fix: 修复已知问题并优化代码质量

This commit is contained in:
fonghehe 2026-04-28 10:51:28 +08:00
parent 293bcb0291
commit 7552cc175b
22 changed files with 3821 additions and 1433 deletions

View File

@ -1,6 +1,9 @@
# 是否开启数据mock
VITE_USE_MOCK=true
# Token Key
VITE_TOKEN_KEY=Authorization
# 是否开启调试工具
VITE_USE_ERUDA=true

View File

@ -1,6 +1,9 @@
# 是否开启数据mock
VITE_USE_MOCK=true
# Token Key
VITE_TOKEN_KEY=Authorization
# 是否开启调试工具
VITE_USE_ERUDA=false

View File

@ -1,6 +1,9 @@
# 是否开启数据mock
VITE_USE_MOCK=true
# Token Key
VITE_TOKEN_KEY=Authorization
# 是否开启调试工具
VITE_USE_ERUDA=true

View File

@ -16,7 +16,6 @@
"ShallowRef": true,
"Slot": true,
"Slots": true,
"Snackbar": true,
"VNode": true,
"WritableComputedRef": true,
"acceptHMRUpdate": true,
@ -72,7 +71,6 @@
"shallowReactive": true,
"shallowReadonly": true,
"shallowRef": true,
"showToast": true,
"storeToRefs": true,
"toRaw": true,
"toRef": true,

View File

@ -1,6 +1,4 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.preferences.autoImportFileExcludePatterns": ["vue-router"],
"npm.packageManager": "pnpm",
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode",

View File

@ -1,6 +1,6 @@
FROM nginx
FROM nginx:1.27-alpine
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/ /usr/share/nginx/html/dist/
COPY dist/ /usr/share/nginx/html/
# 用本地的 nginx.conf 配置来替换nginx镜像里的默认配置
COPY nginx.conf /etc/nginx/nginx.conf

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@ -13,33 +13,5 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script>
window.onload = function () {
document.addEventListener('touchstart', function (event) {
if (event.touches.length > 1) {
event.preventDefault();
}
});
var lastTouchEnd = 0;
document.addEventListener(
'touchend',
function (event) {
var now = new Date().getTime();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
},
false,
);
document.addEventListener('gesturestart', function (event) {
event.preventDefault();
});
};
</script>
</body>
</html>

View File

