diff --git a/frontend/.env b/frontend/.env index 6b00532c..ad5ae08b 100644 --- a/frontend/.env +++ b/frontend/.env @@ -7,4 +7,8 @@ VITE_OPEN = false # public path 配置线上环境路径(打包) VITE_PUBLIC_PATH = '' -VITE_EDITOR=idea \ No newline at end of file +VITE_EDITOR=idea + +# 路由模式 +# Optional: hash | history +VITE_ROUTER_MODE = hash \ No newline at end of file diff --git a/frontend/.env.development b/frontend/.env.development index 11c5a2c1..1055f7e1 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -4,8 +4,4 @@ ENV = 'development' VITE_OPEN = true # 本地环境接口地址 -VITE_API_URL = '/api' - -# 路由模式 -# Optional: hash | history -VITE_ROUTER_MODE = hash \ No newline at end of file +VITE_API_URL = '/api' \ No newline at end of file diff --git a/frontend/.env.production b/frontend/.env.production index 06c4f3c3..62f14400 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -3,7 +3,3 @@ ENV = 'production' # 线上环境接口地址 VITE_API_URL = '/api' - -# 路由模式 -# Optional: hash | history -VITE_ROUTER_MODE = hash \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index e526826d..f827cecd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -24,7 +24,7 @@ "crypto-js": "^4.2.0", "dayjs": "^1.11.13", "echarts": "^5.6.0", - "element-plus": "^2.10.3", + "element-plus": "^2.10.4", "js-base64": "^3.7.7", "jsencrypt": "^3.3.2", "mitt": "^3.0.1", @@ -39,8 +39,8 @@ "sql-formatter": "^15.6.5", "trzsz": "^1.1.5", "uuid": "^9.0.1", - "vue": "^3.5.17", - "vue-i18n": "^11.1.9", + "vue": "^v3.6.0-alpha.2", + "vue-i18n": "^11.1.11", "vue-router": "^4.5.1", "vuedraggable": "^4.1.0" }, @@ -56,7 +56,6 @@ "@vue/compiler-sfc": "^3.5.17", "autoprefixer": "^10.4.21", "code-inspector-plugin": "^0.20.12", - "dotenv": "^16.5.0", "eslint": "^9.29.0", "eslint-plugin-vue": "^10.2.0", "postcss": "^8.5.6", diff --git a/frontend/src/common/SocketBuilder.ts b/frontend/src/common/SocketBuilder.ts deleted file mode 100644 index 63592b51..00000000 --- a/frontend/src/common/SocketBuilder.ts +++ /dev/null @@ -1,43 +0,0 @@ -class SocketBuilder { - websocket: WebSocket; - - constructor(url: string) { - if (typeof WebSocket === 'undefined') { - throw new Error('不支持websocket'); - } - if (!url) { - throw new Error('websocket url不能为空'); - } - this.websocket = new WebSocket(url); - } - - static builder(url: string) { - return new SocketBuilder(url); - } - - open(onopen: any) { - this.websocket.onopen = onopen; - return this; - } - - error(onerror: any) { - this.websocket.onerror = onerror; - return this; - } - - message(onmessage: any) { - this.websocket.onmessage = onmessage; - return this; - } - - close(onclose: any) { - this.websocket.onclose = onclose; - return this; - } - - build() { - return this.websocket; - } -} - -export default SocketBuilder; diff --git a/frontend/src/common/commonEnum.ts b/frontend/src/common/commonEnum.ts index b08b15d1..aa1c4c4a 100644 --- a/frontend/src/common/commonEnum.ts +++ b/frontend/src/common/commonEnum.ts @@ -42,3 +42,27 @@ export const TagResourceTypePath = { Db: `${TagResourceTypeEnum.DbInstance.value}/${TagResourceTypeEnum.AuthCert.value}/${TagResourceTypeEnum.Db.value}`, Es: `${TagResourceTypeEnum.EsInstance.value}/${TagResourceTypeEnum.AuthCert.value}`, }; + +// 消息子类型 +export const MsgSubtypeEnum = { + UserLogin: EnumValue.of('user.login', 'login.login').setExtra({ + notifyType: 'primary', + }), + + MachineFileUploadSuccess: EnumValue.of('machine.file.upload.success', 'machine.fileUploadSuccess').setExtra({ + notifyType: 'success', + }), + MachineFileUploadFail: EnumValue.of('machine.file.upload.fail', 'machine.fileUploadFail').setExtra({ + notifyType: 'error', + }), + + DbDumpFail: EnumValue.of('db.dump.fail', 'db.dbDumpFail').setExtra({ + notifyType: 'error', + }), + SqlScriptRunSuccess: EnumValue.of('db.sqlscript.run.success', 'db.sqlScriptRunSuccess').setExtra({ + notifyType: 'success', + }), + SqlScriptRunFail: EnumValue.of('db.sqlscript.run.fail', 'db.sqlScriptRunFail').setExtra({ + notifyType: 'error', + }), +}; diff --git a/frontend/src/common/crypto.ts b/frontend/src/common/crypto.ts index b118693d..597d26c2 100644 --- a/frontend/src/common/crypto.ts +++ b/frontend/src/common/crypto.ts @@ -1,5 +1,8 @@ import CryptoJS from 'crypto-js'; import { getToken } from '@/common/utils/storage'; +import openApi from './openApi'; +import JSEncrypt from 'jsencrypt'; +import { notBlank } from './assert'; /** * AES 加密数据 @@ -36,3 +39,36 @@ export function AesDecrypt(word: string, key?: string): string { return decrypted.toString(CryptoJS.enc.Base64); } + +var encryptor: any = null; + +export async function getRsaPublicKey() { + let publicKey = sessionStorage.getItem('RsaPublicKey'); + if (publicKey) { + return publicKey; + } + publicKey = (await openApi.getPublicKey()) as string; + sessionStorage.setItem('RsaPublicKey', publicKey); + return publicKey; +} + +/** + * 公钥加密指定值 + * + * @param value value + * @returns 加密后的值 + */ +export async function RsaEncrypt(value: any) { + // 不存在则返回空值 + if (!value) { + return ''; + } + if (encryptor != null && sessionStorage.getItem('RsaPublicKey') != null) { + return encryptor.encrypt(value); + } + encryptor = new JSEncrypt(); + const publicKey = (await getRsaPublicKey()) as string; + notBlank(publicKey, '获取公钥失败'); + encryptor.setPublicKey(publicKey); //设置公钥 + return encryptor.encrypt(value); +} diff --git a/frontend/src/common/request.ts b/frontend/src/common/request.ts index a18fe704..a3126246 100755 --- a/frontend/src/common/request.ts +++ b/frontend/src/common/request.ts @@ -204,6 +204,24 @@ function getApiUrl(url: string) { return baseUrl + url + '?' + joinClientParams(); } +/** + * 创建 websocket + */ +export const createWebSocket = (url: string): Promise => { + return new Promise((resolve, reject) => { + const clientParam = (url.includes('?') ? '&' : '?') + joinClientParams(); + const socket = new WebSocket(`${config.baseWsUrl}${url}${clientParam}`); + + socket.onopen = () => { + resolve(socket); + }; + + socket.onerror = (e) => { + reject(e); + }; + }); +}; + // 组装客户端参数,包括 token 和 clientId export function joinClientParams(): string { return `token=${getToken()}&clientId=${getClientId()}`; diff --git a/frontend/src/common/rsa.ts b/frontend/src/common/rsa.ts deleted file mode 100644 index fc41dd39..00000000 --- a/frontend/src/common/rsa.ts +++ /dev/null @@ -1,36 +0,0 @@ -import openApi from './openApi'; -import JSEncrypt from 'jsencrypt'; -import { notBlank } from './assert'; - -var encryptor: any = null; - -export async function getRsaPublicKey() { - let publicKey = sessionStorage.getItem('RsaPublicKey'); - if (publicKey) { - return publicKey; - } - publicKey = (await openApi.getPublicKey()) as string; - sessionStorage.setItem('RsaPublicKey', publicKey); - return publicKey; -} - -/** - * 公钥加密指定值 - * - * @param value value - * @returns 加密后的值 - */ -export async function RsaEncrypt(value: any) { - // 不存在则返回空值 - if (!value) { - return ''; - } - if (encryptor != null && sessionStorage.getItem('RsaPublicKey') != null) { - return encryptor.encrypt(value); - } - encryptor = new JSEncrypt(); - const publicKey = (await getRsaPublicKey()) as string; - notBlank(publicKey, '获取公钥失败'); - encryptor.setPublicKey(publicKey); //设置公钥 - return encryptor.encrypt(value); -} diff --git a/frontend/src/common/sysmsgs.ts b/frontend/src/common/sysmsgs.ts index 009b81b6..2e04dcbd 100644 --- a/frontend/src/common/sysmsgs.ts +++ b/frontend/src/common/sysmsgs.ts @@ -4,15 +4,15 @@ import { h, reactive } from 'vue'; import { ElNotification } from 'element-plus'; import ProgressNotify from '@/components/progress-notify/progress-notify.vue'; -export function initSysMsgs() { - registerDbSqlExecProgress(); +export async function initSysMsgs() { + await registerDbSqlExecProgress(); } const sqlExecNotifyMap: Map = new Map(); -function registerDbSqlExecProgress() { - syssocket.registerMsgHandler('execSqlFileProgress', function (message: any) { - const content = JSON.parse(message.msg); +async function registerDbSqlExecProgress() { + await syssocket.registerMsgHandler('sqlScriptRunProgress', function (message: any) { + const content = message.params; const id = content.id; let progress = sqlExecNotifyMap.get(id); if (content.terminated) { @@ -38,7 +38,7 @@ function registerDbSqlExecProgress() { duration: 0, title: message.title, message: h(ProgressNotify, progress.props), - type: syssocket.getMsgType(message.type), + type: 'info', showClose: false, }); sqlExecNotifyMap.set(id, progress); diff --git a/frontend/src/common/syssocket.ts b/frontend/src/common/syssocket.ts index e7b6148c..c29f0b7d 100644 --- a/frontend/src/common/syssocket.ts +++ b/frontend/src/common/syssocket.ts @@ -1,34 +1,25 @@ -import Config from './config'; -import SocketBuilder from './SocketBuilder'; import { getToken } from '@/common/utils/storage'; -import { joinClientParams } from './request'; +import { createWebSocket } from './request'; import { ElNotification } from 'element-plus'; +import { MsgSubtypeEnum } from './commonEnum'; +import EnumValue from './Enum'; class SysSocket { /** * socket连接 */ - socket: any; + socket: WebSocket | null = null; /** * key -> 消息类别,value -> 消息对应的处理器函数 */ categoryHandlers: Map = new Map(); - /** - * 消息类型 - */ - messageTypes: any = { - 0: 'error', - 1: 'success', - 2: 'info', - }; - /** * 初始化全局系统消息websocket */ - init() { + async init() { // 存在则不需要重新建立连接 if (this.socket) { return; @@ -38,9 +29,9 @@ class SysSocket { return null; } console.log('init system ws'); - const sysMsgUrl = `${Config.baseWsUrl}/sysmsg?${joinClientParams()}`; - this.socket = SocketBuilder.builder(sysMsgUrl) - .message((event: { data: string }) => { + try { + this.socket = await createWebSocket('/sysmsg'); + this.socket.onmessage = async (event: { data: string }) => { let message; try { message = JSON.parse(event.data); @@ -56,23 +47,32 @@ class SysSocket { return; } - // 默认通知处理 - const type = this.getMsgType(message.type); - let msg = message.msg; - let duration = 0; + const msgSubtype = EnumValue.getEnumByValue(MsgSubtypeEnum, message.subtype); + if (!msgSubtype) { + console.log(`not found msg subtype: ${message.subtype}`); + return; + } + + // 动态导入 i18n 或延迟获取 i18n 实例 + let title = ''; + try { + // 方式1: 动态导入 + const { i18n } = await import('@/i18n'); + title = i18n.global.t(msgSubtype?.label); + } catch (e) { + console.warn('i18n not ready, using default title'); + } + ElNotification({ - duration: duration, - title: message.title, - message: msg, - type: type, + duration: 0, + title, + message: message.msg, + type: msgSubtype?.extra.notifyType || 'info', }); - }) - .open((event: any) => console.log(event)) - .close(() => { - console.log('close sys socket'); - this.socket = null; - }) - .build(); + }; + } catch (e) { + console.error('open system ws error', e); + } } destory() { @@ -87,8 +87,7 @@ class SysSocket { * @param category 消息类别 * @param handlerFunc 消息处理函数 */ - registerMsgHandler(category: any, handlerFunc: any) { - this.init(); + async registerMsgHandler(category: any, handlerFunc: any) { if (this.categoryHandlers.has(category)) { console.log(`${category}该类别消息处理器已存在...`); return; @@ -98,10 +97,6 @@ class SysSocket { } this.categoryHandlers.set(category, handlerFunc); } - - getMsgType(msgType: any) { - return this.messageTypes[msgType]; - } } // 全局系统消息websocket; diff --git a/frontend/src/common/utils/toolsValidate.ts b/frontend/src/common/utils/toolsValidate.ts deleted file mode 100644 index b0e26184..00000000 --- a/frontend/src/common/utils/toolsValidate.ts +++ /dev/null @@ -1,241 +0,0 @@ -/** - * 2020.11.29 lyt 整理 - * 工具类集合,适用于平时开发 - */ - -// 小数或整数(不可以负数) -export function verifyNumberIntegerAndFloat(val: string) { - // 匹配空格 - let v = val.replace(/(^\s*)|(\s*$)/g, ''); - // 只能是数字和小数点,不能是其他输入 - v = v.replace(/[^\d.]/g, ''); - // 以0开始只能输入一个 - v = v.replace(/^0{2}$/g, '0'); - // 保证第一位只能是数字,不能是点 - v = v.replace(/^\./g, ''); - // 小数只能出现1位 - v = v.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); - // 小数点后面保留2位 - v = v.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); - // 返回结果 - return v; -} - -// 正整数验证 -export function verifiyNumberInteger(val: string) { - // 匹配空格 - let v = val.replace(/(^\s*)|(\s*$)/g, ''); - // 去掉 '.' , 防止贴贴的时候出现问题 如 0.1.12.12 - v = v.replace(/[\.]*/g, ''); - // 去掉以 0 开始后面的数, 防止贴贴的时候出现问题 如 00121323 - v = v.replace(/(^0[\d]*)$/g, '0'); - // 首位是0,只能出现一次 - v = v.replace(/^0\d$/g, '0'); - // 只匹配数字 - v = v.replace(/[^\d]/g, ''); - // 返回结果 - return v; -} - -// 去掉中文及空格 -export function verifyCnAndSpace(val: string) { - // 匹配中文与空格 - let v = val.replace(/[\u4e00-\u9fa5\s]+/g, ''); - // 匹配空格 - v = v.replace(/(^\s*)|(\s*$)/g, ''); - // 返回结果 - return v; -} - -// 去掉英文及空格 -export function verifyEnAndSpace(val: string) { - // 匹配英文与空格 - let v = val.replace(/[a-zA-Z]+/g, ''); - // 匹配空格 - v = v.replace(/(^\s*)|(\s*$)/g, ''); - // 返回结果 - return v; -} - -// 禁止输入空格 -export function verifyAndSpace(val: string) { - // 匹配空格 - let v = val.replace(/(^\s*)|(\s*$)/g, ''); - // 返回结果 - return v; -} - -// 金额用 `,` 区分开 -export function verifyNumberComma(val: string) { - // 调用小数或整数(不可以负数)方法 - let v: any = verifyNumberIntegerAndFloat(val); - // 字符串转成数组 - v = v.toString().split('.'); - // \B 匹配非单词边界,两边都是单词字符或者两边都是非单词字符 - v[0] = v[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); - // 数组转字符串 - v = v.join('.'); - // 返回结果 - return v; -} - -// 匹配文字变色(搜索时) -export function verifyTextColor(val: string, text = '', color = 'red') { - // 返回内容,添加颜色 - let v = text.replace(new RegExp(val, 'gi'), `${val}`); - // 返回结果 - return v; -} - -// 数字转中文大写 -export function verifyNumberCnUppercase(val: any, unit = '仟佰拾亿仟佰拾万仟佰拾元角分', v = '') { - // 当前内容字符串添加 2个0,为什么?? - val += '00'; - // 返回某个指定的字符串值在字符串中首次出现的位置,没有出现,则该方法返回 -1 - let lookup = val.indexOf('.'); - // substring:不包含结束下标内容,substr:包含结束下标内容 - if (lookup >= 0) val = val.substring(0, lookup) + val.substr(lookup + 1, 2); - // 根据内容 val 的长度,截取返回对应大写 - unit = unit.substr(unit.length - val.length); - // 循环截取拼接大写 - for (let i = 0; i < val.length; i++) { - v += '零壹贰叁肆伍陆柒捌玖'.substr(val.substr(i, 1), 1) + unit.substr(i, 1); - } - // 正则处理 - v = v - .replace(/零角零分$/, '整') - .replace(/零[仟佰拾]/g, '零') - .replace(/零{2,}/g, '零') - .replace(/零([亿|万])/g, '$1') - .replace(/零+元/, '元') - .replace(/亿零{0,3}万/, '亿') - .replace(/^元/, '零元'); - // 返回结果 - return v; -} - -// 手机号码 -export function verifyPhone(val: string) { - // false: 手机号码不正确 - if (!/^((12[0-9])|(13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$/.test(val)) return false; - // true: 手机号码正确 - else return true; -} - -// 国内电话号码 -export function verifyTelPhone(val: string) { - // false: 国内电话号码不正确 - if (!/\d{3}-\d{8}|\d{4}-\d{7}/.test(val)) return false; - // true: 国内电话号码正确 - else return true; -} - -// 登录账号 (字母开头,允许5-16字节,允许字母数字下划线) -export function verifyAccount(val: string) { - // false: 登录账号不正确 - if (!/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/.test(val)) return false; - // true: 登录账号正确 - else return true; -} - -// 密码 (以字母开头,长度在6~16之间,只能包含字母、数字和下划线) -export function verifyPassword(val: string) { - // false: 密码不正确 - if (!/^[a-zA-Z]\w{5,15}$/.test(val)) return false; - // true: 密码正确 - else return true; -} - -// 强密码 (字母+数字+特殊字符,长度在6-16之间) -export function verifyPasswordPowerful(val: string) { - // false: 强密码不正确 - if (!/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) - return false; - // true: 强密码正确 - else return true; -} - -// 密码强度 -export function verifyPasswordStrength(val: string) { - let v = ''; - // 弱:纯数字,纯字母,纯特殊字符 - if (/^(?:\d+|[a-zA-Z]+|[!@#$%^&\.*]+){6,16}$/.test(val)) v = '弱'; - // 中:字母+数字,字母+特殊字符,数字+特殊字符 - if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) v = '中'; - // 强:字母+数字+特殊字符 - if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) v = '强'; - // 返回结果 - return v; -} - -// IP地址 -export function verifyIPAddress(val: string) { - // false: IP地址不正确 - if (!/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(val)) - return false; - // true: IP地址正确 - else return true; -} - -// 邮箱 -export function verifyEmail(val: string) { - // false: 邮箱不正确 - if ( - !/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( - val - ) - ) - return false; - // true: 邮箱正确 - else return true; -} - -// 身份证 -export function verifyIdCard(val: string) { - // false: 身份证不正确 - if (!/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(val)) return false; - // true: 身份证正确 - else return true; -} - -// 姓名 -export function verifyFullName(val: string) { - // false: 姓名不正确 - if (!/^[\u4e00-\u9fa5]{1,6}(·[\u4e00-\u9fa5]{1,6}){0,2}$/.test(val)) return false; - // true: 姓名正确 - else return true; -} - -// 邮政编码 -export function verifyPostalCode(val: string) { - // false: 邮政编码不正确 - if (!/^[1-9][0-9]{5}$/.test(val)) return false; - // true: 邮政编码正确 - else return true; -} - -// url -export function verifyUrl(val: string) { - // false: url不正确 - if ( - !/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( - val - ) - ) - return false; - // true: url正确 - else return true; -} - -// 车牌号 -export function verifyCarNum(val: string) { - // false: 车牌号不正确 - if ( - !/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/.test( - val - ) - ) - return false; - // true:车牌号正确 - else return true; -} diff --git a/frontend/src/common/utils/url.ts b/frontend/src/common/utils/url.ts deleted file mode 100644 index a3836d79..00000000 --- a/frontend/src/common/utils/url.ts +++ /dev/null @@ -1,13 +0,0 @@ -const mode = import.meta.env.VITE_ROUTER_MODE; - -/** - * @description 获取不同路由模式所对应的 url - * @returns {String} - */ -export function getNowUrl() { - const url = { - hash: location.hash.substring(1), - history: location.pathname + location.search, - }; - return url[mode]; -} diff --git a/frontend/src/common/utils/viteBuild.ts b/frontend/src/common/utils/viteBuild.ts deleted file mode 100644 index 3209d952..00000000 --- a/frontend/src/common/utils/viteBuild.ts +++ /dev/null @@ -1,27 +0,0 @@ -// vite 打包相关 -import dotenv from 'dotenv'; -export interface ViteEnv { - VITE_PORT: number; - VITE_OPEN: boolean; - VITE_PUBLIC_PATH: string; - VITE_EDITOR: string; -} - -export function loadEnv(): ViteEnv { - const env = process.env.NODE_ENV; - const ret: any = {}; - const envList = [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env', ,]; - envList.forEach((e) => { - dotenv.config({ path: e }); - }); - for (const envName of Object.keys(process.env)) { - console.log(envName); - let realName = (process.env as any)[envName].replace(/\\n/g, '\n'); - realName = realName === 'true' ? true : realName === 'false' ? false : realName; - if (envName === 'VITE_PORT') realName = Number(realName); - if (envName === 'VITE_OPEN') realName = Boolean(realName); - ret[envName] = realName; - process.env[envName] = realName; - } - return ret; -} diff --git a/frontend/src/components/pagetable/PageTable.vue b/frontend/src/components/pagetable/PageTable.vue index d4cc660b..470e744a 100644 --- a/frontend/src/components/pagetable/PageTable.vue +++ b/frontend/src/components/pagetable/PageTable.vue @@ -21,7 +21,7 @@
- + - + diff --git a/frontend/src/store/tagsViews.ts b/frontend/src/store/tagsViews.ts index 10a64498..574f2622 100644 --- a/frontend/src/store/tagsViews.ts +++ b/frontend/src/store/tagsViews.ts @@ -1,4 +1,3 @@ -import { getNowUrl } from '@/common/utils/url'; import { defineStore } from 'pinia'; /** @@ -12,14 +11,5 @@ export const useTagsViews = defineStore('tagsViews', { setTagsViews(data: Array) { this.tagsViews = data; }, - // 设置当前页面的tags view title - setNowTitle(title: string) { - this.tagsViews.forEach((item) => { - // console.log(getNowUrl(), item.path); - if (item.path == getNowUrl()) { - item.title = title; - } - }); - }, }, }); diff --git a/frontend/src/views/home/Home.vue b/frontend/src/views/home/Home.vue index 7a604ecf..edfdadf2 100644 --- a/frontend/src/views/home/Home.vue +++ b/frontend/src/views/home/Home.vue @@ -2,7 +2,7 @@
- +
@@ -52,23 +52,6 @@
- - - - - - - - @@ -236,39 +219,11 @@ - - - - - - - - - - - - - - -