fix: 项目结构优化及后端同步适配 (#11)

Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
2026-09-30 12:11:32 +08:00
parent 0af0256c97
commit f31691c300
34 changed files with 1137 additions and 1623 deletions
+16
View File
@@ -0,0 +1,16 @@
import { registerHooks } from 'node:module'
import { existsSync } from 'node:fs'
const source = new URL('../src/', import.meta.url)
registerHooks({
resolve(specifier, context, nextResolve) {
if (specifier.startsWith('@/')) {
return nextResolve(new URL(`${specifier.slice(2)}.ts`, source).href, context)
}
if (specifier.startsWith('.') && context.parentURL?.startsWith(source.href)) {
const candidate = new URL(`${specifier}.ts`, context.parentURL)
if (existsSync(candidate)) return nextResolve(candidate.href, context)
}
return nextResolve(specifier, context)
},
})