@ -18,8 +18,14 @@ http {
charset utf-8;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
location / {
root html;
root /usr/share/nginx/html;
try_files $uri $uri/ @router;
index index.html index.htm;
}

View File

@ -10,99 +10,99 @@
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged",
"prepare": "husky install",
"deps": "yarn upgrade-interactive --latest",
"deps": "pnpm up -i",
"commit": "git add . && git-cz"
},
"dependencies": {
"@nutui/icons-vue": "^0.1.1",
"@nutui/nutui": "^4.3.13",
"@varlet/ui": "^3.13.0",
"@varlet/ui": "^3.15.1",
"@vueuse/core": "14.1.0",
"@vueuse/integrations": "14.1.0",
"axios": "1.13.2",
"dayjs": "^1.11.19",
"dayjs": "^1.11.20",
"mitt": "^3.0.1",
"pinia": "^3.0.4",
"pinia-plugin-persistedstate": "^4.7.1",
"universal-cookie": "^8.0.1",
"vant": "^4.9.22",
"vue": "^3.5.27",
"vue-i18n": "^11.2.8",
"universal-cookie": "^8.1.0",
"vant": "^4.9.24",
"vue": "^3.5.33",
"vue-i18n": "^11.4.0",
"vue-router": "^4.6.4"
},
"devDependencies": {
"@commitlint/cli": "^20.3.1",
"@commitlint/config-conventional": "^20.3.1",
"@commitlint/cli": "^20.5.2",
"@commitlint/config-conventional": "^20.5.0",
"@nutui/auto-import-resolver": "^1.0.0",
"@stylistic/stylelint-plugin": "^4.0.0",
"@stylistic/stylelint-plugin": "^4.0.1",
"@tsconfig/node22": "^22.0.5",
"@types/jsdom": "^21.1.7",
"@types/node": "^24.8.1",
"@typescript-eslint/parser": "^8.53.1",
"@types/node": "^24.12.2",
"@typescript-eslint/parser": "^8.59.1",
"@vant/auto-import-resolver": "^1.3.0",
"@varlet/import-resolver": "^3.13.0",
"@vitejs/plugin-basic-ssl": "^2.1.4",
"@varlet/import-resolver": "^3.15.1",
"@vitejs/plugin-basic-ssl": "^2.3.0",
"@vitejs/plugin-legacy": "^7.2.1",
"@vitejs/plugin-vue": "^6.0.3",
"@vitejs/plugin-vue-jsx": "^5.1.3",
"@vitejs/plugin-vue": "^6.0.6",
"@vitejs/plugin-vue-jsx": "^5.1.5",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.5.0",
"@vue/test-utils": "^2.4.0",
"@vue/eslint-config-typescript": "^14.7.0",
"@vue/test-utils": "^2.4.9",
"@vue/tsconfig": "^0.8.1",
"@zhaojjiang/vite-plugin-eruda": "^0.0.5",
"amfe-flexible": "^2.2.1",
"autoprefixer": "^10.4.23",
"autoprefixer": "^10.5.0",
"cnjm-postcss-px-to-viewport": "^1.0.1",
"consola": "^3.4.2",
"cross-env": "^10.1.0",
"cz-git": "^1.11.1",
"czg": "^1.11.1",
"cz-git": "^1.13.0",
"czg": "^1.13.0",
"eruda": "^3.4.1",
"eslint": "^9.39.2",
"eslint": "^9.39.4",
"eslint-define-config": "^2.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.5.5",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-vue": "^10.7.0",
"eslint-plugin-vue": "^10.9.0",
"git-cz": "^4.9.0",
"husky": "9.1.7",
"jsdom": "^27.4.0",
"lint-staged": "16.2.7",
"mockjs": "^1.1.0",
"node": "^22.18.0",
"node": "^22.22.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.5.3",
"postcss": "^8.5.12",
"postcss-html": "1.8.1",
"postcss-scss": "^4.0.9",
"prettier": "^3.8.0",
"rollup-plugin-visualizer": "^6.0.5",
"stylelint": "^16.25.0",
"stylelint-config-recess-order": "^7.4.0",
"prettier": "^3.8.3",
"rollup-plugin-visualizer": "^6.0.11",
"stylelint": "^16.26.1",
"stylelint-config-recess-order": "^7.7.0",
"stylelint-config-recommended": "^17.0.0",
"stylelint-config-recommended-scss": "^16.0.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^39.0.1",
"stylelint-order": "^7.0.1",
"stylelint-prettier": "^5.0.3",
"stylelint-scss": "^6.11.0",
"terser": "^5.46.0",
"stylelint-scss": "^6.14.0",
"terser": "^5.46.2",
"typescript": "5.9.3",
"unplugin-auto-import": "^21.0.0",
"unplugin-vue-components": "^31.0.0",
"vite": "^7.3.1",
"unplugin-vue-components": "^31.1.0",
"vite": "^7.3.2",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-imagemin": "^0.6.1",
"vite-plugin-mock": "^3.0.2",
"vite-plugin-pages": "^0.33.2",
"vite-plugin-pages": "^0.33.3",
"vite-plugin-progress": "^0.0.7",
"vite-plugin-pwa": "^1.2.0",
"vite-plugin-qrcode": "^0.3.0",
"vite-plugin-restart": "^2.0.0",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-setup-extend-plus": "^0.1.0",
"vitest": "^4.0.17",
"vue-eslint-parser": "^10.1.3",
"vue-tsc": "^3.2.2"
"vitest": "^4.1.5",
"vue-eslint-parser": "^10.4.0",
"vue-tsc": "^3.2.7"
},
"engines": {
"node": ">=20.10.0",
@ -123,7 +123,7 @@
"prettier --write"
],
"{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [
"prettier --write--parser json"
"prettier --write --parser json"
],
"package.json": [
"prettier --write"

5073
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -53,19 +53,9 @@
);
const tabSwitch = (_item: any, index: number) => {
switch (index) {
case 0:
router.push('/home');
break;
case 1:
router.push('/list');
break;
case 2:
router.push('/member');
break;
case 3:
router.push('/demo');
break;
const tab = tabItem[index];
if (tab) {
router.push(`/${tab.key}`);
}
activeTab.value = index;
};

View File

@ -59,7 +59,6 @@ export async function setLang(locale?: string) {
const loader = localeLoaders[target];
if (loader) {
const messages = await loader();
console.log(messages);
i18n.global.setLocaleMessage(target, messages);
}
}

View File

@ -60,9 +60,9 @@ export const routes: RouteRecordRaw[] = [
},
// 匹配不到重定向会主页
{
// 找不到路由重定向到404页面
// 找不到路由重定向到首页
path: '/:pathMatch(.*)',
redirect: '/Home',
redirect: '/home',
},
];

