适配typescript编译

This commit is contained in:
tangly1024.com
2024-09-23 18:46:53 +08:00
parent 65d1932837
commit d94344c14a
5 changed files with 36 additions and 18 deletions

View File

@@ -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: [

View File

@@ -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()
}

View File

@@ -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
}
}
}

View File

@@ -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)',

View File

@@ -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"
]
}