diff --git a/.env.development b/.env.development index dbc8548..f3c96a4 100644 --- a/.env.development +++ b/.env.development @@ -1,8 +1,8 @@ # 开发环境标识(Vite 内置变量,无需修改) NODE_ENV = development -# 开发环境接口基础地址(对应你配置的 192.168.10.10:8085/api) -VITE_API_BASE_URL = http://192.168.10.10:8085/api +# 开发环境接口基础地址(对应你配置的 192.168.11.113:8085/api) +VITE_API_BASE_URL = http://192.168.11.113:8085/api # 请求超时时间(毫秒) VITE_REQUEST_TIMEOUT = 10000 diff --git a/src/api/index.ts b/src/api/index.ts index a69c189..4b058c8 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -2,7 +2,8 @@ import axios from 'axios' import type { AxiosResponse, AxiosError, InternalAxiosRequestConfig } from 'axios' import type { ApiResponse } from '@/api/types' import { ElLoading, ElNotification } from 'element-plus' -import { getStorage, setStorage } from '@/utils/storage' +import { getStorage, setStorage, removeStorage } from '@/utils/storage' +import router from '../router' // 定义loading实例类型,用于控制loading的显示和关闭 let loadingInstance: ReturnType | null = null @@ -14,7 +15,7 @@ const showLoading = () => { if (requestCount === 0 && !loadingInstance) { loadingInstance = ElLoading.service({ lock: true, // 锁定屏幕滚动 - fullscreen: true // 全屏显示 + fullscreen: true, // 全屏显示 }) } requestCount++ @@ -46,7 +47,7 @@ const service = axios.create({ // 3. 请求拦截器:直接使用 axios 内置类型 const requestInterceptor = (config: InternalAxiosRequestConfig) => { - console.log('请求配置', config); + console.log('请求配置', config) // 显示loading(可通过config配置项控制是否显示,比如某些请求不需要loading) if (config.headers?.showLoading !== false) { @@ -81,9 +82,9 @@ const responseInterceptor = (response: AxiosResponse if (response.headers['new_token'] !== undefined) { setStorage('token', response.headers['new_token'] as string) } - console.log('响应response', response); + console.log('响应response', response) const { data } = response - console.log('响应数据data', data); + console.log('响应数据data', data) // 判断业务状态码 if (data.code == 200 || data.code == 0) { // 仅当业务成功时,才弹成功提示 @@ -91,23 +92,23 @@ const responseInterceptor = (response: AxiosResponse message: data.msg || '操作成功!', type: 'success', duration: 2000, - customClass: 'global-notification' + customClass: 'global-notification', }) return data.data } else { - if (data.code === 1) { - // 不弹错误提示,返回带特殊标识的结果 - // 其他业务失败:弹错误提示并拒绝Promise - ElNotification({ - message: data.msg || '未知的错误!', - type: 'error', - duration: 2000, - customClass: 'global-notification' - }) - const result = { - isUserNotExist: true, // 自定义标识,标记“用户不存在” - } as T - return result + switch (data.code) { + case 1: + if (!data.msg) { + data.msg = '未知的错误!' + } + break + case -101: + data.msg = 'token错误!' + removeStorage('token') + router.push({ name: 'Login' }) + break + default: + break; } // 其他业务失败:弹错误提示并拒绝Promise @@ -115,7 +116,7 @@ const responseInterceptor = (response: AxiosResponse message: data.msg || '未知的错误!', type: 'error', duration: 2000, - customClass: 'global-notification' + customClass: 'global-notification', }) return Promise.reject(data) } @@ -159,7 +160,7 @@ const responseErrorInterceptor = (error: AxiosError) => { message: errMsg, type: 'error', duration: 2000, - customClass: 'global-notification' + customClass: 'global-notification', }) return Promise.reject(error) } @@ -170,13 +171,13 @@ service.interceptors.response.use(responseInterceptor, responseErrorInterceptor) export const request = { get(url: string, params?: unknown, config?: InternalAxiosRequestConfig): Promise { return service.get>(url, { params, ...config }).then((res) => { - return res as T; - }); + return res as T + }) }, post(url: string, data?: unknown, config?: InternalAxiosRequestConfig): Promise { return service.post>(url, data, config).then((res) => { - return res as T; - }); + return res as T + }) }, } diff --git a/src/api/modules/system/setting.ts b/src/api/modules/system/setting.ts new file mode 100644 index 0000000..18ddc2e --- /dev/null +++ b/src/api/modules/system/setting.ts @@ -0,0 +1,38 @@ +import { request } from '@/api'; + +type SettingFormParams = { + key: string + value: string + description: string +} + +type SettingListResponse = SettingFormParams & { + id: number +} + +/** + * 获取设置列表 + * @returns Promise 设置列表数据 + */ +export async function getSettingApi(): Promise { + return request.get('/setting/getList') +} + +/** + * 添加设置 + * @param params + * @returns Promise + */ +export async function createSettingApi(params: SettingFormParams): Promise { + return request.post('/setting/add', params) +} + +/** + * 编辑设置 + * @param params 菜单表单参数(含id) + * @returns Promise + */ +export async function editSettingApi(params: SettingFormParams): Promise { + return request.post('/setting/edit', params) +} + diff --git a/src/api/modules/trade/time.ts b/src/api/modules/trade/time.ts new file mode 100644 index 0000000..60bd72d --- /dev/null +++ b/src/api/modules/trade/time.ts @@ -0,0 +1,21 @@ +import { request } from '@/api'; + +// 获取节假日列表 +export async function getHolidayList(): Promise { + return request.get('/contractVariety/getHolidayList') +} + +// 添加节假日 +export async function addHoliday(params: any): Promise { + return request.post('/contractVariety/addHoliday', { ...params }) +} + +//编辑节假日 +export async function editHoliday(params: any): Promise { + return request.post('/contractVariety/editHoliday', { ...params }) +} + +// 删除节假日 +export async function delHoliday(params: any): Promise { + return request.post('/contractVariety/delHoliday', { ...params }) +} diff --git a/src/components/layout/Sidebar.vue b/src/components/layout/Sidebar.vue index 492188e..c923aa0 100644 --- a/src/components/layout/Sidebar.vue +++ b/src/components/layout/Sidebar.vue @@ -1,49 +1,57 @@ diff --git a/src/router/index.ts b/src/router/index.ts index d5d9180..22f9e50 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -14,39 +14,39 @@ const routes = [ path: 'login', name: 'Login', component: () => import('@/views/user/Login.vue'), - meta: { isAuthPage: true, title: '登录' } + meta: { isAuthPage: true, title: '登录' }, }, { path: 'register', name: 'Register', component: () => import('@/views/user/Register.vue'), - meta: { isAuthPage: true, title: '注册' } + meta: { isAuthPage: true, title: '注册' }, }, { path: 'forgot-password', name: 'ForgotPassword', component: () => import('@/views/user/ForgotPassword.vue'), - meta: { isAuthPage: true, title: '忘记密码' } + meta: { isAuthPage: true, title: '忘记密码' }, }, { path: 'change-password', name: 'ChangePassword', component: () => import('@/views/user/ChangePassword.vue'), - meta: { requiresAuth: true, title: '修改密码' } + meta: { requiresAuth: true, title: '修改密码' }, }, { path: 'bind-email', name: 'BindEmail', component: () => import('@/views/user/bindEmail.vue'), - meta: { requiresAuth: true, title: '绑定邮箱' } + meta: { requiresAuth: true, title: '绑定邮箱' }, }, { path: 'bind-phone', name: 'BindPhone', component: () => import('@/views/user/bindPhone.vue'), - meta: { requiresAuth: true, title: '绑定手机号' } - } - ] + meta: { requiresAuth: true, title: '绑定手机号' }, + }, + ], }, // 带侧边栏布局的核心业务页面 { @@ -62,7 +62,7 @@ const routes = [ component: () => import('@/views/dashboard/index.vue'), meta: { title: '首页', // 左侧菜单显示的标题 - } + }, }, // 系统管理 { @@ -78,7 +78,7 @@ const routes = [ component: () => import('@/views/system/menu/index.vue'), meta: { title: '菜单管理', // 左侧菜单显示的标题 - } + }, }, { path: 'role', @@ -86,9 +86,17 @@ const routes = [ component: () => import('@/views/system/role/index.vue'), meta: { title: '角色管理', // 左侧菜单显示的标题 - } - } - ] + }, + }, + { + path: 'setting', + name: 'Setting', + component: () => import('@/views/system/setting/index.vue'), + meta: { + title: '系统设置', // 左侧菜单显示的标题 + }, + }, + ], }, //模板配置 { @@ -97,7 +105,7 @@ const routes = [ meta: { title: '模板配置', // 左侧菜单显示的标题 }, - children: [] + children: [], }, //账户管理 { @@ -113,7 +121,7 @@ const routes = [ component: () => import('@/views/account/client/index.vue'), meta: { title: '客户管理', // 左侧菜单显示的标题 - } + }, }, { path: 'agentList', @@ -121,7 +129,7 @@ const routes = [ component: () => import('@/views/account/agentList/index.vue'), meta: { title: '代理管理', // 左侧菜单显示的标题 - } + }, }, { path: 'market-maker', @@ -129,7 +137,7 @@ const routes = [ component: () => import('@/views/account/market-maker/index.vue'), meta: { title: '做市商管理', // 左侧菜单显示的标题 - } + }, }, { path: 'archives', @@ -137,7 +145,7 @@ const routes = [ component: () => import('@/views/account/archives/index.vue'), meta: { title: '档案管理', // 左侧菜单显示的标题 - } + }, }, { path: 'accountDetail', @@ -145,9 +153,9 @@ const routes = [ component: () => import('@/views/account/accountDetail/index.vue'), meta: { title: '账号管理', // 左侧菜单显示的标题 - } + }, }, - ] + ], }, //交易管理 { @@ -163,7 +171,7 @@ const routes = [ component: () => import('@/views/trade/variety/index.vue'), meta: { title: '品种', // 左侧菜单显示的标题 - } + }, }, { path: 'group', @@ -171,7 +179,7 @@ const routes = [ component: () => import('@/views/trade/group/index.vue'), meta: { title: '交易组', // 左侧菜单显示的标题 - } + }, }, { path: 'time', @@ -179,7 +187,7 @@ const routes = [ component: () => import('@/views/trade/time/index.vue'), meta: { title: '交易时间', // 左侧菜单显示的标题 - } + }, }, { path: 'positionStat', @@ -187,7 +195,7 @@ const routes = [ component: () => import('@/views/trade/positionStat/index.vue'), meta: { title: '持仓统计', // 左侧菜单显示的标题 - } + }, }, { path: 'historyTrade', @@ -195,7 +203,7 @@ const routes = [ component: () => import('@/views/trade/historyTrade/index.vue'), meta: { title: '历史交易', // 左侧菜单显示的标题 - } + }, }, { path: 'tradeSoftware', @@ -203,9 +211,9 @@ const routes = [ component: () => import('@/views/trade/tradeSoftware/index.vue'), meta: { title: '交易软件', // 左侧菜单显示的标题 - } + }, }, - ] + ], }, //公告管理 { @@ -230,7 +238,7 @@ const routes = [ component: () => import('@/views/funding/deposit/index.vue'), meta: { title: '存款审核', // 左侧菜单显示的标题 - } + }, }, { path: 'withdrawal', @@ -238,7 +246,7 @@ const routes = [ component: () => import('@/views/funding/withdrawl/index.vue'), meta: { title: '取款审核', // 左侧菜单显示的标题 - } + }, }, { path: 'withdrawalDetail', @@ -246,7 +254,7 @@ const routes = [ component: () => import('@/views/funding/withdrawalDetail/index.vue'), meta: { title: '取款明细', // 左侧菜单显示的标题 - } + }, }, { path: 'depositDetail', @@ -254,7 +262,7 @@ const routes = [ component: () => import('@/views/funding/depositDetail/index.vue'), meta: { title: '存款明细', // 左侧菜单显示的标题 - } + }, }, { path: 'transfer', @@ -262,7 +270,7 @@ const routes = [ component: () => import('@/views/funding/transfer/index.vue'), meta: { title: '转账', // 左侧菜单显示的标题 - } + }, }, { path: 'transferDetail', @@ -270,7 +278,7 @@ const routes = [ component: () => import('@/views/funding/transferDetail/index.vue'), meta: { title: '转账明细', // 左侧菜单显示的标题 - } + }, }, { path: 'capitalFlow', @@ -278,7 +286,7 @@ const routes = [ component: () => import('@/views/funding/capitalFlow/index.vue'), meta: { title: '资金流水', // 左侧菜单显示的标题 - } + }, }, { path: 'receiverAccount', @@ -286,7 +294,7 @@ const routes = [ component: () => import('@/views/funding/receiverAccount/index.vue'), meta: { title: '收款账户列表', // 左侧菜单显示的标题 - } + }, }, { path: 'depositChannel', @@ -294,7 +302,7 @@ const routes = [ component: () => import('@/views/funding/depositChannel/index.vue'), meta: { title: '存款渠道列表', // 左侧菜单显示的标题 - } + }, }, { path: 'fundDetail', @@ -302,9 +310,9 @@ const routes = [ component: () => import('@/views/funding/fundDetail/index.vue'), meta: { title: '资金明细', // 左侧菜单显示的标题 - } + }, }, - ] + ], }, { path: 'risk', @@ -329,7 +337,7 @@ const routes = [ component: () => import('@/views/personalized/followRecord/index.vue'), meta: { title: '跟单记录', // 左侧菜单显示的标题 - } + }, }, // 带单记录 { @@ -338,9 +346,9 @@ const routes = [ component: () => import('@/views/personalized/leadRecord/index.vue'), meta: { title: '带单记录', // 左侧菜单显示的标题 - } + }, }, - ] + ], }, //代理管理 { @@ -357,7 +365,7 @@ const routes = [ component: () => import('@/views/agent/customerList/index.vue'), meta: { title: '客户列表', // 左侧菜单显示的标题 - } + }, }, //客户详情 { @@ -366,7 +374,7 @@ const routes = [ component: () => import('@/views/agent/customerDetail/index.vue'), meta: { title: '客户详情', // 左侧菜单显示的标题 - } + }, }, //客户交易订单 { @@ -375,7 +383,7 @@ const routes = [ component: () => import('@/views/agent/customerTradeOrder/index.vue'), meta: { title: '客户交易订单', // 左侧菜单显示的标题 - } + }, }, //客户资金流水 { @@ -384,17 +392,17 @@ const routes = [ component: () => import('@/views/agent/customerCapitalFlow/index.vue'), meta: { title: '客户资金流水', // 左侧菜单显示的标题 - } + }, }, - ] + ], }, - ] + ], }, { path: '/:pathMatch(.*)*', - redirect: '/user/login' // 404 重定向到登录页,避免循环 - } -]; + redirect: '/user/login', // 404 重定向到登录页,避免循环 + }, +] const router = createRouter({ history: createWebHistory(), @@ -429,4 +437,4 @@ router.afterEach((to) => { } }); -export default router; \ No newline at end of file +export default router; diff --git a/src/views/system/setting/index.vue b/src/views/system/setting/index.vue new file mode 100644 index 0000000..2220b28 --- /dev/null +++ b/src/views/system/setting/index.vue @@ -0,0 +1,156 @@ + + diff --git a/src/views/system/setting/options.ts b/src/views/system/setting/options.ts new file mode 100644 index 0000000..db2aa6c --- /dev/null +++ b/src/views/system/setting/options.ts @@ -0,0 +1,19 @@ +//定义table配置 +export const menuTableColumns = [ + { prop: 'key', label: 'key', align: 'center' as const }, + { prop: 'value', label: 'value', align: 'center' as const }, + { prop: 'description', label: '备注', align: 'center' as const }, + { label: '操作', slotName: 'action', align: 'center' as const }, +] + +//定义menuForm配置 +export const menuFormItemOptions = [ + { prop: 'key', label: 'key', type: 'input' as const, placeholder: '请输入key', disabled: false }, + { prop: 'value', label: 'value', type: 'input' as const, placeholder: '请选择value' }, + { + prop: 'description', + label: 'description', + type: 'input' as const, + placeholder: '请选择description', + }, +] diff --git a/src/views/system/setting/rules.ts b/src/views/system/setting/rules.ts new file mode 100644 index 0000000..6ea979a --- /dev/null +++ b/src/views/system/setting/rules.ts @@ -0,0 +1,9 @@ +import type { FormRules } from 'element-plus' + +export const rules = (): FormRules => { + return { + key: [{ required: true, message: '请选择key', trigger: 'blur' }], + value: [{ required: true, message: '请选择value', trigger: 'blur' }], + description: [{ required: true, message: '请选择备注', trigger: 'blur' }], + } +} diff --git a/src/views/trade/group/index.vue b/src/views/trade/group/index.vue index 43f1259..06d278c 100644 --- a/src/views/trade/group/index.vue +++ b/src/views/trade/group/index.vue @@ -1,6 +1,6 @@