View File

@ -1,11 +1,6 @@
import { loginPassword } from '@/api';
import { useCookies } from '@vueuse/integrations/useCookies';
import { defineStore } from 'pinia';
const { VITE_TOKEN_KEY } = import.meta.env;
const token = useCookies().get(VITE_TOKEN_KEY as string);
console.log(token);
interface StoreUser {
token: string;
info: Record<any, any>;
@ -13,7 +8,7 @@ interface StoreUser {
export const useUserStore = defineStore('user', {
state: (): StoreUser => ({
token: 'token',
token: '',
info: {},
}),
getters: {

View File

@ -22,6 +22,7 @@ body {
'Helvetica Neue',
sans-serif;
color: var(--color-text);
touch-action: manipulation;
background: var(--color-background);
text-rendering: optimizelegibility;
transition:

View File

@ -3,6 +3,7 @@ import type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, Inte
import { showToast } from 'vant';
const service: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '',
withCredentials: false,
timeout: 10000,
});

View File

@ -1,7 +1,5 @@
import { useAxios } from '@vueuse/integrations';
import 'vant/es/toast/style';
/**
* reactive useFetchApi
*/

View File

@ -1,11 +1,12 @@
import { createFetch } from '@vueuse/core';
import { useCookies } from '@vueuse/integrations/useCookies';
import { showNotify } from 'vant';
const useFetchApi = createFetch({
baseUrl: '',
options: {
async beforeFetch({ options }) {
const myToken = 'token';
const myToken = useCookies().get((import.meta.env.VITE_TOKEN_KEY as string) || 'Authorization') || '';
options.headers = {
...options.headers,
Authorization: `Bearer ${myToken}`,
@ -17,7 +18,7 @@ const useFetchApi = createFetch({
if (response.status >= 200 && response.status < 300) {
try {
const jsonObj = data;
if (jsonObj.code != 200) {
if (jsonObj.code !== 200) {
showNotify({ type: 'danger', message: jsonObj.message || 'Error' });
}

View File

@ -43,7 +43,7 @@
watch(
() => router,
(val) => {
details.data = detailsData.find((_item, index) => index == parseInt(val.currentRoute.value.query.id as string));
details.data = detailsData.find((_item, index) => index === parseInt(val.currentRoute.value.query.id as string));
},
{ deep: true, immediate: true },
);

View File

@ -62,6 +62,7 @@ module.exports = {
'named-grid-areas-no-invalid': null,
'no-descending-specificity': null,
'no-empty-source': null,
'declaration-property-value-no-unknown': null,
'order/order': [
[
'dollar-variables',

View File

@ -17,7 +17,6 @@
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}

9
types/module.d.ts vendored
View File

@ -1,15 +1,10 @@
declare module '*.vue' {
import { DefineComponent } from 'vue';
import type { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
const Component: DefineComponent<{}, {}, any>;
export default Component;
}
declare module 'ant-design-vue/es/locale/*' {
import { Locale } from 'ant-design-vue/types/locale-provider';
const locale: Locale & ReadonlyRecordable;
export default locale as Locale & ReadonlyRecordable;
}
declare module 'virtual:*' {
const result: any;
export default result;