From d94344c14a8d77786b479d19d68acad723ebabe0 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 23 Sep 2024 18:46:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dtypescript=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/CustomNotionApi.ts | 20 ++++++++++++++++---- middleware.ts | 2 +- pages/api/auth/callback/notion.ts | 6 +++++- tailwind.config.js | 3 ++- tsconfig.json | 23 ++++++++++++----------- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/lib/notion/CustomNotionApi.ts b/lib/notion/CustomNotionApi.ts index d9f83c33..fc5f46c9 100644 --- a/lib/notion/CustomNotionApi.ts +++ b/lib/notion/CustomNotionApi.ts @@ -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: [ diff --git a/middleware.ts b/middleware.ts index b121de0d..03ebb331 100644 --- a/middleware.ts +++ b/middleware.ts @@ -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() } diff --git a/pages/api/auth/callback/notion.ts b/pages/api/auth/callback/notion.ts index f11824e6..b69a1982 100644 --- a/pages/api/auth/callback/notion.ts +++ b/pages/api/auth/callback/notion.ts @@ -110,6 +110,10 @@ const fetchToken = async (code: string): Promise => { } } catch (error) { console.error('Error fetching token', error) - return null + return { + status: 400, + statusText: 'failed', + data: null as unknown as NotionTokenResponseData + } } } diff --git a/tailwind.config.js b/tailwind.config.js index 485f82c5..da9f7875 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -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)', diff --git a/tsconfig.json b/tsconfig.json index c882f101..4dc644e1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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" + ] }