fix(web): 修复代码格式和文件清理问题

清理无用文件和资源,调整代码格式统一双引号,修复部分组件路径引用问题

删除大量无用图片资源和组件文件,统一代码风格使用双引号,修复国际化文件路径引用,调整部分组件逻辑,优化项目结构
This commit is contained in:
zhangtao
2026-05-01 01:05:16 +08:00
parent 80263e98e1
commit b7800e2ddd
595 changed files with 24834 additions and 103011 deletions
-6
View File
@@ -1,6 +0,0 @@
import type { App } from 'vue';
import { InstallCodeMirror } from 'codemirror-editor-vue3';
export function initCodeMirror(app: App<Element>) {
app.use(InstallCodeMirror);
}
+24 -24
View File
@@ -1,9 +1,9 @@
import axios, { AxiosResponse } from 'axios';
import { ElLoading, ElMessage } from 'element-plus';
import { saveAs as fileSaverSaveAs } from 'file-saver';
import { Auth } from '@/utils/auth';
import errorCode from '@/utils/errorCode';
import { blobValidate } from '@/utils/common';
import axios, { AxiosResponse } from "axios";
import { ElLoading, ElMessage } from "element-plus";
import { saveAs as fileSaverSaveAs } from "file-saver";
import { Auth } from "@/utils/auth";
import errorCode from "@/utils/errorCode";
import { blobValidate } from "@/utils/common";
const baseURL = import.meta.env.VITE_APP_BASE_API;
let downloadLoadingInstance: any;
@@ -19,17 +19,17 @@ interface DownloadUtil {
const download: DownloadUtil = {
name(name: string, isDelete: boolean = true): void {
const url =
baseURL + '/common/download?fileName=' + encodeURIComponent(name) + '&delete=' + isDelete;
baseURL + "/common/download?fileName=" + encodeURIComponent(name) + "&delete=" + isDelete;
axios({
method: 'get',
method: "get",
url,
responseType: 'blob',
headers: { Authorization: 'Bearer ' + Auth.getAccessToken() },
responseType: "blob",
headers: { Authorization: "Bearer " + Auth.getAccessToken() },
}).then((res: AxiosResponse<Blob>) => {
const isBlob = blobValidate(res.data);
if (isBlob) {
const blob = new Blob([res.data]);
download.saveAs(blob, decodeURIComponent(res.headers['download-filename']));
download.saveAs(blob, decodeURIComponent(res.headers["download-filename"]));
} else {
download.printErrMsg(res.data);
}
@@ -37,17 +37,17 @@ const download: DownloadUtil = {
},
resource(resource: string): void {
const url = baseURL + '/common/download/resource?resource=' + encodeURIComponent(resource);
const url = baseURL + "/common/download/resource?resource=" + encodeURIComponent(resource);
axios({
method: 'get',
method: "get",
url,
responseType: 'blob',
headers: { Authorization: 'Bearer ' + Auth.getAccessToken() },
responseType: "blob",
headers: { Authorization: "Bearer " + Auth.getAccessToken() },
}).then((res: AxiosResponse<Blob>) => {
const isBlob = blobValidate(res.data);
if (isBlob) {
const blob = new Blob([res.data]);
download.saveAs(blob, decodeURIComponent(res.headers['download-filename']));
download.saveAs(blob, decodeURIComponent(res.headers["download-filename"]));
} else {
download.printErrMsg(res.data);
}
@@ -57,19 +57,19 @@ const download: DownloadUtil = {
zip(url: string, name: string): void {
const fullUrl = baseURL + url;
downloadLoadingInstance = ElLoading.service({
text: '正在下载数据,请稍候',
background: 'rgba(0, 0, 0, 0.7)',
text: "正在下载数据,请稍候",
background: "rgba(0, 0, 0, 0.7)",
});
axios({
method: 'get',
method: "get",
url: fullUrl,
responseType: 'blob',
headers: { Authorization: 'Bearer ' + Auth.getAccessToken() },
responseType: "blob",
headers: { Authorization: "Bearer " + Auth.getAccessToken() },
})
.then((res: AxiosResponse<Blob>) => {
const isBlob = blobValidate(res.data);
if (isBlob) {
const blob = new Blob([res.data], { type: 'application/zip' });
const blob = new Blob([res.data], { type: "application/zip" });
download.saveAs(blob, name);
} else {
download.printErrMsg(res.data);
@@ -78,7 +78,7 @@ const download: DownloadUtil = {
})
.catch((r: any) => {
console.error(r);
ElMessage.error('下载文件出现错误,请联系管理员!');
ElMessage.error("下载文件出现错误,请联系管理员!");
downloadLoadingInstance.close();
});
},
@@ -90,7 +90,7 @@ const download: DownloadUtil = {
async printErrMsg(data: Blob): Promise<void> {
const resText = await data.text();
const rspObj = JSON.parse(resText);
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'];
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode["default"];
ElMessage.error(errMsg);
},
};
-76
View File
@@ -1,76 +0,0 @@
/**
* ECharts 插件配置
*
* 按需导入 ECharts 图表和组件,减小打包体积。
* 只注册项目中实际使用的图表类型和组件。
*
* @module plugins/echarts
* @author Fastapi Admin Team
*/
// ECharts 按需导入配置
import * as echarts from 'echarts/core';
// 导入图表类型
import {
BarChart,
LineChart,
PieChart,
ScatterChart,
RadarChart,
MapChart,
CandlestickChart,
} from 'echarts/charts';
// 导入组件
import {
TitleComponent,
TooltipComponent,
GridComponent,
LegendComponent,
DataZoomComponent,
MarkPointComponent,
MarkLineComponent,
ToolboxComponent,
BrushComponent,
GeoComponent,
VisualMapComponent,
} from 'echarts/components';
// 导入渲染器
import { CanvasRenderer } from 'echarts/renderers';
// 注册必要的组件
echarts.use([
// 图表类型
BarChart,
LineChart,
PieChart,
ScatterChart,
RadarChart,
MapChart,
CandlestickChart,
// 组件
TitleComponent,
TooltipComponent,
GridComponent,
LegendComponent,
DataZoomComponent,
MarkPointComponent,
MarkLineComponent,
ToolboxComponent,
BrushComponent,
GeoComponent,
VisualMapComponent,
// 渲染器
CanvasRenderer,
]);
// 导出 echarts 实例和类型
export { echarts };
export type { EChartsOption, BarSeriesOption } from 'echarts';
// 导出常用的图形工具
export const graphic = echarts.graphic;
-6
View File
@@ -1,6 +0,0 @@
import type { App } from 'vue';
import ElementPlus from 'element-plus';
export function initElementPlus(app: App<Element>) {
app.use(ElementPlus);
}
-6
View File
@@ -1,6 +0,0 @@
import type { App } from 'vue';
import i18n from '@/locales';
export function initI18n(app: App<Element>) {
app.use(i18n);
}
+2 -2
View File
@@ -1,5 +1,5 @@
import type { App } from 'vue';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import type { App } from "vue";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
// 注册所有图标
export function initElIcons(app: App<Element>) {
+12 -19
View File
@@ -1,18 +1,18 @@
import type { App } from 'vue';
import type { App } from "vue";
import { initDirectives } from '@/directives';
import { initRouter } from '@/router';
import { initStore } from '@/store';
import { initElIcons } from './icons';
import { initPermission } from './permission';
import { initI18n } from './i18n';
import { initCodeMirror } from './codemirror';
import { initElementPlus } from './elementPlus';
import { setupDirective } from "@/directives";
import { initI18n } from "@/locales";
import { initRouter } from "@/router";
import { initStore } from "@/store";
import { initElIcons } from "./icons";
import { initPermission } from "./permission";
import { InstallCodeMirror } from "codemirror-editor-vue3";
import ElementPlus from "element-plus";
export default {
install(app: App<Element>) {
// 自定义指令(directive)
initDirectives(app);
setupDirective(app);
// 路由(router)
initRouter(app);
// 状态管理(store)
@@ -24,15 +24,8 @@ export default {
// 路由守卫
initPermission(app);
// 注册 CodeMirror
initCodeMirror(app);
app.use(InstallCodeMirror);
// 注册 ElementPlus
initElementPlus(app);
app.use(ElementPlus);
},
};
/**
* 插件统一导出
* 集中管理第三方库的封装和配置
*/
export * from './echarts';
+14 -14
View File
@@ -1,13 +1,13 @@
import type { App } from 'vue';
import type { NavigationGuardNext, RouteLocationNormalized, RouteRecordRaw } from 'vue-router';
import NProgress from '@/utils/nprogress';
import { Auth } from '@/utils/auth';
import router from '@/router';
import { usePermissionStore, useUserStore } from '@/store';
import type { App } from "vue";
import type { NavigationGuardNext, RouteLocationNormalized, RouteRecordRaw } from "vue-router";
import NProgress from "@/utils/nprogress";
import { Auth } from "@/utils/auth";
import router from "@/router";
import { usePermissionStore, useUserStore } from "@/store";
export function initPermission(app: App<Element>) {
// 白名单路由
const whiteList = ['/login'];
const whiteList = ["/login"];
router.beforeEach(async (to, from, next) => {
NProgress.start();
@@ -17,8 +17,8 @@ export function initPermission(app: App<Element>) {
if (isLoggedIn) {
// 如果已登录但访问登录页,重定向到首页
if (to.path === '/login') {
next({ path: '/' });
if (to.path === "/login") {
next({ path: "/" });
return;
}
@@ -35,7 +35,7 @@ export function initPermission(app: App<Element>) {
}
} catch (error) {
// 错误处理:重置状态并跳转登录(保留 redirect 与未登录分支一致)
console.error('Route guard error:', error);
console.error("Route guard error:", error);
await useUserStore().resetAllState();
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`);
NProgress.done();
@@ -79,14 +79,14 @@ async function handleAuthenticatedUser(
// 路由已加载,检查路由是否存在
if (to.matched.length === 0) {
next('/404');
next("/404");
return;
}
// 动态设置页面标题(仅做简单净化,避免 query 注入标签/过长字符串影响标签栏展示)
const rawTitle = (to.params.title as string) || (to.query.title as string);
if (rawTitle && typeof rawTitle === 'string') {
const safe = rawTitle.replace(/[<>]/g, '').trim().slice(0, 64);
if (rawTitle && typeof rawTitle === "string") {
const safe = rawTitle.replace(/[<>]/g, "").trim().slice(0, 64);
if (safe) {
to.meta.title = safe;
}
@@ -94,7 +94,7 @@ async function handleAuthenticatedUser(
next();
} catch (error) {
console.error('❌ Route guard error:', error);
console.error("❌ Route guard error:", error);
await useUserStore().resetAllState();
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`);
NProgress.done();