Skip to content

Commit cf3b9e0

Browse files
committed
chore: 更新 tsconfig 配置
1 parent 8d2fa97 commit cf3b9e0

File tree

10 files changed

+84
-60
lines changed

10 files changed

+84
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules
33
dist*
44
dist-ssr
55
*.local
6+
*.tsbuildinfo
67
.eslintcache
78
.stylelintcache
89
public/icons

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
},
77
"scripts": {
88
"dev": "vite",
9-
"build:test": "vue-tsc && vite build --mode test",
10-
"build": "vue-tsc && vite build",
9+
"build:test": "vue-tsc -b && vite build --mode test",
10+
"build": "vue-tsc -b && vite build",
1111
"serve:test": "http-server ./dist-test -o",
1212
"serve": "http-server ./dist -o",
1313
"svgo": "svgo -f src/assets/icons",
1414
"new": "plop",
1515
"generate:icons": "esno ./scripts/generate.icons.ts",
1616
"lint": "npm-run-all -s lint:tsc lint:eslint lint:stylelint",
17-
"lint:tsc": "vue-tsc",
17+
"lint:tsc": "vue-tsc -b",
1818
"lint:eslint": "eslint . --cache --fix",
1919
"lint:stylelint": "stylelint \"src/**/*.{css,scss,vue}\" --cache --fix",
2020
"postinstall": "simple-git-hooks",

src/components/RegisterForm/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const rules = ref<FormRules>({
3838
checkPassword: [
3939
{ required: true, trigger: 'blur', message: '请再次输入密码' },
4040
{
41-
validator: (rule, value, callback) => {
41+
validator: (_rule, value, callback) => {
4242
if (value !== form.value.password) {
4343
callback(new Error('两次输入的密码不一致'))
4444
}

src/components/SystemInfo/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ onMounted(() => {
1414

1515
<template>
1616
<HSlideover v-model="isShow" title="系统信息">
17+
<div v-if="pkg.version" class="px-4">
18+
<h2 class="m-0 text-lg font-bold">
19+
版本号
20+
</h2>
21+
<div class="my-4 text-center text-lg font-sans">
22+
{{ pkg.version }}
23+
</div>
24+
</div>
1725
<div class="px-4">
1826
<h2 class="m-0 text-lg font-bold">
1927
最后编译时间

src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const router = createRouter({
3838
routes,
3939
})
4040

41-
router.beforeEach((to, from, next) => {
41+
router.beforeEach((to, _from, next) => {
4242
const settingsStore = useSettingsStore()
4343
const userStore = useUserStore()
4444
const menuStore = useMenuStore()

tsconfig.app.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"jsx": "preserve",
5+
"lib": [
6+
"ESNext",
7+
"DOM",
8+
"DOM.Iterable"
9+
],
10+
"moduleDetection": "force",
11+
"useDefineForClassFields": true,
12+
"baseUrl": "./",
13+
"module": "ESNext",
14+
"moduleResolution": "Bundler",
15+
"paths": {
16+
"@/*": [
17+
"src/*"
18+
],
19+
"#/*": [
20+
"src/types/*"
21+
]
22+
},
23+
"resolveJsonModule": true,
24+
"types": [
25+
"vite/client",
26+
"vite-plugin-app-loading/client",
27+
"element-plus/global"
28+
],
29+
"allowImportingTsExtensions": true,
30+
"allowJs": false,
31+
"strict": true,
32+
"noFallthroughCasesInSwitch": true,
33+
"noUnusedLocals": true,
34+
"noUnusedParameters": true,
35+
"noEmit": true,
36+
"sourceMap": true,
37+
"esModuleInterop": true,
38+
"isolatedModules": true,
39+
"skipLibCheck": true
40+
},
41+
"include": [
42+
"src/**/*.ts",
43+
"src/**/*.d.ts",
44+
"src/**/*.tsx",
45+
"src/**/*.vue"
46+
]
47+
}

tsconfig.json

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,7 @@
11
{
2-
"compilerOptions": {
3-
"target": "ESNext",
4-
"jsx": "preserve",
5-
"lib": [
6-
"ESNext",
7-
"DOM",
8-
"DOM.Iterable"
9-
],
10-
"useDefineForClassFields": true,
11-
"baseUrl": "./",
12-
"module": "ESNext",
13-
"moduleResolution": "Bundler",
14-
"paths": {
15-
"@/*": [
16-
"src/*"
17-
],
18-
"#/*": [
19-
"src/types/*"
20-
]
21-
},
22-
"resolveJsonModule": true,
23-
"types": [
24-
"vite/client",
25-
"vite-plugin-app-loading/client",
26-
"element-plus/global"
27-
],
28-
"allowImportingTsExtensions": true,
29-
"allowJs": false,
30-
"strict": true,
31-
"noEmit": true,
32-
"sourceMap": true,
33-
"esModuleInterop": true,
34-
"isolatedModules": true,
35-
"skipLibCheck": true
36-
},
372
"references": [
38-
{
39-
"path": "./tsconfig.node.json"
40-
}
3+
{ "path": "./tsconfig.app.json" },
4+
{ "path": "./tsconfig.node.json" }
415
],
42-
"include": [
43-
"src/**/*.ts",
44-
"src/**/*.d.ts",
45-
"src/**/*.tsx",
46-
"src/**/*.vue"
47-
]
6+
"files": []
487
}

tsconfig.node.json

100644100755
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
3+
"target": "ES2022",
4+
"lib": ["ES2023"],
5+
"moduleDetection": "force",
46
"module": "ESNext",
5-
"moduleResolution": "bundler",
6-
"allowSyntheticDefaultImports": true,
7+
"moduleResolution": "Bundler",
8+
"allowImportingTsExtensions": true,
9+
"strict": true,
10+
"noFallthroughCasesInSwitch": true,
11+
"noUnusedLocals": true,
12+
"noUnusedParameters": true,
13+
"noEmit": true,
14+
"isolatedModules": true,
715
"skipLibCheck": true
816
},
917
"include": [

vite.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import pkg from './package.json'
77
import createVitePlugins from './vite/plugins'
88

99
// https://vitejs.dev/config/
10-
export default ({ mode, command }) => {
10+
export default defineConfig(({ mode, command }) => {
1111
const env = loadEnv(mode, process.cwd())
1212
// 全局 scss 资源
13-
const scssResources = []
13+
const scssResources: string[] = []
1414
fs.readdirSync('src/assets/styles/resources').forEach((dirname) => {
1515
if (fs.statSync(`src/assets/styles/resources/${dirname}`).isFile()) {
1616
scssResources.push(`@use "src/assets/styles/resources/${dirname}" as *;`)
1717
}
1818
})
19-
return defineConfig({
19+
return {
2020
// 开发服务器选项 https://cn.vitejs.dev/config/server-options
2121
server: {
2222
open: true,
@@ -44,7 +44,7 @@ export default ({ mode, command }) => {
4444
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
4545
}),
4646
},
47-
plugins: createVitePlugins(env, command === 'build'),
47+
plugins: createVitePlugins(mode, command === 'build'),
4848
resolve: {
4949
alias: {
5050
'@': path.resolve(__dirname, 'src'),
@@ -57,5 +57,5 @@ export default ({ mode, command }) => {
5757
},
5858
},
5959
},
60-
})
61-
}
60+
}
61+
})

vite/plugins.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { PluginOption } from 'vite'
21
import path from 'node:path'
32
import process from 'node:process'
43
import vue from '@vitejs/plugin-vue'
@@ -9,14 +8,16 @@ import Unocss from 'unocss/vite'
98
import autoImport from 'unplugin-auto-import/vite'
109
import TurboConsole from 'unplugin-turbo-console/vite'
1110
import components from 'unplugin-vue-components/vite'
11+
import { loadEnv, type PluginOption } from 'vite'
1212
import AppLoading from 'vite-plugin-app-loading'
1313
import Archiver from 'vite-plugin-archiver'
1414
import banner from 'vite-plugin-banner'
1515
import { compression } from 'vite-plugin-compression2'
1616
import { vitePluginFakeServer } from 'vite-plugin-fake-server'
1717
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
1818

19-
export default function createVitePlugins(viteEnv, isBuild = false) {
19+
export default function createVitePlugins(mode: string, isBuild = false) {
20+
const viteEnv = loadEnv(mode, process.cwd())
2021
const vitePlugins: (PluginOption | PluginOption[])[] = [
2122
vue(),
2223
vueJsx(),

0 commit comments

Comments
 (0)