diff --git a/order-system/src/jsconfig.json b/order-system/src/jsconfig.json new file mode 100644 index 0000000..37c23f7 --- /dev/null +++ b/order-system/src/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + }, + "types": ["vite/client"] + }, + "exclude": ["node_modules", "dist"] +} \ No newline at end of file diff --git a/order-system/src/router/index.ts b/order-system/src/router/index.ts new file mode 100644 index 0000000..0bf8cc4 --- /dev/null +++ b/order-system/src/router/index.ts @@ -0,0 +1,20 @@ +import { createRouter, createWebHistory } from 'vue-router' +import type { RouteRecordRaw } from 'vue-router' +import Layout from '@/components/HelloWorld.vue' +// console.log('组件路径:', HelloWorld.__file) + + +const routes: Array = [ + { + path: '/home', + name: 'Home', + component: Layout + } +] + +const router = createRouter({ + history: createWebHistory(), + routes +}) + +export default router \ No newline at end of file diff --git a/order-system/src/vite-env.d.ts b/order-system/src/vite-env.d.ts index 11f02fe..41e228f 100644 --- a/order-system/src/vite-env.d.ts +++ b/order-system/src/vite-env.d.ts @@ -1 +1,16 @@ /// +/// + +// 声明 Vue 文件模块 +declare module '*.vue' { + import type { DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} + +// 声明路径别名(可选,增强类型提示) +declare module '@/components/*' { + import type { DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/order-system/tsconfig.app.json b/order-system/tsconfig.app.json index 3dbbc45..321e27c 100644 --- a/order-system/tsconfig.app.json +++ b/order-system/tsconfig.app.json @@ -2,14 +2,27 @@ "extends": "@vue/tsconfig/tsconfig.dom.json", "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - - /* Linting */ + // 添加以下路径配置 + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + }, + // 添加必要的库支持 + "lib": ["ESNext", "DOM"], + // 添加模块解析配置 + "module": "ESNext", + "moduleResolution": "Node", + // 确保包含以下选项 + "target": "ESNext", + "esModuleInterop": true, + "resolveJsonModule": true, "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true + "jsx": "preserve" }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] -} + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.vue", + "vite-env.d.ts" // 确保包含类型声明文件 + ] +} \ No newline at end of file diff --git a/order-system/tsconfig.node.json b/order-system/tsconfig.node.json index c513361..f85a399 100644 --- a/order-system/tsconfig.node.json +++ b/order-system/tsconfig.node.json @@ -5,10 +5,6 @@ "lib": ["ES2023"], "module": "ESNext", "skipLibCheck": true, - "baseUrl": ".", // 设置根目录为项目根目录 - "paths": { - "@/*": ["src/*"] // 将 @/ 映射到 src/ 目录 - }, /* Bundler mode */ "moduleResolution": "bundler", diff --git a/order-system/vite.config.ts b/order-system/vite.config.ts index 482a35d..67b4b64 100644 --- a/order-system/vite.config.ts +++ b/order-system/vite.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' -import { resolve } from 'path' //导入nodejs核心模块path,解构提取resolce方法 +import path from 'path' //导入nodejs核心模块path,解构提取resolce方法 // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], @@ -10,13 +10,23 @@ export default defineConfig({ hmr:true,//开启热更新 open:true//启动在浏览器打开 }, + // resolve: { + // //为项目设置别名,简化项目路径 + // alias: [ + // { + // find: '@', + // replacement: resolve(__dirname, 'src') + // } + // ] + // } resolve: { - //为项目设置别名,简化项目路径 - alias: [ - { - find: '@', - replacement: resolve(__dirname, 'src') - } - ] + // 修正为对象格式 + alias: { + '@': path.resolve(__dirname, 'src'), + // 可以添加更多别名 + 'components': path.resolve(__dirname, 'src/components') + }, + // 添加扩展名支持 + extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], } })