Browse Source

feat: bug fix commit

master
AaronWu 5 months ago
parent
commit
3d8478739a
  1. 2
      .env
  2. 7
      .env.development
  3. 6
      .env.production
  4. 9
      src/utils/request.ts
  5. 40
      src/views/login/index.vue
  6. 4
      src/views/question/issue/index.vue
  7. 32
      src/views/question/knowledge/formSchemas.tsx
  8. 5
      src/views/system/user/formSchemas.ts
  9. 6
      vite.config.ts

2
.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'

7
.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/'

6
.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/'

9
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 <T = any>(
// 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);

40
src/views/login/index.vue

@ -17,6 +17,17 @@
<a-form layout="vertical" :model="state.formInline" @submit.prevent="handleSubmit">
<a-form-item>
<a-input
v-model:value="state.formInline.account"
size="large"
:placeholder="!state.isRegister ? '请输入账号' : '账号长度5-30个字符,仅限英文字母'"
class="custom-input"
>
<template #prefix><user-outlined /></template>
</a-input>
</a-form-item>
<!-- 用户名 -->
<a-form-item v-if="state.isRegister">
<a-input
v-model:value="state.formInline.username"
size="large"
@ -116,6 +127,7 @@
isRegister: false, //
captcha: '',
formInline: {
account: '',
username: '',
password: '',
company: '', //
@ -132,6 +144,7 @@
// /
const toggleMode = () => {
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({

4
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 = '';
}

32
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';

5
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<API.CreateUserParams>[] = [
rules: [
{ required: true, message: '请输入内容' },
{ min: 5, max: 30, message: '请输入5到30个字符' },
//限制为纯英文
{ pattern: /^[a-zA-Z]+$/, message: '请避免使用非英文字母字符或符号' },
],
},
{

6
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'),
},
},
},

Loading…
Cancel
Save