mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
适配typescript编译
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
const axios = require('axios')
|
||||
|
||||
// 发送 Notion API 请求
|
||||
async function postNotion(properties, databaseId, listContentMain, token) {
|
||||
async function postNotion(
|
||||
properties: any,
|
||||
databaseId: string,
|
||||
listContentMain: any[],
|
||||
token: string
|
||||
) {
|
||||
const url = 'https://api.notion.com/v1/pages'
|
||||
|
||||
const children = listContentMain
|
||||
@@ -46,14 +51,14 @@ async function postNotion(properties, databaseId, listContentMain, token) {
|
||||
try {
|
||||
const response = await axios.post(url, payload, { headers })
|
||||
return response
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('写入Notion异常', error)
|
||||
throw new Error(`Error posting to Notion: ${error.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理响应结果
|
||||
function responseResult(response) {
|
||||
function responseResult(response: { status: number; data: any }) {
|
||||
if (response.status === 200) {
|
||||
console.log('成功...')
|
||||
console.log(response.data)
|
||||
@@ -64,7 +69,14 @@ function responseResult(response) {
|
||||
}
|
||||
|
||||
// 准备属性字段
|
||||
function notionProperty(id, avatar, name, mail, lastLoginTime, token) {
|
||||
function notionProperty(
|
||||
id: any,
|
||||
avatar: any,
|
||||
name: any,
|
||||
mail: any,
|
||||
lastLoginTime: any,
|
||||
token: any
|
||||
) {
|
||||
return {
|
||||
id: {
|
||||
rich_text: [
|
||||
|
||||
@@ -27,7 +27,7 @@ const isTenantAdminRoute = createRouteMatcher([
|
||||
* @param ev
|
||||
* @returns
|
||||
*/
|
||||
const noAuthMiddleware = async (req, ev) => {
|
||||
const noAuthMiddleware = async (req: any, ev: any) => {
|
||||
// 如果没有配置 Clerk 相关环境变量,返回一个默认响应或者继续处理请求
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
@@ -110,6 +110,10 @@ const fetchToken = async (code: string): Promise<NotionTokenResponse> => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching token', error)
|
||||
return null
|
||||
return {
|
||||
status: 400,
|
||||
statusText: 'failed',
|
||||
data: null as unknown as NotionTokenResponseData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ module.exports = {
|
||||
maxWidth: {
|
||||
side: '14rem',
|
||||
'9/10': '90%',
|
||||
'screen-3xl': '1440px'
|
||||
'screen-3xl': '1440px',
|
||||
'screen-4xl': '1560px'
|
||||
},
|
||||
boxShadow: {
|
||||
input: '0px 7px 20px rgba(0, 0, 0, 0.03)',
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./*"],
|
||||
"@/components/*": ["components/*"],
|
||||
"@/theme/*": ["theme/*"],
|
||||
"@/data/*": ["data/*"],
|
||||
"@/lib/*": ["lib/*"],
|
||||
"@/styles/*": ["styles/*"]
|
||||
"@/*": [
|
||||
"./*"
|
||||
]
|
||||
},
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"incremental": true,
|
||||
"target": "es6",
|
||||
"module": "esnext",
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node",
|
||||
@@ -25,11 +25,12 @@
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.json",
|
||||
// "**/*.js",
|
||||
"**/*.js",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/*.jsx"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user