From 3d8478739af4c54a6b4e2555bdb9b59c27e65320 Mon Sep 17 00:00:00 2001 From: AaronWu <2463371514@qq.com> Date: Mon, 21 Jul 2025 13:46:39 +0800 Subject: [PATCH] feat: bug fix commit --- .env | 2 +- .env.development | 7 +--- .env.production | 6 +-- src/utils/request.ts | 9 ++--- src/views/login/index.vue | 40 ++++++++++++++++++-- src/views/question/issue/index.vue | 4 +- src/views/question/knowledge/formSchemas.tsx | 32 +++++++++++++++- src/views/system/user/formSchemas.ts | 5 ++- vite.config.ts | 6 +-- 9 files changed, 84 insertions(+), 27 deletions(-) diff --git a/.env b/.env index 29a7617..625bf07 100644 --- a/.env +++ b/.env @@ -5,7 +5,7 @@ ENV = 'production' VITE_BASE_URL = / # base api -VITE_BASE_API = '/api/admin/' +VITE_BASE_API = '/server/' VITE_BASE_SOCKET_PATH = '/ws-api' VITE_BASE_SOCKET_NSP = '/admin' diff --git a/.env.development b/.env.development index cd490ae..f6ae544 100644 --- a/.env.development +++ b/.env.development @@ -2,16 +2,13 @@ # @Author: AaronWu 2463371514@qq.com # @Date: 2025-03-31 15:12:17 # @LastEditors: AaronWu 2463371514@qq.com - # @LastEditTime: 2025-07-07 11:36:29 + # @LastEditTime: 2025-07-08 11:33:47 # @FilePath: /IssueSupportManage/.env.development # @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE ### # 只在开发模式中被载入 -# 网站前缀 -# VITE_BASE_API_URL = http://192.168.2.64:8089/server/ -# VITE_BASE_API_URL = http://43.137.2.78:8085/server/ -VITE_BASE_API_URL = /server/ + # base api VITE_BASE_API = '/server/' diff --git a/.env.production b/.env.production index 6a058fa..687d667 100644 --- a/.env.production +++ b/.env.production @@ -2,15 +2,13 @@ # @Author: AaronWu 2463371514@qq.com # @Date: 2025-03-31 15:12:17 # @LastEditors: AaronWu 2463371514@qq.com - # @LastEditTime: 2025-07-07 11:52:04 + # @LastEditTime: 2025-07-08 11:14:20 # @FilePath: /IssueSupportManage/.env.production # @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE ### # 只在生产模式中被载入 -# 网站前缀 -# VITE_BASE_API_URL = http://question.supsub.cn:8085/server/ -VITE_BASE_API_URL = /server/ + # base api VITE_BASE_API = '/server/' diff --git a/src/utils/request.ts b/src/utils/request.ts index 0102a56..ec75231 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -22,7 +22,7 @@ export interface RequestOptions { const UNKNOWN_ERROR = '未知错误,请重试'; /** 真实请求的路径前缀 */ -const baseApiUrl = import.meta.env.VITE_BASE_API_URL; +const baseApiUrl = import.meta.env.VITE_BASE_API; console.log('baseApiUrl: ', baseApiUrl); /** mock请求路径前缀 */ const baseMockUrl = import.meta.env.VITE_MOCK_API; @@ -54,7 +54,6 @@ service.interceptors.response.use( const res = response.data; // if the custom code is not 200, it is judged as an error. if (res.code !== 200) { - // Illegal token if (res.code === 401 || res.code === 402 || res.code === 501) { // to re-login @@ -68,11 +67,10 @@ service.interceptors.response.use( window.location.reload(); }, }); - return + return; } $message.error(res.msg || UNKNOWN_ERROR); - // throw other const error = new Error(res.msg || UNKNOWN_ERROR) as Error & { code: any }; error.code = res.code; @@ -116,7 +114,8 @@ export const request = async ( // if (permCode && !useUserStore().perms.includes(permCode)) { // return $message.error('你没有访问该接口的权限,请联系管理员!'); // } - const fullUrl = `${(isMock ? baseMockUrl : baseApiUrl) + config.url}`; + const fullUrl = config.url; + console.log('fullUrl: ', fullUrl); config.url = uniqueSlash(fullUrl); const res = await service.request(config); diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5bf79bf..a471f45 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -17,6 +17,17 @@ + + + + + + { state.isRegister = !state.isRegister; + state.formInline.account = ''; state.formInline.username = ''; state.formInline.password = ''; state.formInline.confirmPassword = ''; @@ -141,9 +154,9 @@ // 修改:处理表单提交 const handleSubmit = async () => { - const { username, password, confirmPassword } = state.formInline; + const { account, username, password, confirmPassword } = state.formInline; - if (username.trim() === '' || password.trim() === '') { + if (account.trim() === '' || password.trim() === '') { return message.warning('用户名或密码不能为空!'); } @@ -151,6 +164,14 @@ if (password !== confirmPassword) { return message.warning('两次输入的密码不一致!'); } + if (username.trim() === '') { + return message.warning('用户名不能为空!'); + } + // 限制用户名不得超过100个字符 + if (username.length > 100) { + return message.warning('用户名不得超过100个字符!'); + } + if (state.formInline.email.trim() === '') { return message.warning('邮箱不能为空!'); } @@ -160,17 +181,28 @@ if (state.formInline.company.trim() === '') { return message.warning('公司名称不能为空!'); } + // 限制公司名称不得超过100个字符 + if (state.formInline.company.length > 100) { + return message.warning('公司名称不得超过100个字符!'); + } + // 限制长度 5-30位 且仅限英文字母 + if (state.formInline.account.length < 5 || state.formInline.account.length > 30) { + return message.warning('账号长度需为5到30个字母!'); + } + if (!/^[a-zA-Z]+$/.test(state.formInline.account)) { + return message.warning('账号仅限英文字母!'); + } + // TODO: 调用注册接口 state.loading = true; try { await register({ ...state.formInline, - account: state.formInline.username, sex: 1, }); message.success('注册成功,请联系系统管理员通过审核'); setTimeout(() => { - state.isRegister = false; // 注册成功后切换到登录模式 + toggleMode(); }, 1000); } catch (err: any) { Modal.error({ diff --git a/src/views/question/issue/index.vue b/src/views/question/issue/index.vue index f5f6508..6a787f4 100644 --- a/src/views/question/issue/index.vue +++ b/src/views/question/issue/index.vue @@ -224,7 +224,7 @@ ...e, }; }); - values.fileIds = values.files.map((e) => e.id).join(','); + values.fileIds = values.files.filter((e) => e.id).map((e) => e.id).join(','); } else { values.fileIds = ''; } @@ -436,7 +436,7 @@ ...e, }; }); - values.fileIds = values.files.map((e) => e.id).join(','); + values.fileIds = values.files.filter((e) => e.id).map((e) => e.id).join(','); } else { values.fileIds = ''; } diff --git a/src/views/question/knowledge/formSchemas.tsx b/src/views/question/knowledge/formSchemas.tsx index 0be0987..fbbf81f 100644 --- a/src/views/question/knowledge/formSchemas.tsx +++ b/src/views/question/knowledge/formSchemas.tsx @@ -101,7 +101,37 @@ export const getEditFormSchema: ( console.log('file: ', file); // 限制允许上传的文件类型 - const allowedTypes = ['xlsx', 'xls', 'doc', 'docx', 'pdf', 'jpg', 'jpeg', 'png']; + const allowedTypes = [ + // 文档 + 'xlsx', + 'xls', + 'doc', + 'docx', + // 图片 + 'pdf', + 'jpg', + 'jpeg', + 'png', + // 视频 + 'mp4', + 'avi', + 'mov', + 'wmv', + 'mkv', + 'flv', + 'webm', + // 压缩包 + 'zip', + 'rar', + '7z', + 'tar', + 'gz', + 'bz2', + 'tgz', + 'tbz2', + // 其他 + 'htm', + ]; // 检查文件类型 const fileType = getFileExtension(file.name) || 'unknown'; diff --git a/src/views/system/user/formSchemas.ts b/src/views/system/user/formSchemas.ts index 4d28825..48e93f2 100644 --- a/src/views/system/user/formSchemas.ts +++ b/src/views/system/user/formSchemas.ts @@ -2,7 +2,7 @@ * @Author: AaronWu 2463371514@qq.com * @Date: 2025-04-01 09:08:06 * @LastEditors: AaronWu 2463371514@qq.com - * @LastEditTime: 2025-04-01 16:48:50 + * @LastEditTime: 2025-07-15 16:19:12 * @FilePath: /IssueSupportManage/src/views/system/user/formSchemas.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -23,7 +23,8 @@ export const userSchemas: FormSchema[] = [ rules: [ { required: true, message: '请输入内容' }, { min: 5, max: 30, message: '请输入5到30个字符' }, - + //限制为纯英文 + { pattern: /^[a-zA-Z]+$/, message: '请避免使用非英文字母字符或符号' }, ], }, { diff --git a/vite.config.ts b/vite.config.ts index 7b1668c..ad82baf 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -125,10 +125,10 @@ export default defineConfig({ // rewrite: (path) => path.replace(/^\/api/, '/server'), // }, '/server': { - // target: 'http://43.137.2.78:8085', - target: 'http://192.168.2.64:8089', + target: 'http://43.137.2.78:8085', + // target: 'http://192.168.2.64:8089', changeOrigin: true, - rewrite: (path) => path.replace(/^\/server/, ''), + rewrite: (path) => path.replace(/^\/server/, '/server'), }, }, },