update 优化 代码写法 删除无用依赖

This commit is contained in:
疯狂的狮子Li 2026-03-16 19:20:22 +08:00
parent e3227f5cc5
commit b83755e626
16 changed files with 51 additions and 61 deletions

View File

@ -30,14 +30,11 @@
"crypto-js": "4.2.0", "crypto-js": "4.2.0",
"echarts": "6.0.0", "echarts": "6.0.0",
"element-plus": "2.13.5", "element-plus": "2.13.5",
"file-saver": "2.0.5",
"highlight.js": "11.11.1", "highlight.js": "11.11.1",
"image-conversion": "2.1.1", "image-conversion": "2.1.1",
"js-cookie": "3.0.5",
"jsencrypt": "3.5.4", "jsencrypt": "3.5.4",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"pinia": "3.0.4", "pinia": "3.0.4",
"screenfull": "6.0.2",
"vue": "3.5.30", "vue": "3.5.30",
"vue-cropper": "1.1.4", "vue-cropper": "1.1.4",
"vue-i18n": "11.3.0", "vue-i18n": "11.3.0",
@ -47,15 +44,11 @@
"vxe-table": "4.18.1" "vxe-table": "4.18.1"
}, },
"devDependencies": { "devDependencies": {
"@iconify/json": "^2.2.448",
"@types/crypto-js": "4.2.2", "@types/crypto-js": "4.2.2",
"@types/file-saver": "2.0.7",
"@types/js-cookie": "3.0.6",
"@types/node": "^25.4.0", "@types/node": "^25.4.0",
"@types/nprogress": "0.2.3", "@types/nprogress": "0.2.3",
"@unocss/preset-attributify": "66.6.6", "@unocss/preset-attributify": "66.6.6",
"@unocss/preset-icons": "66.6.6", "@unocss/preset-wind3": "66.6.6",
"@unocss/preset-uno": "66.6.6",
"@vitejs/plugin-vue": "6.0.4", "@vitejs/plugin-vue": "6.0.4",
"@vue/compiler-sfc": "3.5.30", "@vue/compiler-sfc": "3.5.30",
"@vue/eslint-config-prettier": "10.2.0", "@vue/eslint-config-prettier": "10.2.0",
@ -70,7 +63,6 @@
"typescript": "~5.9.3", "typescript": "~5.9.3",
"unocss": "66.6.6", "unocss": "66.6.6",
"unplugin-auto-import": "21.0.0", "unplugin-auto-import": "21.0.0",
"unplugin-icons": "23.0.1",
"unplugin-vue-components": "31.0.0", "unplugin-vue-components": "31.0.0",
"unplugin-vue-setup-extend-plus": "1.0.1", "unplugin-vue-setup-extend-plus": "1.0.1",
"vite": "7.3.1", "vite": "7.3.1",

View File

@ -9,8 +9,8 @@
<el-popover shadow="none" :visible="visible" placement="bottom-end" trigger="click" :width="450"> <el-popover shadow="none" :visible="visible" placement="bottom-end" trigger="click" :width="450">
<template #reference> <template #reference>
<div class="cursor-pointer text-[#999] absolute right-[10px] top-0 height-[32px] leading-[32px]" @click="visible = !visible"> <div class="cursor-pointer text-[#999] absolute right-[10px] top-0 height-[32px] leading-[32px]" @click="visible = !visible">
<i-ep-caret-top v-show="visible"></i-ep-caret-top> <CaretTop v-show="visible" />
<i-ep-caret-bottom v-show="!visible"></i-ep-caret-bottom> <CaretBottom v-show="!visible" />
</div> </div>
</template> </template>

View File

@ -85,7 +85,7 @@ import { useSettingsStore } from '@/store/modules/settings';
import { useNoticeStore } from '@/store/modules/notice'; import { useNoticeStore } from '@/store/modules/notice';
import notice from './notice/index.vue'; import notice from './notice/index.vue';
import router from '@/router'; import router from '@/router';
import { ElMessageBoxOptions } from 'element-plus/es/components/message-box/src/message-box.type'; import type { ElMessageBoxOptions } from 'element-plus';
import { NavTypeEnum } from '@/enums/NavTypeEnum'; import { NavTypeEnum } from '@/enums/NavTypeEnum';
import Logo from "@/layout/components/Sidebar/Logo.vue"; import Logo from "@/layout/components/Sidebar/Logo.vue";
import TopBar from './TopBar/index.vue'; import TopBar from './TopBar/index.vue';

View File

@ -1,6 +1,6 @@
import { to as tos } from 'await-to-js'; import { to as tos } from 'await-to-js';
import router from './router'; import router from './router';
import NProgress from 'nprogress'; import * as NProgressModule from 'nprogress';
import 'nprogress/nprogress.css'; import 'nprogress/nprogress.css';
import { getToken } from '@/utils/auth'; import { getToken } from '@/utils/auth';
import { isHttp, isPathMatch } from '@/utils/validate'; import { isHttp, isPathMatch } from '@/utils/validate';
@ -10,6 +10,8 @@ import { useSettingsStore } from '@/store/modules/settings';
import { usePermissionStore } from '@/store/modules/permission'; import { usePermissionStore } from '@/store/modules/permission';
import { ElMessage } from 'element-plus/es'; import { ElMessage } from 'element-plus/es';
const NProgress = ('default' in NProgressModule ? NProgressModule.default : NProgressModule) as typeof NProgressModule;
NProgress.configure({ showSpinner: false }); NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/register', '/social-callback', '/register*', '/register/*']; const whiteList = ['/login', '/register', '/social-callback', '/register*', '/register/*'];

View File

@ -1,12 +1,12 @@
import axios from 'axios'; import axios from 'axios';
import FileSaver from 'file-saver';
import errorCode from '@/utils/errorCode'; import errorCode from '@/utils/errorCode';
import { blobValidate } from '@/utils/ruoyi'; import { blobValidate } from '@/utils/ruoyi';
import { LoadingInstance } from 'element-plus/es/components/loading/src/loading';
import { globalHeaders } from '@/utils/request'; import { globalHeaders } from '@/utils/request';
import { saveBlob } from '@/utils/save';
import type { LoadingInstance } from 'element-plus';
const baseURL = import.meta.env.VITE_APP_BASE_API; const baseURL = import.meta.env.VITE_APP_BASE_API;
let downloadLoadingInstance: LoadingInstance; let downloadLoadingInstance: LoadingInstance | undefined;
export default { export default {
async oss(ossId: string | number) { async oss(ossId: string | number) {
const url = baseURL + '/resource/oss/download/' + ossId; const url = baseURL + '/resource/oss/download/' + ossId;
@ -21,15 +21,15 @@ export default {
const isBlob = blobValidate(res.data); const isBlob = blobValidate(res.data);
if (isBlob) { if (isBlob) {
const blob = new Blob([res.data], { type: 'application/octet-stream' }); const blob = new Blob([res.data], { type: 'application/octet-stream' });
FileSaver.saveAs(blob, decodeURIComponent(res.headers['download-filename'] as string)); saveBlob(blob, decodeURIComponent(res.headers['download-filename'] as string));
} else { } else {
this.printErrMsg(res.data); this.printErrMsg(res.data);
} }
downloadLoadingInstance.close(); downloadLoadingInstance?.close();
} catch (r) { } catch (r) {
console.error(r); console.error(r);
ElMessage.error('下载文件出现错误,请联系管理员!'); ElMessage.error('下载文件出现错误,请联系管理员!');
downloadLoadingInstance.close(); downloadLoadingInstance?.close();
} }
}, },
async zip(url: string, name: string) { async zip(url: string, name: string) {
@ -45,15 +45,15 @@ export default {
const isBlob = blobValidate(res.data); const isBlob = blobValidate(res.data);
if (isBlob) { if (isBlob) {
const blob = new Blob([res.data], { type: 'application/zip' }); const blob = new Blob([res.data], { type: 'application/zip' });
FileSaver.saveAs(blob, name); saveBlob(blob, name);
} else { } else {
this.printErrMsg(res.data); this.printErrMsg(res.data);
} }
downloadLoadingInstance.close(); downloadLoadingInstance?.close();
} catch (r) { } catch (r) {
console.error(r); console.error(r);
ElMessage.error('下载文件出现错误,请联系管理员!'); ElMessage.error('下载文件出现错误,请联系管理员!');
downloadLoadingInstance.close(); downloadLoadingInstance?.close();
} }
}, },
async printErrMsg(data: any) { async printErrMsg(data: any) {

View File

@ -1,6 +1,6 @@
import { MessageBoxData } from 'element-plus'; import type { LoadingInstance, MessageBoxData } from 'element-plus';
import { LoadingInstance } from 'element-plus/es/components/loading/src/loading';
let loadingInstance: LoadingInstance; let loadingInstance: LoadingInstance | undefined;
export default { export default {
// 消息提示 // 消息提示
msg(content: any) { msg(content: any) {
@ -76,6 +76,6 @@ export default {
}, },
// 关闭遮罩层 // 关闭遮罩层
closeLoading() { closeLoading() {
loadingInstance.close(); loadingInstance?.close();
} }
}; };

View File

@ -1,4 +1,6 @@
import CryptoJS from 'crypto-js'; import * as CryptoJSModule from 'crypto-js';
const CryptoJS = ('default' in CryptoJSModule ? CryptoJSModule.default : CryptoJSModule) as typeof CryptoJSModule;
/** /**
* 32 * 32
@ -26,7 +28,7 @@ export const generateAesKey = () => {
* base64 * base64
* @returns {string} * @returns {string}
*/ */
export const encryptBase64 = (str: CryptoJS.lib.WordArray) => { export const encryptBase64 = (str: CryptoJSModule.lib.WordArray) => {
return CryptoJS.enc.Base64.stringify(str); return CryptoJS.enc.Base64.stringify(str);
}; };
@ -43,7 +45,7 @@ export const decryptBase64 = (str: string) => {
* @param aesKey * @param aesKey
* @returns {string} * @returns {string}
*/ */
export const encryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray) => { export const encryptWithAes = (message: string, aesKey: CryptoJSModule.lib.WordArray) => {
const encrypted = CryptoJS.AES.encrypt(message, aesKey, { const encrypted = CryptoJS.AES.encrypt(message, aesKey, {
mode: CryptoJS.mode.ECB, mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7 padding: CryptoJS.pad.Pkcs7
@ -57,7 +59,7 @@ export const encryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray)
* @param aesKey * @param aesKey
* @returns {string} * @returns {string}
*/ */
export const decryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray) => { export const decryptWithAes = (message: string, aesKey: CryptoJSModule.lib.WordArray) => {
const decrypted = CryptoJS.AES.decrypt(message, aesKey, { const decrypted = CryptoJS.AES.decrypt(message, aesKey, {
mode: CryptoJS.mode.ECB, mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7 padding: CryptoJS.pad.Pkcs7

View File

@ -1,4 +1,4 @@
import JSEncrypt from 'jsencrypt'; import { JSEncrypt } from 'jsencrypt';
// 密钥对生成 http://web.chacuo.net/netrsakeypair // 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey = import.meta.env.VITE_APP_RSA_PUBLIC_KEY; const publicKey = import.meta.env.VITE_APP_RSA_PUBLIC_KEY;

View File

@ -5,15 +5,15 @@ import { tansParams, blobValidate } from '@/utils/ruoyi';
import cache from '@/plugins/cache'; import cache from '@/plugins/cache';
import { HttpStatus } from '@/enums/RespEnum'; import { HttpStatus } from '@/enums/RespEnum';
import { errorCode } from '@/utils/errorCode'; import { errorCode } from '@/utils/errorCode';
import { LoadingInstance } from 'element-plus/es/components/loading/src/loading';
import FileSaver from 'file-saver';
import { getLanguage } from '@/lang'; import { getLanguage } from '@/lang';
import { encryptBase64, encryptWithAes, generateAesKey, decryptWithAes, decryptBase64 } from '@/utils/crypto'; import { encryptBase64, encryptWithAes, generateAesKey, decryptWithAes, decryptBase64 } from '@/utils/crypto';
import { encrypt, decrypt } from '@/utils/jsencrypt'; import { encrypt, decrypt } from '@/utils/jsencrypt';
import router from '@/router'; import router from '@/router';
import { saveBlob } from '@/utils/save';
import type { LoadingInstance } from 'element-plus';
const encryptHeader = 'encrypt-key'; const encryptHeader = 'encrypt-key';
let downloadLoadingInstance: LoadingInstance; let downloadLoadingInstance: LoadingInstance | undefined;
// 是否显示重新登录 // 是否显示重新登录
export const isRelogin = { show: false }; export const isRelogin = { show: false };
export const globalHeaders = () => { export const globalHeaders = () => {
@ -193,7 +193,7 @@ export function download(url: string, params: any, fileName: string) {
const isLogin = blobValidate(resp); const isLogin = blobValidate(resp);
if (isLogin) { if (isLogin) {
const blob = new Blob([resp]); const blob = new Blob([resp]);
FileSaver.saveAs(blob, fileName); saveBlob(blob, fileName);
} else { } else {
const blob = new Blob([resp]); const blob = new Blob([resp]);
const resText = await blob.text(); const resText = await blob.text();
@ -201,11 +201,11 @@ export function download(url: string, params: any, fileName: string) {
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']; const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'];
ElMessage.error(errMsg); ElMessage.error(errMsg);
} }
downloadLoadingInstance.close(); downloadLoadingInstance?.close();
}).catch((r: any) => { }).catch((r: any) => {
console.error(r); console.error(r);
ElMessage.error('下载文件出现错误,请联系管理员!'); ElMessage.error('下载文件出现错误,请联系管理员!');
downloadLoadingInstance.close(); downloadLoadingInstance?.close();
}); });
} }
// 导出 axios 实例 // 导出 axios 实例

13
src/utils/save.ts Normal file
View File

@ -0,0 +1,13 @@
export function saveBlob(blob: Blob, fileName: string) {
const downloadLink = document.createElement('a');
const objectUrl = URL.createObjectURL(blob);
downloadLink.href = objectUrl;
downloadLink.download = fileName;
downloadLink.rel = 'noopener';
downloadLink.click();
setTimeout(() => {
URL.revokeObjectURL(objectUrl);
}, 40_000);
}

View File

@ -267,7 +267,7 @@
drag drag
> >
<el-icon class="el-icon--upload"> <el-icon class="el-icon--upload">
<i-ep-upload-filled /> <UploadFilled />
</el-icon> </el-icon>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<template #tip> <template #tip>

View File

@ -211,8 +211,7 @@ import { listDefinition, deleteDefinition, active, importDef, unPublishList, pub
import { categoryTree } from '@/api/workflow/category'; import { categoryTree } from '@/api/workflow/category';
import { CategoryTreeVO } from '@/api/workflow/category/types'; import { CategoryTreeVO } from '@/api/workflow/category/types';
import { FlowDefinitionQuery, FlowDefinitionVo, FlowDefinitionForm } from '@/api/workflow/definition/types'; import { FlowDefinitionQuery, FlowDefinitionVo, FlowDefinitionForm } from '@/api/workflow/definition/types';
import { UploadRequestOptions, TabsPaneContext } from 'element-plus'; import type { ElMessageBoxOptions, TabsPaneContext, UploadRequestOptions } from 'element-plus';
import { ElMessageBoxOptions } from 'element-plus/es/components/message-box/src/message-box.type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;

View File

@ -1,9 +1,8 @@
import { import {
defineConfig, defineConfig,
presetAttributify, presetAttributify,
presetIcons, presetWind3,
presetTypography, presetTypography,
presetUno,
presetWebFonts, presetWebFonts,
transformerDirectives, transformerDirectives,
transformerVariantGroup transformerVariantGroup
@ -21,9 +20,8 @@ export default defineConfig({
} }
}, },
presets: [ presets: [
presetUno(), presetWind3(),
presetAttributify(), presetAttributify(),
presetIcons(),
presetTypography(), presetTypography(),
presetWebFonts({ presetWebFonts({
fonts: {} fonts: {}

View File

@ -1,16 +1,11 @@
import Components from 'unplugin-vue-components/vite'; import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import IconsResolver from 'unplugin-icons/resolver';
export default (path: any) => { export default (path: any) => {
return Components({ return Components({
resolvers: [ resolvers: [
// 自动导入 Element Plus 组件 // 自动导入 Element Plus 组件
ElementPlusResolver(), ElementPlusResolver()
// 自动注册图标组件
IconsResolver({
enabledCollections: ['ep']
})
], ],
dts: path.resolve(path.resolve(__dirname, '../../src'), 'types', 'components.d.ts') dts: path.resolve(path.resolve(__dirname, '../../src'), 'types', 'components.d.ts')
}); });

View File

@ -1,9 +0,0 @@
import Icons from 'unplugin-icons/vite';
export default () => {
return Icons({
// 自动安装图标库
autoInstall: true,
compiler: "vue3"
});
};

View File

@ -4,7 +4,6 @@ import vueDevTools from 'vite-plugin-vue-devtools';
import createUnoCss from './unocss'; import createUnoCss from './unocss';
import createAutoImport from './auto-import'; import createAutoImport from './auto-import';
import createComponents from './components'; import createComponents from './components';
import createIcons from './icons';
import createSvgIconsPlugin from './svg-icon'; import createSvgIconsPlugin from './svg-icon';
import createCompression from './compression'; import createCompression from './compression';
import createSetupExtend from './setup-extend'; import createSetupExtend from './setup-extend';
@ -18,7 +17,6 @@ export default (viteEnv: any, isBuild = false): [] => {
vitePlugins.push(createAutoImport(path)); vitePlugins.push(createAutoImport(path));
vitePlugins.push(createComponents(path)); vitePlugins.push(createComponents(path));
vitePlugins.push(createCompression(viteEnv)); vitePlugins.push(createCompression(viteEnv));
vitePlugins.push(createIcons());
vitePlugins.push(createSvgIconsPlugin(path)); vitePlugins.push(createSvgIconsPlugin(path));
vitePlugins.push(createSetupExtend()); vitePlugins.push(createSetupExtend());
return vitePlugins; return vitePlugins;