@movk/nuxt-docs 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/modules/ai-chat/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
1
3
|
import { addComponentsDir, addImportsDir, addServerHandler, createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
2
4
|
|
|
3
5
|
export interface AiChatModuleOptions {
|
|
@@ -65,11 +67,28 @@ export default defineNuxtModule<AiChatModuleOptions>({
|
|
|
65
67
|
|
|
66
68
|
addImportsDir(resolve('runtime/composables'))
|
|
67
69
|
|
|
70
|
+
/**
|
|
71
|
+
* 检查用户项目中是否存在自定义 handler
|
|
72
|
+
* '/api/ai-chat' -> 'api/ai-chat','/custom' -> 'custom'
|
|
73
|
+
*/
|
|
68
74
|
const routePath = options.apiPath!.replace(/^\//, '')
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
const extensions = ['ts', 'js', 'mjs']
|
|
76
|
+
|
|
77
|
+
const possibleHandlerPaths = extensions.flatMap(ext => [
|
|
78
|
+
join(nuxt.options.serverDir, `${routePath}.${ext}`),
|
|
79
|
+
join(nuxt.options.serverDir, routePath, `index.${ext}`)
|
|
80
|
+
])
|
|
81
|
+
|
|
82
|
+
const hasCustomHandler = possibleHandlerPaths.some(path => existsSync(path))
|
|
83
|
+
|
|
84
|
+
if (!hasCustomHandler) {
|
|
85
|
+
addServerHandler({
|
|
86
|
+
route: options.apiPath!,
|
|
87
|
+
handler: resolve('./runtime/server/api/ai-chat')
|
|
88
|
+
})
|
|
89
|
+
} else {
|
|
90
|
+
console.info(`[ai-chat] Using custom handler, skipping default handler registration`)
|
|
91
|
+
}
|
|
73
92
|
}
|
|
74
93
|
})
|
|
75
94
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt-docs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Modern Nuxt 4 documentation theme with auto-generated component docs, AI chat assistant, MCP server, and complete developer experience optimization.",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|
|
File without changes
|