chore: 更新 tsconfig 配置

This commit is contained in:
Hooray 2024-09-21 13:26:00 +08:00
parent ffd040a0ef
commit 3ed947c8da
11 changed files with 89 additions and 65 deletions

1
.gitignore vendored
View File

@ -3,5 +3,6 @@ node_modules
dist*
dist-ssr
*.local
*.tsbuildinfo
.eslintcache
.stylelintcache

View File

@ -6,15 +6,15 @@
},
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build:test": "vue-tsc && vite build --mode test",
"build": "vue-tsc -b && vite build",
"build:test": "vue-tsc -b && vite build --mode test",
"serve": "http-server ./dist -o",
"serve:test": "http-server ./dist-test -o",
"svgo": "svgo -f src/assets/icons",
"new": "plop",
"generate:icons": "esno ./scripts/generate.icons.ts",
"lint": "npm-run-all -s lint:tsc lint:eslint lint:stylelint",
"lint:tsc": "vue-tsc",
"lint:tsc": "vue-tsc -b",
"lint:eslint": "eslint . --cache --fix",
"lint:stylelint": "stylelint \"src/**/*.{css,scss,vue}\" --cache --fix",
"postinstall": "simple-git-hooks",

View File

@ -38,7 +38,7 @@ const rules = ref<FormRules>({
checkPassword: [
{ required: true, trigger: 'blur', message: '请再次输入密码' },
{
validator: (rule, value, callback) => {
validator: (_rule, value, callback) => {
if (value !== form.value.password) {
callback(new Error('两次输入的密码不一致'))
}

View File

@ -14,6 +14,14 @@ onMounted(() => {
<template>
<HSlideover v-model="isShow" title="系统信息">
<div v-if="pkg.version" class="px-4">
<h2 class="m-0 text-lg font-bold">
版本号
</h2>
<div class="my-4 text-center text-lg font-sans">
{{ pkg.version }}
</div>
</div>
<div class="px-4">
<h2 class="m-0 text-lg font-bold">
最后编译时间

View File

@ -9,7 +9,7 @@ import { asyncRoutes, asyncRoutesByFilesystem } from './routes'
import '@/assets/styles/nprogress.css'
function setupRoutes(router: Router) {
router.beforeEach(async (to, from, next) => {
router.beforeEach(async (to, _from, next) => {
const settingsStore = useSettingsStore()
const userStore = useUserStore()
const routeStore = useRouteStore()
@ -110,7 +110,7 @@ function setupRoutes(router: Router) {
// 进度条
function setupProgress(router: Router) {
const { isLoading } = useNProgress()
router.beforeEach((to, from, next) => {
router.beforeEach((_to, _from, next) => {
const settingsStore = useSettingsStore()
if (settingsStore.settings.app.enableProgress) {
isLoading.value = true

View File

@ -113,7 +113,7 @@ const useTabbarStore = defineStore(
}
})
keepAliveStore.remove(name)
list.value = list.value.filter((item, i) => {
list.value = list.value.filter((_item, i) => {
return i >= index
})
}
@ -138,7 +138,7 @@ const useTabbarStore = defineStore(
}
})
keepAliveStore.remove(name)
list.value = list.value.filter((item, i) => {
list.value = list.value.filter((_item, i) => {
return i <= index
})
}

49
tsconfig.app.json Executable file
View File

@ -0,0 +1,49 @@
{
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"lib": [
"ESNext",
"DOM",
"DOM.Iterable"
],
"moduleDetection": "force",
"useDefineForClassFields": true,
"baseUrl": "./",
"module": "ESNext",
"moduleResolution": "Bundler",
"paths": {
"@/*": [
"src/*"
],
"#/*": [
"src/types/*"
]
},
"resolveJsonModule": true,
"types": [
"vite/client",
"vite-plugin-pages/client",
"vite-plugin-vue-meta-layouts/client",
"vite-plugin-app-loading/client",
"element-plus/global"
],
"allowImportingTsExtensions": true,
"allowJs": false,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmit": true,
"sourceMap": true,
"esModuleInterop": true,
"isolatedModules": true,
"skipLibCheck": true
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue"
]
}

49
tsconfig.json Executable file → Normal file
View File

@ -1,50 +1,7 @@
{
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"lib": [
"ESNext",
"DOM",
"DOM.Iterable"
],
"useDefineForClassFields": true,
"baseUrl": "./",
"module": "ESNext",
"moduleResolution": "Bundler",
"paths": {
"@/*": [
"src/*"
],
"#/*": [
"src/types/*"
]
},
"resolveJsonModule": true,
"types": [
"vite/client",
"vite-plugin-pages/client",
"vite-plugin-vue-meta-layouts/client",
"vite-plugin-app-loading/client",
"element-plus/global"
],
"allowImportingTsExtensions": true,
"allowJs": false,
"strict": true,
"noEmit": true,
"sourceMap": true,
"esModuleInterop": true,
"isolatedModules": true,
"skipLibCheck": true
},
"references": [
{
"path": "./tsconfig.node.json"
}
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue"
]
"files": []
}

View File

@ -1,9 +1,17 @@
{
"compilerOptions": {
"composite": true,
"target": "ES2022",
"lib": ["ES2023"],
"moduleDetection": "force",
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
},
"include": [

View File

@ -7,16 +7,16 @@ import pkg from './package.json'
import createVitePlugins from './vite/plugins'
// https://vitejs.dev/config/
export default async ({ mode, command }) => {
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
// 全局 scss 资源
const scssResources = []
const scssResources: string[] = []
fs.readdirSync('src/assets/styles/resources').forEach((dirname) => {
if (fs.statSync(`src/assets/styles/resources/${dirname}`).isFile()) {
scssResources.push(`@use "src/assets/styles/resources/${dirname}" as *;`)
}
})
return defineConfig({
return {
// 开发服务器选项 https://cn.vitejs.dev/config/server-options
server: {
open: true,
@ -44,7 +44,7 @@ export default async ({ mode, command }) => {
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
}),
},
plugins: createVitePlugins(env, command === 'build'),
plugins: createVitePlugins(mode, command === 'build'),
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
@ -58,5 +58,5 @@ export default async ({ mode, command }) => {
},
},
},
})
}
}
})

View File

@ -1,4 +1,3 @@
import type { PluginOption } from 'vite'
import path from 'node:path'
import process from 'node:process'
import vueLegacy from '@vitejs/plugin-legacy'
@ -10,6 +9,7 @@ import Unocss from 'unocss/vite'
import autoImport from 'unplugin-auto-import/vite'
import TurboConsole from 'unplugin-turbo-console/vite'
import components from 'unplugin-vue-components/vite'
import { loadEnv, type PluginOption } from 'vite'
import AppLoading from 'vite-plugin-app-loading'
import Archiver from 'vite-plugin-archiver'
import banner from 'vite-plugin-banner'
@ -20,7 +20,8 @@ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import VueDevTools from 'vite-plugin-vue-devtools'
import Layouts from 'vite-plugin-vue-meta-layouts'
export default function createVitePlugins(viteEnv, isBuild = false) {
export default function createVitePlugins(mode: string, isBuild = false) {
const viteEnv = loadEnv(mode, process.cwd())
const vitePlugins: (PluginOption | PluginOption[])[] = [
vue(),
vueJsx(),