From 53b678f2ecb1e5680acab76a91043ecdb989ebe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88?= <2960252003@qq.com> Date: Wed, 17 Jan 2024 07:46:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- config/vite.config.dev.ts | 10 +- index.html | 26 +- npminstall-debug.log | 195 +++++++ package.json | 6 +- src/api/interceptor.ts | 11 +- src/api/role.ts | 34 +- src/api/user.ts | 32 +- src/components/navbar/index.vue | 291 +++++------ src/locale/en-US.ts | 3 + src/locale/zh-CN.ts | 3 + src/mock/user.ts | 4 +- src/router/index.ts | 1 + src/router/routes/index.ts | 1 + src/router/routes/modules/character.ts | 28 + src/router/routes/modules/dashboard.ts | 16 +- src/store/index.ts | 3 +- src/store/modules/role/index.ts | 54 ++ src/store/modules/role/type.ts | 14 + src/store/modules/user/index.ts | 22 +- src/store/modules/user/types.ts | 5 +- src/types/global.ts | 5 +- src/views/character/manage/index.vue | 489 ++++++++++++++++++ src/views/character/manage/locale/en-US.ts | 45 ++ src/views/character/manage/locale/zh-CN.ts | 46 ++ src/views/login/components/login-form.vue | 218 ++++---- src/views/login/locale/zh-CN.ts | 2 +- .../user/info/components/user-info-header.vue | 72 +-- .../setting/components/basic-information.vue | 72 +-- .../setting/components/password-reset.vue | 110 ++-- src/views/user/setting/locale/en-US.ts | 1 + src/views/user/setting/locale/zh-CN.ts | 1 + 32 files changed, 1410 insertions(+), 414 deletions(-) create mode 100644 npminstall-debug.log create mode 100644 src/router/routes/modules/character.ts create mode 100644 src/store/modules/role/index.ts create mode 100644 src/store/modules/role/type.ts create mode 100644 src/views/character/manage/index.vue create mode 100644 src/views/character/manage/locale/en-US.ts create mode 100644 src/views/character/manage/locale/zh-CN.ts diff --git a/.env.development b/.env.development index fcd6403..ad49734 100644 --- a/.env.development +++ b/.env.development @@ -1 +1,3 @@ -VITE_API_BASE_URL= '' +VITE_API_URL= '' + + \ No newline at end of file diff --git a/config/vite.config.dev.ts b/config/vite.config.dev.ts index 5e92013..53c2923 100644 --- a/config/vite.config.dev.ts +++ b/config/vite.config.dev.ts @@ -1,7 +1,7 @@ import { mergeConfig } from 'vite'; import eslint from 'vite-plugin-eslint'; +import * as path from 'path'; import baseConfig from './vite.config.base'; -import * as path from "path"; export default mergeConfig( { @@ -11,11 +11,13 @@ export default mergeConfig( fs: { strict: true, }, - proxy:{ + proxy: { '/api': { - target: 'http://localhost:8080', + target: 'http://59.110.238.182:8081', + // target: 'http://4.246.149.244:8081', + // target: 'http://localhost:5173', changeOrigin: true, - } + }, }, }, plugins: [ diff --git a/index.html b/index.html index 46cac70..61c2883 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,17 @@ - - - - - Arco Design Pro - 开箱即用的中台前端/设计解决方案 - - -
- - - + + + + + + 学院学习平台 + + + +
+ + + + \ No newline at end of file diff --git a/npminstall-debug.log b/npminstall-debug.log new file mode 100644 index 0000000..204d604 --- /dev/null +++ b/npminstall-debug.log @@ -0,0 +1,195 @@ +{ + root: 'C:\\Users\\29602\\Desktop\\study\\study-fontend', + registry: 'https://registry.npmmirror.com', + pkgs: [], + production: false, + cacheStrict: false, + cacheDir: 'C:\\Users\\29602\\.npminstall_tarball', + env: { + npm_config_registry: 'https://registry.npmmirror.com', + npm_config_argv: '{"remain":[],"cooked":["--fix-bug-versions","--china","--userconfig=C:\\\\Users\\\\29602\\\\.cnpmrc","--disturl=https://cdn.npmmirror.com/binaries/node","--registry=https://registry.npmmirror.com"],"original":["--fix-bug-versions","--china","--userconfig=C:\\\\Users\\\\29602\\\\.cnpmrc","--disturl=https://cdn.npmmirror.com/binaries/node","--registry=https://registry.npmmirror.com"]}', + npm_config_user_agent: 'npminstall/7.11.1 npm/? node/v18.19.0 win32 x64', + npm_config_cache: 'C:\\Users\\29602\\.npminstall_tarball', + NODE: 'C:\\Program Files\\nodejs\\node.exe', + npm_node_execpath: 'C:\\Program Files\\nodejs\\node.exe', + npm_execpath: 'C:\\Users\\29602\\AppData\\Roaming\\npm\\node_modules\\cnpm\\node_modules\\npminstall\\bin\\install.js', + npm_config_userconfig: 'C:\\Users\\29602\\.cnpmrc', + npm_config_disturl: 'https://cdn.npmmirror.com/binaries/node', + npm_config_r: 'https://registry.npmmirror.com', + COREPACK_NPM_REGISTRY: 'https://registry.npmmirror.com', + NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node', + NVM_NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node', + PHANTOMJS_CDNURL: 'https://cdn.npmmirror.com/binaries/phantomjs', + CHROMEDRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/chromedriver', + OPERADRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/operadriver', + CYPRESS_DOWNLOAD_PATH_TEMPLATE: 'https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip', + ELECTRON_MIRROR: 'https://cdn.npmmirror.com/binaries/electron/', + ELECTRON_BUILDER_BINARIES_MIRROR: 'https://cdn.npmmirror.com/binaries/electron-builder-binaries/', + SASS_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-sass', + SWC_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-swc', + NWJS_URLBASE: 'https://cdn.npmmirror.com/binaries/nwjs/v', + PUPPETEER_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/chrome-for-testing', + PUPPETEER_DOWNLOAD_BASE_URL: 'https://cdn.npmmirror.com/binaries/chrome-for-testing', + PLAYWRIGHT_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/playwright', + SENTRYCLI_CDNURL: 'https://cdn.npmmirror.com/binaries/sentry-cli', + SAUCECTL_INSTALL_BINARY_MIRROR: 'https://cdn.npmmirror.com/binaries/saucectl', + RE2_DOWNLOAD_MIRROR: 'https://cdn.npmmirror.com/binaries/node-re2', + RE2_DOWNLOAD_SKIP_PATH: 'true', + PRISMA_ENGINES_MIRROR: 'https://cdn.npmmirror.com/binaries/prisma', + npm_config_better_sqlite3_binary_host: 'https://cdn.npmmirror.com/binaries/better-sqlite3', + npm_config_keytar_binary_host: 'https://cdn.npmmirror.com/binaries/keytar', + npm_config_sharp_binary_host: 'https://cdn.npmmirror.com/binaries/sharp', + npm_config_sharp_libvips_binary_host: 'https://cdn.npmmirror.com/binaries/sharp-libvips', + npm_config_robotjs_binary_host: 'https://cdn.npmmirror.com/binaries/robotjs', + npm_rootpath: 'C:\\Users\\29602\\Desktop\\study\\study-fontend', + INIT_CWD: 'C:\\Users\\29602\\Desktop\\study\\study-fontend' + }, + binaryMirrors: { + ENVS: { + COREPACK_NPM_REGISTRY: 'https://registry.npmmirror.com', + NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node', + NVM_NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node', + PHANTOMJS_CDNURL: 'https://cdn.npmmirror.com/binaries/phantomjs', + CHROMEDRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/chromedriver', + OPERADRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/operadriver', + CYPRESS_DOWNLOAD_PATH_TEMPLATE: 'https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip', + ELECTRON_MIRROR: 'https://cdn.npmmirror.com/binaries/electron/', + ELECTRON_BUILDER_BINARIES_MIRROR: 'https://cdn.npmmirror.com/binaries/electron-builder-binaries/', + SASS_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-sass', + SWC_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-swc', + NWJS_URLBASE: 'https://cdn.npmmirror.com/binaries/nwjs/v', + PUPPETEER_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/chrome-for-testing', + PUPPETEER_DOWNLOAD_BASE_URL: 'https://cdn.npmmirror.com/binaries/chrome-for-testing', + PLAYWRIGHT_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/playwright', + SENTRYCLI_CDNURL: 'https://cdn.npmmirror.com/binaries/sentry-cli', + SAUCECTL_INSTALL_BINARY_MIRROR: 'https://cdn.npmmirror.com/binaries/saucectl', + RE2_DOWNLOAD_MIRROR: 'https://cdn.npmmirror.com/binaries/node-re2', + RE2_DOWNLOAD_SKIP_PATH: 'true', + PRISMA_ENGINES_MIRROR: 'https://cdn.npmmirror.com/binaries/prisma', + npm_config_better_sqlite3_binary_host: 'https://cdn.npmmirror.com/binaries/better-sqlite3', + npm_config_keytar_binary_host: 'https://cdn.npmmirror.com/binaries/keytar', + npm_config_sharp_binary_host: 'https://cdn.npmmirror.com/binaries/sharp', + npm_config_sharp_libvips_binary_host: 'https://cdn.npmmirror.com/binaries/sharp-libvips', + npm_config_robotjs_binary_host: 'https://cdn.npmmirror.com/binaries/robotjs' + }, + '@ali/s2': { host: 'https://cdn.npmmirror.com/binaries/looksgood-s2' }, + sharp: { replaceHostFiles: [Array], replaceHostMap: [Object] }, + '@tensorflow/tfjs-node': { + replaceHostFiles: [Array], + replaceHostRegExpMap: [Object], + replaceHostMap: [Object] + }, + cypress: { + host: 'https://cdn.npmmirror.com/binaries/cypress', + newPlatforms: [Object] + }, + 'utf-8-validate': { + host: 'https://cdn.npmmirror.com/binaries/utf-8-validate/v{version}' + }, + xprofiler: { + remote_path: './xprofiler/v{version}/', + host: 'https://cdn.npmmirror.com/binaries' + }, + leveldown: { host: 'https://cdn.npmmirror.com/binaries/leveldown/v{version}' }, + couchbase: { host: 'https://cdn.npmmirror.com/binaries/couchbase/v{version}' }, + gl: { host: 'https://cdn.npmmirror.com/binaries/gl/v{version}' }, + sqlite3: { + host: 'https://cdn.npmmirror.com/binaries/sqlite3', + remote_path: 'v{version}' + }, + '@journeyapps/sqlcipher': { host: 'https://cdn.npmmirror.com/binaries' }, + grpc: { + host: 'https://cdn.npmmirror.com/binaries', + remote_path: '{name}/v{version}' + }, + 'grpc-tools': { host: 'https://cdn.npmmirror.com/binaries' }, + wrtc: { + host: 'https://cdn.npmmirror.com/binaries', + remote_path: '{name}/v{version}' + }, + fsevents: { host: 'https://cdn.npmmirror.com/binaries/fsevents' }, + nodejieba: { host: 'https://cdn.npmmirror.com/binaries/nodejieba' }, + canvas: { host: 'https://cdn.npmmirror.com/binaries/canvas' }, + 'skia-canvas': { host: 'https://cdn.npmmirror.com/binaries/skia-canvas' }, + 'flow-bin': { + replaceHost: 'https://github.com/facebook/flow/releases/download/v', + host: 'https://cdn.npmmirror.com/binaries/flow/v' + }, + 'jpegtran-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/jpegtran-bin' + }, + 'cwebp-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/cwebp-bin' + }, + 'zopflipng-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/zopflipng-bin' + }, + 'optipng-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/optipng-bin' + }, + mozjpeg: { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/mozjpeg-bin' + }, + gifsicle: { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/gifsicle-bin' + }, + 'pngquant-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/pngquant-bin', + replaceHostMap: [Object] + }, + 'pngcrush-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/pngcrush-bin' + }, + 'jpeg-recompress-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/jpeg-recompress-bin' + }, + 'advpng-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/advpng-bin' + }, + 'pngout-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/pngout-bin' + }, + 'jpegoptim-bin': { + replaceHost: [Array], + host: 'https://cdn.npmmirror.com/binaries/jpegoptim-bin' + }, + argon2: { host: 'https://cdn.npmmirror.com/binaries/argon2' }, + 'ali-zeromq': { host: 'https://cdn.npmmirror.com/binaries/ali-zeromq' }, + 'ali-usb_ctl': { host: 'https://cdn.npmmirror.com/binaries/ali-usb_ctl' }, + 'gdal-async': { host: 'https://cdn.npmmirror.com/binaries/node-gdal-async' }, + 'libpg-query': { host: 'https://cdn.npmmirror.com/binaries' } + }, + forbiddenLicenses: null, + flatten: false, + proxy: undefined, + prune: false, + disableFallbackStore: false, + workspacesMap: Map(0) {}, + enableWorkspace: false, + workspaceRoot: 'C:\\Users\\29602\\Desktop\\study\\study-fontend', + isWorkspaceRoot: true, + isWorkspacePackage: false, + offline: false, + strictSSL: true, + ignoreScripts: false, + foregroundScripts: false, + ignoreOptionalDependencies: false, + detail: false, + forceLinkLatest: false, + trace: false, + engineStrict: false, + registryOnly: false, + client: false, + autoFixVersion: [Function: autoFixVersion] +} \ No newline at end of file diff --git a/package.json b/package.json index 31643da..67786de 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,11 @@ "preview": "npm run build && vite preview --host", "type:check": "vue-tsc --noEmit --skipLibCheck", "lint-staged": "npx lint-staged", - "prepare": "husky install" + "prepare": "husky install", + + "start": "npm run dev" + + }, "lint-staged": { "*.{js,ts,jsx,tsx}": [ diff --git a/src/api/interceptor.ts b/src/api/interceptor.ts index 6285c94..db09fe6 100644 --- a/src/api/interceptor.ts +++ b/src/api/interceptor.ts @@ -21,6 +21,14 @@ axios.interceptors.request.use( // this example using the JWT token // Authorization is a custom headers key // please modify it according to the actual situation + const userStore = useUserStore(); + // console.log('config', config); + // if (config.url === '/api/erst/user/me') { + // userStore.headerName = 'zsc'; + // userStore.tokenDate = '123'; + config.headers['X-CSRF-TOKEN'] = userStore.tokenDate; + // } + const token = getToken(); if (token) { if (!config.headers) { @@ -28,6 +36,7 @@ axios.interceptors.request.use( } config.headers.Authorization = `Bearer ${token}`; } + return config; }, (error) => { @@ -70,7 +79,7 @@ axios.interceptors.response.use( }, (error) => { const { response } = error; - console.log(response); + console.log('error', error); if ( [50008, 50012, 50014].includes(response.data.code) && response.config.url !== '/api/user/info' diff --git a/src/api/role.ts b/src/api/role.ts index 36ef707..a0a2960 100644 --- a/src/api/role.ts +++ b/src/api/role.ts @@ -8,6 +8,17 @@ export interface RoleCreateRecord { permissionIds: (number | undefined)[]; remark: string; } + +export interface ListRecord { + username: string; + phone: string; + email: string; + enable: string; + nickname: string; + avater: string; + address: string; +} + export interface RoleRecord extends RoleCreateRecord { permissions?: []; } @@ -16,24 +27,35 @@ export interface RoleListRecord extends RoleRecord { name: string; } - export function create(data: RoleCreateRecord) { return axios.post(`/api/role`, data); } +// 更新用户 export function update(data: RoleRecord) { - return axios.patch(`/api/role/${data.id}`, data); + return axios.patch(`/api/rest/user/${data.id}`, data); } - export function getDetail(id: number) { return axios.get(`/api/role/${id}`); } -export function remove(id: number) { - return axios.delete(`/api/role/${id}`); +// 删除用户 +export function remove(id: string) { + return axios.delete(`/api/rest/role/${id}`); } +// 模糊查询用户列表 export function queryRoles(params?: ListParams>) { - return queryList(`/api/role`, params); + return queryList(`/api/rest/user/query`, params); +} + +// 添加用户 +export function addUser(params: ListRecord) { + return axios.post('/api/rest/user/register', params); +} + +// 是否启用 +export function enabled(id: string) { + return axios.patch(`/api/rest/user/${id}/toggle`); } diff --git a/src/api/user.ts b/src/api/user.ts index 3bf3ee0..6f62d1d 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -21,7 +21,8 @@ export interface LoginRes { } export interface PasswordReSetModel { - newPassword: string; + oldPassword: string; + password: string; confirmPassword: string; } @@ -73,16 +74,30 @@ export interface UserListRes { pageable: Pageable; } -export function login(data: LoginData) { - return axios.post('/api/user/login', data); +// 获取令牌 +export function me() { + return axios.get('/api/rest/user/me'); +} + +// 用户登录 +export function login(data: LoginData, headerName: string, token: string) { + return axios({ + url: '/api/rest/user/login', + data, + method: 'post', + headers: { + [headerName]: token, + }, + }); } export function logout() { - return axios.post('/api/user/logout'); + return axios.post('/api/rest/user/logout'); } +// 更新密码 export function resetPassword(data: PasswordReSetModel) { - return axios.patch('/api/user/self/update-password', data); + return axios.patch('/api/rest/user/self/update-password', data); } export function create(data: CreateRecord) { @@ -94,15 +109,16 @@ export function update(data: UserRecord) { } export function selfUpdate(data: UserState) { - return axios.patch(`/api/user/self`, data); + return axios.patch(`/api/rest/user/self`, data); } export function switchRole(roleId: number) { return axios.patch(`/api/user/self/switch-role/${roleId}`); } +// 获取用户信息 export function getUserInfo() { - return axios.get('/api/user/info'); + return axios.get('/api/rest/user/self'); } export function getUserDetail(id: number) { @@ -124,4 +140,4 @@ export function queryUserList(params: UserParams) { return qs.stringify(obj); }, }); -} \ No newline at end of file +} diff --git a/src/components/navbar/index.vue b/src/components/navbar/index.vue index 0ee935c..9bad70a 100644 --- a/src/components/navbar/index.vue +++ b/src/components/navbar/index.vue @@ -10,7 +10,7 @@ :style="{ margin: 0, fontSize: '18px' }" :heading="5" > - Arco Pro + 中山学院
    - - - - - - - - - + + + + + + + + +
  • -
  • - - - -
  • +
  • diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 62ef2ea..0cdf66e 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -28,6 +28,7 @@ import localeUserSetting from '@/views/user/setting/locale/en-US'; import systemUser from '@/views/system/user/locale/en-US'; +import localRole from '@/views/character/manage/locale/zh-CN'; import localeSettings from './en-US/settings'; export default { @@ -45,6 +46,7 @@ export default { 'menu.arcoWebsite': 'Arco Design', 'menu.faq': 'FAQ', 'menu.system': 'System', + 'menu.role': 'Role', 'navbar.docs': 'Docs', 'navbar.action.locale': 'Switch to English', ...localeSettings, @@ -67,5 +69,6 @@ export default { ...locale500, ...localeUserInfo, ...localeUserSetting, + ...localRole, ...systemUser, }; diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 8057196..b7fcd8a 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -28,6 +28,7 @@ import localeUserSetting from '@/views/user/setting/locale/zh-CN'; import systemUser from '@/views/system/user/locale/zh-CN'; +import localRole from '@/views/character/manage/locale/zh-CN'; import localeSettings from './zh-CN/settings'; export default { @@ -45,6 +46,7 @@ export default { 'menu.arcoWebsite': 'Arco Design', 'menu.faq': '常见问题', 'menu.system': '系统管理', + 'menu.role': '角色中心', 'navbar.docs': '文档中心', 'navbar.action.locale': '切换为中文', ...localeSettings, @@ -67,6 +69,7 @@ export default { ...locale500, ...localeUserInfo, ...localeUserSetting, + ...localRole, ...systemUser, }; diff --git a/src/mock/user.ts b/src/mock/user.ts index 45b2a1e..2cd8765 100644 --- a/src/mock/user.ts +++ b/src/mock/user.ts @@ -12,7 +12,7 @@ setupMock({ // Mock.XHR.prototype.withCredentials = true; // 用户信息 - Mock.mock(new RegExp('/api/user/info'), () => { + Mock.mock(new RegExp('/api/rest/user/info'), () => { if (isLogin()) { const role = window.localStorage.getItem('userRole') || 'admin'; return successResponseWrap({ @@ -39,7 +39,7 @@ setupMock({ }); // 登录 - Mock.mock(new RegExp('/api/user/login'), (params: MockParams) => { + Mock.mock(new RegExp('/api/rest/user/login'), (params: MockParams) => { const { username, password } = JSON.parse(params.body); if (!username) { return failResponseWrap(null, '用户名不能为空', 50000); diff --git a/src/router/index.ts b/src/router/index.ts index e230a4b..2553f69 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -23,6 +23,7 @@ const router = createRouter({ requiresAuth: false, }, }, + ...appRoutes, REDIRECT_MAIN, NOT_FOUND_ROUTE, diff --git a/src/router/routes/index.ts b/src/router/routes/index.ts index c60f695..f97f711 100644 --- a/src/router/routes/index.ts +++ b/src/router/routes/index.ts @@ -1,6 +1,7 @@ import type { RouteRecordNormalized } from 'vue-router'; const modules = import.meta.glob('./modules/*.ts', { eager: true }); + const externalModules = import.meta.glob('./externalModules/*.ts', { eager: true, }); diff --git a/src/router/routes/modules/character.ts b/src/router/routes/modules/character.ts new file mode 100644 index 0000000..53a50e6 --- /dev/null +++ b/src/router/routes/modules/character.ts @@ -0,0 +1,28 @@ +import { DEFAULT_LAYOUT } from '../base'; +import { AppRouteRecordRaw } from '../types'; + +const CHARACTER: AppRouteRecordRaw = { + path: '/character', + name: 'character', + component: DEFAULT_LAYOUT, + meta: { + locale: 'menu.role', + icon: 'icon-computer', + requiresAuth: true, + order: 2, + }, + children: [ + { + path: 'manage', + name: 'Manage', + component: () => import('@/views/character/manage/index.vue'), + meta: { + locale: 'menu.role.manage', + requiresAuth: true, + permissions: ['*'], + }, + }, + ], +}; + +export default CHARACTER; diff --git a/src/router/routes/modules/dashboard.ts b/src/router/routes/modules/dashboard.ts index 8f93976..8828ef3 100644 --- a/src/router/routes/modules/dashboard.ts +++ b/src/router/routes/modules/dashboard.ts @@ -8,8 +8,8 @@ const DASHBOARD: AppRouteRecordRaw = { meta: { locale: 'menu.dashboard', requiresAuth: true, - icon: 'icon-dashboard', - order: 0, + icon: 'icon-dashboard', // 设置图标 + order: 0, // 排序路由菜单项。如果设置该值,值越高,越靠前 }, children: [ { @@ -24,13 +24,13 @@ const DASHBOARD: AppRouteRecordRaw = { }, { - path: 'monitor', - name: 'Monitor', - component: () => import('@/views/dashboard/monitor/index.vue'), + path: 'monitor',// 一级路径 + name: 'Monitor',// 路由名称 + component: () => import('@/views/dashboard/monitor/index.vue'),// 要跳转的视图,这里要跳转到页面的基本布局 meta: { - locale: 'menu.dashboard.monitor', - requiresAuth: true, - permissions: ['admin'], + locale: 'menu.dashboard.monitor',// 菜单名字 + requiresAuth: true,// 需要登录鉴权 + permissions: ['admin'],// 只允许管理员用户访问 }, }, ], diff --git a/src/store/index.ts b/src/store/index.ts index 11c703c..4c4ca11 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,9 +3,10 @@ import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; import useAppStore from './modules/app'; import useUserStore from './modules/user'; import useTabBarStore from './modules/tab-bar'; +import useRoleStore from './modules/role'; const pinia = createPinia(); pinia.use(piniaPluginPersistedstate); -export { useAppStore, useUserStore, useTabBarStore }; +export { useAppStore, useUserStore, useTabBarStore, useRoleStore }; export default pinia; diff --git a/src/store/modules/role/index.ts b/src/store/modules/role/index.ts new file mode 100644 index 0000000..d86ae68 --- /dev/null +++ b/src/store/modules/role/index.ts @@ -0,0 +1,54 @@ +import { defineStore } from 'pinia'; +import { + queryRoles, + ListRecord, + addUser, + remove, + update, + enabled, +} from '@/api/role'; +import { RoleState } from './type'; + +const useRoleStore = defineStore('role', { + state: (): RoleState => ({ + current: undefined, + pageSize: undefined, + username: undefined, + phone: undefined, + email: undefined, + enable: undefined, + nickname: undefined, + avater: undefined, + address: undefined, + }), + + getters: { + roleInfo(state: RoleState): RoleState { + return { ...state }; + }, + }, + actions: { + async getUserInfo(params: any) { + const res = await queryRoles(params); + return res; + }, + + async addUser(params: any) { + return addUser(params); + }, + + async deleteUser(id: string) { + return remove(id); + }, + + async updateUser(data: any) { + return update(data); + }, + + async enabledStatus(id: string) { + return enabled(id); + }, + }, +}); + +export default useRoleStore; diff --git a/src/store/modules/role/type.ts b/src/store/modules/role/type.ts new file mode 100644 index 0000000..9d07241 --- /dev/null +++ b/src/store/modules/role/type.ts @@ -0,0 +1,14 @@ +import { RoleRecord } from '@/api/role'; + +export type RoleType = '' | '*' | 'admin' | 'user' | string[]; +export interface RoleState { + current?: string; + pageSize?: string; + username?: string; + phone?: string; + email?: string; + enable?: string; + nickname?: string; + avater?: string; + address?: string; +} diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index b80fd38..a6fdc77 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -5,6 +5,7 @@ import { switchRole, getUserInfo, LoginData, + me, } from '@/api/user'; import { setToken, clearToken } from '@/utils/auth'; import { removeRouteListener } from '@/utils/route-listener'; @@ -14,16 +15,19 @@ import useAppStore from '../app'; const useUserStore = defineStore('user', { state: (): UserState => ({ username: undefined, - name: undefined, + nickName: undefined, avatar: undefined, email: undefined, phone: undefined, + address: undefined, createAt: undefined, remark: undefined, id: undefined, role: undefined, roles: undefined, permissions: [], + headerName: '', + tokenDate: '', }), getters: { @@ -60,12 +64,20 @@ const useUserStore = defineStore('user', { this.setInfo(res.data); }, + // Get user's crsf + async me() { + const res = await me(); + this.headerName = res.data.csrf.headerName; + this.tokenDate = res.data.csrf.token; + + return res; + }, + // Login - async login(loginForm: LoginData) { + async login(loginForm: LoginData, headerName: string, token: string) { try { - const res = await userLogin(loginForm); - // setToken(res.data.token); - setToken(res.data.token); + const res = await userLogin(loginForm, headerName, token); + setToken(token); } catch (err) { clearToken(); throw err; diff --git a/src/store/modules/user/types.ts b/src/store/modules/user/types.ts index ad95ba9..ad827cd 100644 --- a/src/store/modules/user/types.ts +++ b/src/store/modules/user/types.ts @@ -3,14 +3,17 @@ import { RoleRecord } from '@/api/role'; export type RoleType = '' | '*' | 'admin' | 'user' | string[]; export interface UserState { username?: string; - name?: string; + nickName?: string; avatar?: string; email?: string; phone?: string; + address?: string; createAt?: string; remark?: string; id?: number; role?: RoleRecord; roles?: RoleRecord[]; permissions?: string[] | '' | '*' | 'admin' | 'user'; + headerName: string; + tokenDate: string; } diff --git a/src/types/global.ts b/src/types/global.ts index 30ac3af..05a25fe 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -24,9 +24,8 @@ export interface PostData { } export interface Pagination { - current: number; - pageSize: number; - total?: number; + page: number; + size: number; } export type TimeRanger = [string, string]; diff --git a/src/views/character/manage/index.vue b/src/views/character/manage/index.vue new file mode 100644 index 0000000..c477df0 --- /dev/null +++ b/src/views/character/manage/index.vue @@ -0,0 +1,489 @@ + + + + + + diff --git a/src/views/character/manage/locale/en-US.ts b/src/views/character/manage/locale/en-US.ts new file mode 100644 index 0000000..50b471b --- /dev/null +++ b/src/views/character/manage/locale/en-US.ts @@ -0,0 +1,45 @@ +export default { + 'menu.list.searchTable': 'Search Table', + 'menu.role.manage': 'Role Manage', + 'searchTable.form.number': 'Set Number', + 'searchTable.form.number.placeholder': 'Please enter Set Number', + 'searchTable.form.name': 'Set Name', + 'searchTable.form.name.placeholder': 'Please enter Set Name', + 'searchTable.form.contentType': 'Content Type', + 'searchTable.form.contentType.img': 'image-text', + 'searchTable.form.contentType.horizontalVideo': 'Horizontal short video', + 'searchTable.form.contentType.verticalVideo': 'Vertical short video', + 'searchTable.form.filterType': 'Filter Type', + 'searchTable.form.filterType.artificial': 'artificial', + 'searchTable.form.filterType.rules': 'Rules', + 'searchTable.form.createdTime': 'Create Date', + 'searchTable.form.status': 'Status', + 'searchTable.form.status.online': 'Online', + 'searchTable.form.status.offline': 'Offline', + 'searchTable.form.search': 'Search', + 'searchTable.form.reset': 'Reset', + 'searchTable.form.selectDefault': 'All', + 'searchTable.operation.create': 'Create', + 'searchTable.operation.import': 'Import', + 'searchTable.operation.download': 'Download', + // columns + 'searchTable.columns.index': '#', + 'searchTable.columns.number': 'Set Number', + 'searchTable.columns.name': 'Set Name', + 'searchTable.columns.contentType': 'Content Type', + 'searchTable.columns.filterType': 'Filter Type', + 'searchTable.columns.count': 'Count', + 'searchTable.columns.createdTime': 'CreatedTime', + 'searchTable.columns.status': 'Status', + 'searchTable.columns.operations': 'Operations', + 'searchTable.columns.operations.view': 'View', + // size + 'searchTable.size.mini': 'mini', + 'searchTable.size.small': 'small', + 'searchTable.size.medium': 'middle', + 'searchTable.size.large': 'large', + // actions + 'searchTable.actions.refresh': 'refresh', + 'searchTable.actions.density': 'density', + 'searchTable.actions.columnSetting': 'columnSetting', +}; diff --git a/src/views/character/manage/locale/zh-CN.ts b/src/views/character/manage/locale/zh-CN.ts new file mode 100644 index 0000000..99eb32f --- /dev/null +++ b/src/views/character/manage/locale/zh-CN.ts @@ -0,0 +1,46 @@ +export default { + 'menu.list.searchTable': '查询表格', + 'menu.role.manage': '角色管理', + 'roleManage.username': '用户名', + 'searchTable.form.username': '用户名', + 'searchTable.form.username.placeholder': '请输入用户名', + 'searchTable.form.phone': '电话号码', + 'searchTable.form.phone.placeholder': '请输入电话号码', + 'searchTable.form.role': '角色', + 'searchTable.form.role.placeholder': '请选择角色', + 'searchTable.form.role.user': '普通用户', + 'searchTable.form.email': 'Email', + 'searchTable.form.email.placeholder': '请输入Email', + 'searchTable.form.role.auditor': '审核员', + 'searchTable.form.search': '查询', + 'searchTable.form.reset': '重置', + 'searchTable.columns.nickName': '昵称', + 'searchTable.columns.username': '用户名', + 'searchTable.columns.phone': '电话', + 'searchTable.columns.email': 'Email', + 'searchTable.columns.enabled': '是否启用', + 'searchTable.columns.avater': '头像', + 'searchTable.columns.address': '地址', + 'searchTable.columns.operations.detail': '详细', + 'searchTable.operation.create': '添加', + 'searchTable.operation.delete': '删除', + 'add.user.info': '添加用户', + 'add.user.info.username': '用户名', + 'add.user.info.username.placeholder': '请输入用户名', + 'add.user.info.password': '密码', + 'add.user.info.password.placeholder': '请输入密码', + 'add.user.info.phone': '电话号码', + 'add.user.info.phone.placeholder': '请输入电话号码', + 'add.user.info.email': 'Email', + 'add.user.info.email.placeholder': '请输入Email', + 'add.user.info.nickName': '昵称', + 'add.user.info.nickName.placeholder': '请输入昵称', + 'add.user.info.address': '地址', + 'add.user.info.address.placeholder': '请输入地址', + 'add.user.info.dept': '角色', + 'add.user.info.dept.placeholder': '请选择角色', + 'add.user.info.sucess': '添加成功', + 'add.user.info.fail': '添加失败', + 'modify.user.info.sucess': '修改成功', + 'modify.user.info.fail': '修改失败', +}; diff --git a/src/views/login/components/login-form.vue b/src/views/login/components/login-form.vue index 263c41a..5f79bd1 100644 --- a/src/views/login/components/login-form.vue +++ b/src/views/login/components/login-form.vue @@ -1,8 +1,8 @@ diff --git a/src/views/login/locale/zh-CN.ts b/src/views/login/locale/zh-CN.ts index c0725f4..f0aba2a 100644 --- a/src/views/login/locale/zh-CN.ts +++ b/src/views/login/locale/zh-CN.ts @@ -1,5 +1,5 @@ export default { - 'login.form.title': '中山学院学习平台', + 'login.form.title': '学院学习平台', 'login.form.userName.errMsg': '用户名不能为空', 'login.form.password.errMsg': '密码不能为空', 'login.form.login.errMsg': '登录出错,请刷新重试', diff --git a/src/views/user/info/components/user-info-header.vue b/src/views/user/info/components/user-info-header.vue index 560921f..fc55dcc 100644 --- a/src/views/user/info/components/user-info-header.vue +++ b/src/views/user/info/components/user-info-header.vue @@ -8,24 +8,26 @@ - {{ userInfo.username }} + {{ userInfo.nickName }}
    - - {{ userInfo.username }} -
    -
    - + {{ userInfo.phone }}
    - - - - +
    + + + {{ userInfo.email }} + +
    + + + +
    @@ -33,37 +35,37 @@ diff --git a/src/views/user/setting/components/basic-information.vue b/src/views/user/setting/components/basic-information.vue index f32100e..ff85eba 100644 --- a/src/views/user/setting/components/basic-information.vue +++ b/src/views/user/setting/components/basic-information.vue @@ -38,7 +38,7 @@ /> - + @@ -79,41 +79,41 @@ diff --git a/src/views/user/setting/components/password-reset.vue b/src/views/user/setting/components/password-reset.vue index 7f902f3..31a2d77 100644 --- a/src/views/user/setting/components/password-reset.vue +++ b/src/views/user/setting/components/password-reset.vue @@ -7,13 +7,26 @@ :wrapper-col-props="{ span: 16 }" > + + + + + @@ -46,55 +59,58 @@ diff --git a/src/views/user/setting/locale/en-US.ts b/src/views/user/setting/locale/en-US.ts index a15cf87..0740319 100644 --- a/src/views/user/setting/locale/en-US.ts +++ b/src/views/user/setting/locale/en-US.ts @@ -45,6 +45,7 @@ export default { 'userSetting.basicInfo.placeholder.profile': 'Please enter your profile, no more than 200 words', 'userSetting.form.error.profile.maxLength': 'No more than 200 words', + 'userSetting.passwordReset.form.label.oldPassword': 'Orinal Password', 'userSetting.SecuritySettings.form.label.password': 'Login Password', 'userSetting.SecuritySettings.placeholder.password': 'Has been set. The password must contain at least six letters, digits, and special characters except Spaces. The password must contain both uppercase and lowercase letters.', diff --git a/src/views/user/setting/locale/zh-CN.ts b/src/views/user/setting/locale/zh-CN.ts index 0e77019..c6198f7 100644 --- a/src/views/user/setting/locale/zh-CN.ts +++ b/src/views/user/setting/locale/zh-CN.ts @@ -33,6 +33,7 @@ export default { 'userSetting.basicInfo.placeholder.profile': '请输入您的个人简介,最多不超过200字。', 'userSetting.form.error.profile.maxLength': '最多不超过200字', + 'userSetting.passwordReset.form.label.oldPassword': '原密码', 'userSetting.passwordReset.form.label.newPassword': '新密码', 'userSetting.passwordReset.form.label.confirmPassword': '确认新密码', 'userSetting.SecuritySettings.form.label.password': '登录密码',