diff --git a/.env.dev_prod b/.env.dev_prod index 67eb4e0..b59552e 100644 --- a/.env.dev_prod +++ b/.env.dev_prod @@ -4,4 +4,4 @@ NODE_ENV = 'development' # 开发模式连生产服 VUE_APP_BASE_API = '/api-prod' VUE_APP_COOKIE = '' -VUE_APP_BASE_API2 = 'http://nbxt.oa.x-lf.cn' +VUE_APP_INNER='http://nbxt.oa.x-lf.cn' \ No newline at end of file diff --git a/components.d.ts b/components.d.ts index f6d0d87..34bc889 100644 --- a/components.d.ts +++ b/components.d.ts @@ -13,17 +13,13 @@ declare module '@vue/runtime-core' { DropdownMenu: typeof import('./src/components/Share/DropdownMenu.vue')['default'] Dropzone: typeof import('./src/components/Dropzone/index.vue')['default'] EditorImage: typeof import('./src/components/Tinymce/components/EditorImage.vue')['default'] - ElAlert: typeof import('element-plus/es')['ElAlert'] - ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete'] ElBadge: typeof import('element-plus/es')['ElBadge'] ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem'] ElButton: typeof import('element-plus/es')['ElButton'] - ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] ElCard: typeof import('element-plus/es')['ElCard'] - ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] + ElCol: typeof import('element-plus/es')['ElCol'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] - ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] @@ -35,22 +31,14 @@ declare module '@vue/runtime-core' { ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElOption: typeof import('element-plus/es')['ElOption'] - ElPagination: typeof import('element-plus/es')['ElPagination'] - ElPopover: typeof import('element-plus/es')['ElPopover'] ElProgress: typeof import('element-plus/es')['ElProgress'] - ElRadio: typeof import('element-plus/es')['ElRadio'] - ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] - ElRate: typeof import('element-plus/es')['ElRate'] ElRow: typeof import('element-plus/es')['ElRow'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] - ElSlider: typeof import('element-plus/es')['ElSlider'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] - ElTabPane: typeof import('element-plus/es')['ElTabPane'] - ElTabs: typeof import('element-plus/es')['ElTabs'] ElTag: typeof import('element-plus/es')['ElTag'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ErrorLog: typeof import('./src/components/ErrorLog/index.vue')['default'] @@ -79,7 +67,4 @@ declare module '@vue/runtime-core' { UploadExcel: typeof import('./src/components/UploadExcel/index.vue')['default'] VueCountTo: typeof import('./src/components/vue-count-to/vue-countTo.vue')['default'] } - export interface ComponentCustomProperties { - vLoading: typeof import('element-plus/es')['ElLoadingDirective'] - } } diff --git a/src/api/user.js b/src/api/user.js index a5f2d01..659661d 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,24 +1,39 @@ import request from '@/utils/request'; + + +function getCurrentTimestamp() { + return new Date().getTime(); +} export function login(data) { return request({ url: '/auth/login', method: 'post', - data + data, + headers: { + 'Timestamp':getCurrentTimestamp() + } }); } export function getInfo(token) { return request({ - url: '/vue-element-admin/user/info', - method: 'get', - params: { token } + url: '/user/profile/get', + method: 'post', + params: {token}, + headers: { + 'Timestamp': getCurrentTimestamp() + } }); } + export function logout(token) { return request({ - url: '/vue-element-admin/user/logout', - method: 'post', - params: { token } + url: '/auth/logout', + method: 'get', + params: { token }, + headers: { + 'Timestamp': getCurrentTimestamp() + } }); } diff --git a/src/permission.ts b/src/permission.ts index 935930a..7eb8fd9 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -20,7 +20,7 @@ router.beforeEach(async (to, from, next) => { // determine whether the user has logged in const hasToken = getToken(); - + console.log('88888',hasToken) if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page @@ -28,7 +28,9 @@ router.beforeEach(async (to, from, next) => { next({ path: '/' }); } else { // determine whether the user has obtained his permission roles through getInfo - const hasRoles = userStore().roles && userStore().roles.length > 0; + // const hasRoles = userStore().roles && userStore().roles.length > 0; + const hasRoles = true; + // console.log('hasRoles=', hasRoles); if (hasRoles) { next(); @@ -38,6 +40,7 @@ router.beforeEach(async (to, from, next) => { // note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] // eslint-disable-next-line @typescript-eslint/no-explicit-any const infoRes = await userStore().getInfo() as any; + console.log('permissionuserinfor:',infoRes) let roles = []; if (infoRes.roles) { roles = infoRes.roles; diff --git a/src/router/index.ts b/src/router/index.ts index ef5ebf6..334b763 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,15 +1,15 @@ -// import { markRaw } from 'vue'; +import { markRaw } from 'vue'; import { createRouter, createWebHistory } from 'vue-router'; // createWebHashHistory, createWebHistory import type { Router, RouteRecordRaw, RouteComponent } from 'vue-router'; -// import { Help as IconHelp } from '@element-plus/icons-vue'; +import { Help as IconHelp } from '@element-plus/icons-vue'; /* Layout */ const Layout = ():RouteComponent => import('@/layout/index.vue'); /* Router Modules */ -// import componentsRouter from './modules/components'; -// import chartsRouter from './modules/charts'; -// import nestedRouter from './modules/nested'; +import componentsRouter from './modules/components'; +import chartsRouter from './modules/charts'; +import nestedRouter from './modules/nested'; import tableRouter from './modules/table'; /** @@ -51,44 +51,44 @@ export const constantRoutes:RouteRecordRaw[] = [ component: () => import('@/views/error-page/401.vue'), meta: { hidden: true } }, - // { - // path: '/', - // component: Layout, - // redirect: '/dashboard', - // children: [ - // { - // path: 'dashboard', - // component: () => import('@/views/dashboard/index.vue'), - // name: 'Dashboard', - // meta: { title: 'Dashboard', icon: 'dashboard', affix: true } - // } - // ] - // }, - // { - // path: '/documentation', - // component: Layout, - // children: [ - // { - // path: 'index', - // component: () => import('@/views/documentation/index.vue'), - // name: 'Documentation', - // meta: { title: 'Documentation', icon: 'documentation', affix: true } - // } - // ] - // }, - // { - // path: '/guide', - // component: Layout, - // redirect: '/guide/index', - // children: [ - // { - // path: 'index', - // component: () => import('@/views/guide/index.vue'), - // name: 'Guide', - // meta: { title: 'Guide', icon: 'guide', noCache: true } - // } - // ] - // }, + { + path: '/', + component: Layout, + redirect: '/dashboard', + children: [ + { + path: 'dashboard', + component: () => import('@/views/dashboard/index.vue'), + name: 'Dashboard', + meta: { title: '我管理的', icon: 'dashboard', affix: true } + } + ] + }, + { + path: '/documentation', + component: Layout, + children: [ + { + path: 'index', + component: () => import('@/views/documentation/index.vue'), + name: 'Documentation', + meta: { title: 'Documentation', icon: 'documentation', affix: true } + } + ] + }, + { + path: '/guide', + component: Layout, + redirect: '/guide/index', + children: [ + { + path: 'index', + component: () => import('@/views/guide/index.vue'), + name: 'Guide', + meta: { title: 'Guide', icon: 'guide', noCache: true } + } + ] + }, { path: '/profile', component: Layout, @@ -118,91 +118,91 @@ export const asyncRoutes:RouteRecordRaw[] = [ redirect: '/permission/page', name: 'Permission', meta: { - // alwaysShow: true, // will always show the root menu - title: '内部系统' - // icon: 'lock' - // roles: ['admin', 'editor'] // you can set roles in root nav + alwaysShow: true, // will always show the root menu + title: 'Permission', + icon: 'lock', + roles: ['admin', 'editor','teacher_user'] // you can set roles in root nav }, children: [ - // { - // path: 'page', - // component: () => import('@/views/permission/page.vue'), - // name: 'PagePermission', - // meta: { - // title: 'Page Permission', - // roles: ['admin'] // or you can only set roles in sub nav - // } - // }, - // { - // path: 'directive', - // component: () => import('@/views/permission/directive.vue'), - // name: 'DirectivePermission', - // meta: { - // title: 'Directive Permission' - // // if do not set roles, means: this page does not require permission - // } - // }, - // { - // path: 'role', - // component: () => import('@/views/permission/role.vue'), - // name: 'RolePermission', - // meta: { - // title: 'Role Permission', - // roles: ['admin'] - // } - // } + { + path: 'page', + component: () => import('@/views/permission/page.vue'), + name: 'PagePermission', + meta: { + title: 'Page Permission', + roles: ['admin','teacher_user'] // or you can only set roles in sub nav + } + }, + { + path: 'directive', + component: () => import('@/views/permission/directive.vue'), + name: 'DirectivePermission', + meta: { + title: 'Directive Permission' + // if do not set roles, means: this page does not require permission + } + }, + { + path: 'role', + component: () => import('@/views/permission/role.vue'), + name: 'RolePermission', + meta: { + title: 'Role Permission', + roles: ['admin','teacher'] + } + } ] }, - // { - // path: '/icon', - // component: Layout, - // children: [ - // { - // path: 'index', - // component: () => import('@/views/icons/index.vue'), - // name: 'Icons', - // meta: { title: 'Icons', icon: 'icon', noCache: true } - // } - // ] - // }, + { + path: '/icon', + component: Layout, + children: [ + { + path: 'index', + component: () => import('@/views/icons/index.vue'), + name: 'Icons', + meta: { title: 'Icons', icon: 'icon', noCache: true } + } + ] + }, // /** when your routing map is too long, you can split it into small modules **/ - // componentsRouter, - // chartsRouter, - // nestedRouter, + componentsRouter, + chartsRouter, + nestedRouter, tableRouter, - // - // { - // path: '/example', - // component: Layout, - // redirect: '/example/list', - // name: 'Example', - // meta: { - // title: 'Example', - // icon: markRaw(IconHelp) - // }, - // children: [ - // { - // path: 'create', - // component: () => import('@/views/example/create.vue'), - // name: 'CreateArticle', - // meta: { title: 'Create Article', icon: 'edit' } - // }, - // { - // path: 'edit/:id(\\d+)', - // component: () => import('@/views/example/edit.vue'), - // name: 'EditArticle', - // meta: { hidden: true, title: 'Edit Article', noCache: true, activeMenu: '/example/list' } - // }, - // { - // path: 'list', - // component: () => import('@/views/example/list.vue'), - // name: 'ArticleList', - // meta: { title: 'Article List', icon: 'list' } - // } - // ] - // }, + + { + path: '/example', + component: Layout, + redirect: '/example/list', + name: 'Example', + meta: { + title: 'Example', + icon: markRaw(IconHelp) + }, + children: [ + { + path: 'create', + component: () => import('@/views/example/create.vue'), + name: 'CreateArticle', + meta: { title: 'Create Article', icon: 'edit' } + }, + { + path: 'edit/:id(\\d+)', + component: () => import('@/views/example/edit.vue'), + name: 'EditArticle', + meta: { hidden: true, title: 'Edit Article', noCache: true, activeMenu: '/example/list' } + }, + { + path: 'list', + component: () => import('@/views/example/list.vue'), + name: 'ArticleList', + meta: { title: 'Article List', icon: 'list' } + } + ] + }, { path: '/tab', @@ -212,35 +212,35 @@ export const asyncRoutes:RouteRecordRaw[] = [ path: 'index', component: () => import('@/views/tab/index.vue'), name: 'Tab', - meta: { title: '日报', icon: 'tab' } + meta: { title: 'Tab', icon: 'tab' } } ] }, - // { - // path: '/error', - // component: Layout, - // redirect: 'noRedirect', - // name: 'ErrorPages', - // meta: { - // title: 'Error Pages', - // icon: '404' - // }, - // children: [ - // { - // path: '401', - // component: () => import('@/views/error-page/401.vue'), - // name: 'Page401', - // meta: { title: '401', noCache: true } - // }, - // { - // path: '404', - // component: () => import('@/views/error-page/404.vue'), - // name: 'Page404', - // meta: { title: '404', noCache: true } - // } - // ] - // }, + { + path: '/error', + component: Layout, + redirect: 'noRedirect', + name: 'ErrorPages', + meta: { + title: 'Error Pages', + icon: '404' + }, + children: [ + { + path: '401', + component: () => import('@/views/error-page/401.vue'), + name: 'Page401', + meta: { title: '401', noCache: true } + }, + { + path: '404', + component: () => import('@/views/error-page/404.vue'), + name: 'Page404', + meta: { title: '404', noCache: true } + } + ] + }, { path: '/error-log', @@ -250,7 +250,7 @@ export const asyncRoutes:RouteRecordRaw[] = [ path: 'log', component: () => import('@/views/error-log/index.vue'), name: 'ErrorLog', - meta: { title: '消息', icon: 'bug' } + meta: { title: 'Error Log', icon: 'bug' } } ] }, @@ -261,7 +261,7 @@ export const asyncRoutes:RouteRecordRaw[] = [ redirect: '/excel/export-excel', name: 'Excel', meta: { - title: '申请和审批', + title: 'Excel', icon: 'excel' }, children: [ @@ -269,63 +269,63 @@ export const asyncRoutes:RouteRecordRaw[] = [ path: 'export-excel', component: () => import('@/views/excel/export-excel.vue'), name: 'ExportExcel', - meta: { title: '提交申请' } + meta: { title: 'Export Excel' } }, { path: 'export-selected-excel', component: () => import('@/views/excel/select-excel.vue'), name: 'SelectExcel', - meta: { title: '我的审批' } + meta: { title: 'Export Selected' } }, { path: 'export-merge-header', component: () => import('@/views/excel/merge-header.vue'), name: 'MergeHeader', - meta: { title: '记录查询' } + meta: { title: 'Merge Header' } + }, + { + path: 'upload-excel', + component: () => import('@/views/excel/upload-excel.vue'), + name: 'UploadExcel', + meta: { title: 'Upload Excel' } } - // { - // path: 'upload-excel', - // component: () => import('@/views/excel/upload-excel.vue'), - // name: 'UploadExcel', - // meta: { title: 'Upload Excel' } - // } ] }, - // { - // path: '/zip', - // component: Layout, - // redirect: '/zip/download', - // name: 'Zip', - // meta: { alwaysShow: true, title: 'Zip', icon: 'zip' }, - // children: [ - // { - // path: 'download', - // component: () => import('@/views/zip/index.vue'), - // name: 'ExportZip', - // meta: { title: 'Export Zip' } - // } - // ] - // }, + { + path: '/zip', + component: Layout, + redirect: '/zip/download', + name: 'Zip', + meta: { alwaysShow: true, title: 'Zip', icon: 'zip' }, + children: [ + { + path: 'download', + component: () => import('@/views/zip/index.vue'), + name: 'ExportZip', + meta: { title: 'Export Zip' } + } + ] + }, - // { - // path: '/pdf', - // component: Layout, - // redirect: '/pdf/index', - // children: [ - // { - // path: 'index', - // component: () => import('@/views/pdf/index.vue'), - // name: 'PDF', - // meta: { title: 'PDF', icon: 'pdf' } - // } - // ] - // }, - // { - // path: '/pdf/download', - // component: () => import('@/views/pdf/download.vue'), - // meta: { hidden: true } - // }, + { + path: '/pdf', + component: Layout, + redirect: '/pdf/index', + children: [ + { + path: 'index', + component: () => import('@/views/pdf/index.vue'), + name: 'PDF', + meta: { title: 'PDF', icon: 'pdf' } + } + ] + }, + { + path: '/pdf/download', + component: () => import('@/views/pdf/download.vue'), + meta: { hidden: true } + }, { path: '/theme', @@ -335,65 +335,65 @@ export const asyncRoutes:RouteRecordRaw[] = [ path: 'index', component: () => import('@/views/theme/index.vue'), name: 'Theme', - meta: { title: '个人信息管理', icon: 'theme' } + meta: { title: 'Theme', icon: 'theme' } } ] }, - // { - // path: '/clipboard', - // component: Layout, - // children: [ - // { - // path: 'index', - // component: () => import('@/views/clipboard/index.vue'), - // name: 'ClipboardDemo', - // meta: { title: 'Clipboard', icon: 'clipboard' } - // } - // ] - // }, + { + path: '/clipboard', + component: Layout, + children: [ + { + path: 'index', + component: () => import('@/views/clipboard/index.vue'), + name: 'ClipboardDemo', + meta: { title: 'Clipboard', icon: 'clipboard' } + } + ] + }, - // { - // path: '/external-link', - // component: Layout, - // children: [ - // { - // path: 'https://element-plus.midfar.com', - // meta: { title: 'External Link', icon: 'link' }, - // redirect: '' - // } - // ] - // }, - // - // { - // path: '/my-demo', - // component: Layout, - // name: 'MyDemo', - // meta: { - // title: 'MyDemo', - // icon: 'component' - // }, - // children: [ - // { - // path: 'element-demo', - // component: () => import('@/views/mydemo/ElementDemo.vue'), - // name: 'ElementDemo', - // meta: { title: 'ElementDemo', icon: 'skill' } - // }, - // { - // path: 'store-demo', - // component: () => import('@/views/mydemo/StoreDemo.vue'), - // name: 'StoreDemo', - // meta: { title: 'StoreDemo', icon: 'lock' } - // }, - // { - // path: 'webSocket-demo', - // component: () => import('@/views/mydemo/WebSocketDemo.vue'), - // name: 'WebSocketDemo', - // meta: { title: 'WebSocketDemo', icon: 'lock' } - // } - // ] - // }, + { + path: '/external-link', + component: Layout, + children: [ + { + path: 'https://element-plus.midfar.com', + meta: { title: 'External Link', icon: 'link' }, + redirect: '' + } + ] + }, + + { + path: '/my-demo', + component: Layout, + name: 'MyDemo', + meta: { + title: 'MyDemo', + icon: 'component' + }, + children: [ + { + path: 'element-demo', + component: () => import('@/views/mydemo/ElementDemo.vue'), + name: 'ElementDemo', + meta: { title: 'ElementDemo', icon: 'skill' } + }, + { + path: 'store-demo', + component: () => import('@/views/mydemo/StoreDemo.vue'), + name: 'StoreDemo', + meta: { title: 'StoreDemo', icon: 'lock' } + }, + { + path: 'webSocket-demo', + component: () => import('@/views/mydemo/WebSocketDemo.vue'), + name: 'WebSocketDemo', + meta: { title: 'WebSocketDemo', icon: 'lock' } + } + ] + }, // 404 page must be placed at the end !!! { path: '/:pathMatch(.*)*', redirect: '/404', meta: { hidden: true }} diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 5551c1b..92f96e8 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -56,7 +56,7 @@ export default defineStore({ }, generateRoutes(roles: string[]) { let accessedRoutes; - if (roles.includes('admin')) { + if (roles.includes('teacher_user')) { accessedRoutes = asyncRoutes || []; } else { accessedRoutes = filterAsyncRoutes(asyncRoutes, roles); diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 0a421b4..f08410c 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { login as apiLogin, logout as apiLogout, getInfo as apiGetInfo } from '@/api/user'; +import {login as apiLogin, logout as apiLogout, getInfo as apiGetInfo, } from '@/api/user'; import { getToken, setToken, removeToken } from '@/utils/auth'; import router, { resetRouter } from '@/router'; import tagsViewStore from './tagsView'; @@ -16,26 +16,52 @@ export interface IUserState { export default defineStore({ id: 'user', - state: ():IUserState => ({ + state: ():{ + address: string; + signature: string; + sex: string; + roles: any[]; + description: string; + avatar: string; + token: any; + phone: string; + nickname: string; + id: string; + email: string; + age: string; + username: string + } => ({ token: getToken(), - userId: '', - name: '', - avatar: '', - introduction: '', - roles: [] + id:'', + username:'', + address:'', + phone:'', + email:'', + age:'', + signature:'', + avatar:'', + nickname:'', + sex:'', + description:'', + roles:['admin'] }), getters: {}, actions: { // user login - login({ commit }, userInfo):Promise { + + + login(userInfo):Promise { const { username, password } = userInfo; return new Promise((resolve, reject) => { - apiLogin({ username: username.trim(), password: password }).then(response => { + apiLogin({ user: username.trim(), password: password }).then(response => { const { data } = response; - commit('SET_TOKEN', data.token); + this.token = data.token; setToken(data.token); + router.push('/') resolve(); + console.log('2222',response) }).catch(error => { + console.log('3333',error) reject(error); }); }); @@ -46,22 +72,28 @@ export default defineStore({ return new Promise((resolve, reject) => { apiGetInfo(this.token).then(response => { const { data } = response; - + console.log('66666',data) if (!data) { reject('Verification failed, please Login again.'); } - - const { roles, name, avatar, introduction } = data; - + const { id,username,address,phone,email,age,signature,avatar,nickname,sex,description,roles } = data; // roles must be a non-empty array if (!roles || roles.length <= 0) { reject('getInfo: roles must be a non-null array!'); } - - this.roles = roles; - this.name = name; + this.id = id; + // this.roles = roles; + // this.roles =['admin']; + this.username = username; this.avatar = avatar; - this.introduction = introduction; + this.description = description; + this.sex = sex; + this.age = age; + this.address = address; + this.phone = phone; + this.email = email; + this.signature = signature; + this.nickname = nickname; resolve(data); }).catch(error => { reject(error); diff --git a/src/utils/request.js b/src/utils/request.js index f12aac3..9a920c7 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,11 +2,12 @@ import axios from 'axios'; import store from '@/store'; import { getToken } from '@/utils/auth'; +const BaseURL ='https://nbxt.oa.x-lf.cn' // create an axios instance const service = axios.create({ - baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url + baseURL: BaseURL, // url = base url + request url // withCredentials: true, // send cookies when cross-domain requests - timeout: 5000 // request timeout + timeout: 10000 // request timeout }); const service2 = axios.create({ @@ -24,7 +25,7 @@ service.interceptors.request.use( // let each request carry token // ['X-Token'] is a custom headers key // please modify it according to the actual situation - config.headers['X-Token'] = getToken(); + config.headers['token'] = getToken(); } return config; }, @@ -49,9 +50,9 @@ service.interceptors.response.use( */ response => { const res = response.data; - + console.log('999999',res) // if the custom code is not 20000, it is judged as an error. - if (res.code !== 20000) { + if (res.code !== 20000 && res.code !== 200) { ElMessage({ message: res.message || 'Error', type: 'error', diff --git a/src/utils/validate.ts b/src/utils/validate.ts index 32ab3c1..9ad5080 100644 --- a/src/utils/validate.ts +++ b/src/utils/validate.ts @@ -15,7 +15,7 @@ export function isExternal(path) { * @returns {Boolean} */ export function validUsername(str) { - const valid_map = ['admin', 'editor']; + const valid_map = ['admin', 'editor', 'teacher_user']; return valid_map.indexOf(str.trim()) >= 0; } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index ac2a7d6..145d3ef 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -30,7 +30,7 @@ - 登录 + Login
@@ -65,6 +65,7 @@ import SocialSign from './components/SocialSignin.vue'; import type { FormItemRule } from 'element-plus'; import type { IForm } from '@/types/element-plus'; import store from '@/store'; + export default defineComponent({ name: 'Login', components: { SocialSign }, @@ -85,7 +86,7 @@ export default defineComponent({ }; return { loginForm: { - username: 'teacher_demo', + username: 'teacher_user', password: '123456' }, loginRules: { @@ -144,7 +145,7 @@ export default defineComponent({ (this.$refs.loginForm as IForm).validate(valid => { if (valid) { this.loading = true; - this.$store.dispatch("login", this.loginForm) + store.user().login(this.loginForm) .then(() => { this.$router.push({ path: this.redirect || '/', query: this.otherQuery }); this.loading = false; @@ -166,6 +167,24 @@ export default defineComponent({ return acc; }, {}); } + // afterQRScan() { + // if (e.key === 'x-admin-oauth-code') { + // const code = getQueryObject(e.newValue) + // const codeMap = { + // wechat: 'code', + // tencent: 'code' + // } + // const type = codeMap[this.auth_type] + // const codeName = code[type] + // if (codeName) { + // store.user().LoginByThirdparty(codeName).then(() => { + // this.$router.push({ path: this.redirect || '/' }) + // }) + // } else { + // alert('第三方登录失败') + // } + // } + // } } }); diff --git a/vite.config.js b/vite.config.js index afec140..2f29647 100644 --- a/vite.config.js +++ b/vite.config.js @@ -65,13 +65,12 @@ export default defineConfig(({ command, mode }) => { host: 'localhost', port: 8001, proxy: { - '/api-test': { - target: 'https://api.midfar.com/dspt_test/api', + '/api-prod': { + target: 'https://nbxt.oa.x-lf.cn', changeOrigin: true, - rewrite: (path) => path.replace(/^\/api-test/, '') - }, - headers: { - Cookie: env.VUE_APP_COOKIE + pathRewrite: { + '^/api-prod': '' + } } } }