diff --git a/src/api/login/index.ts b/src/api/login/index.ts index d342031..0fdfba3 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -14,56 +14,60 @@ export interface SmsLoginVO { // 登录 export const login = (data: UserLoginVO) => { - return request.post({ url: '/system/auth/login', data }) + return request.post({ url: '/admin-api/system/auth/login', data }) } // 刷新访问令牌 export const refreshToken = () => { - return request.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() }) + return request.post({ + url: '/admin-api/system/auth/refresh-token?refreshToken=' + getRefreshToken() + }) } // 使用租户名,获得租户编号 export const getTenantIdByName = (name: string) => { - return request.get({ url: '/system/tenant/get-id-by-name?name=' + name }) + return request.get({ url: '/admin-api/system/tenant/get-id-by-name?name=' + name }) } // 登出 export const loginOut = () => { - return request.post({ url: '/system/auth/logout' }) + return request.post({ url: '/admin-api/system/auth/logout' }) } // 获取用户权限信息 export const getInfo = (data) => { - return request.get({ url: '/system/auth/get-permission-info', data }) + return request.get({ url: '/admin-api/system/auth/get-permission-info', data }) } //获取登录验证码 export const sendSmsCode = (data: SmsCodeVO) => { - return request.post({ url: '/system/auth/send-sms-code', data }) + return request.post({ url: '/admin-api/system/auth/send-sms-code', data }) } // 短信验证码登录 export const smsLogin = (data: SmsLoginVO) => { - return request.post({ url: '/system/auth/sms-login', data }) + return request.post({ url: '/admin-api/system/auth/sms-login', data }) } // 社交授权的跳转 export const socialAuthRedirect = (type: number, redirectUri: string) => { return request.get({ - url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri + url: '/admin-api/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri }) } // 获取验证图片以及 token export const getCode = (data) => { - return request.postOriginal({ url: 'system/captcha/get', data }) + return request.postOriginal({ url: '/admin-api/system/captcha/get', data }) } // 滑动或者点选验证 export const reqCheck = (data) => { - return request.postOriginal({ url: 'system/captcha/check', data }) + return request.postOriginal({ url: '/admin-api/system/captcha/check', data }) } // 获取应用信息 export const getAppInfo = (instanceId: number) => { - return request.get({ url: 'system/serviceInstance/getInstanceInfo?instanceId=' + instanceId }) + return request.get({ + url: '/admin-api/system/serviceInstance/getInstanceInfo?instanceId=' + instanceId + }) } diff --git a/src/api/login/oauth2/index.ts b/src/api/login/oauth2/index.ts index aef1820..cc95188 100644 --- a/src/api/login/oauth2/index.ts +++ b/src/api/login/oauth2/index.ts @@ -2,7 +2,7 @@ import request from '@/config/axios' // 获得授权信息 export const getAuthorize = (clientId: string) => { - return request.get({ url: '/system/oauth2/authorize?clientId=' + clientId }) + return request.get({ url: '/admin-api/system/oauth2/authorize?clientId=' + clientId }) } // 发起授权 @@ -25,7 +25,7 @@ export const authorize = ( } // 发起请求 return request.post({ - url: '/system/oauth2/authorize', + url: '/admin-api/system/oauth2/authorize', headers: { 'Content-type': 'application/x-www-form-urlencoded' }, diff --git a/src/api/system/dept/index.ts b/src/api/system/dept/index.ts index 161ff68..070d46b 100644 --- a/src/api/system/dept/index.ts +++ b/src/api/system/dept/index.ts @@ -14,30 +14,30 @@ export interface DeptVO { // 查询部门(精简)列表 export const getSimpleDeptList = async (): Promise => { - return await request.get({ url: '/system/dept/list-all-simple' }) + return await request.get({ url: '/admin-api/system/dept/list-all-simple' }) } // 查询部门列表 export const getDeptPage = async (params) => { - return await request.get({ url: '/system/dept/list', params }) + return await request.get({ url: '/admin-api/system/dept/list', params }) } // 查询部门详情 export const getDept = async (id: number) => { - return await request.get({ url: '/system/dept/get?id=' + id }) + return await request.get({ url: '/admin-api/system/dept/get?id=' + id }) } // 新增部门 export const createDept = async (data: DeptVO) => { - return await request.post({ url: '/system/dept/create', data: data }) + return await request.post({ url: '/admin-api/system/dept/create', data: data }) } // 修改部门 export const updateDept = async (params: DeptVO) => { - return await request.put({ url: '/system/dept/update', data: params }) + return await request.put({ url: '/admin-api/system/dept/update', data: params }) } // 删除部门 export const deleteDept = async (id: number) => { - return await request.delete({ url: '/system/dept/delete?id=' + id }) + return await request.delete({ url: '/admin-api/system/dept/delete?id=' + id }) } diff --git a/src/api/system/dict/dict.data.ts b/src/api/system/dict/dict.data.ts index 87e7dce..7d42625 100644 --- a/src/api/system/dict/dict.data.ts +++ b/src/api/system/dict/dict.data.ts @@ -15,35 +15,35 @@ export type DictDataVO = { // 查询字典数据(精简)列表 export const listSimpleDictData = () => { - return request.get({ url: '/system/dict-data/list-all-simple' }) + return request.get({ url: '/admin-api/system/dict-data/list-all-simple' }) } // 查询字典数据列表 export const getDictDataPage = (params: PageParam) => { - return request.get({ url: '/system/dict-data/page', params }) + return request.get({ url: '/admin-api/system/dict-data/page', params }) } // 查询字典数据详情 export const getDictData = (id: number) => { - return request.get({ url: '/system/dict-data/get?id=' + id }) + return request.get({ url: '/admin-api/system/dict-data/get?id=' + id }) } // 新增字典数据 export const createDictData = (data: DictDataVO) => { - return request.post({ url: '/system/dict-data/create', data }) + return request.post({ url: '/admin-api/system/dict-data/create', data }) } // 修改字典数据 export const updateDictData = (data: DictDataVO) => { - return request.put({ url: '/system/dict-data/update', data }) + return request.put({ url: '/admin-api/system/dict-data/update', data }) } // 删除字典数据 export const deleteDictData = (id: number) => { - return request.delete({ url: '/system/dict-data/delete?id=' + id }) + return request.delete({ url: '/admin-api/system/dict-data/delete?id=' + id }) } // 导出字典类型数据 export const exportDictData = (params) => { - return request.get({ url: '/system/dict-data/export', params }) + return request.get({ url: '/admin-api/system/dict-data/export', params }) } diff --git a/src/api/system/dict/dict.type.ts b/src/api/system/dict/dict.type.ts index ed2969f..9bb50af 100644 --- a/src/api/system/dict/dict.type.ts +++ b/src/api/system/dict/dict.type.ts @@ -11,34 +11,34 @@ export type DictTypeVO = { // 查询字典(精简)列表 export const getSimpleDictTypeList = () => { - return request.get({ url: '/system/dict-type/list-all-simple' }) + return request.get({ url: '/admin-api/system/dict-type/list-all-simple' }) } // 查询字典列表 export const getDictTypePage = (params: PageParam) => { - return request.get({ url: '/system/dict-type/page', params }) + return request.get({ url: '/admin-api/system/dict-type/page', params }) } // 查询字典详情 export const getDictType = (id: number) => { - return request.get({ url: '/system/dict-type/get?id=' + id }) + return request.get({ url: '/admin-api/system/dict-type/get?id=' + id }) } // 新增字典 export const createDictType = (data: DictTypeVO) => { - return request.post({ url: '/system/dict-type/create', data }) + return request.post({ url: '/admin-api/system/dict-type/create', data }) } // 修改字典 export const updateDictType = (data: DictTypeVO) => { - return request.put({ url: '/system/dict-type/update', data }) + return request.put({ url: '/admin-api/system/dict-type/update', data }) } // 删除字典 export const deleteDictType = (id: number) => { - return request.delete({ url: '/system/dict-type/delete?id=' + id }) + return request.delete({ url: '/admin-api/system/dict-type/delete?id=' + id }) } // 导出字典类型 export const exportDictType = (params) => { - return request.get({ url: '/system/dict-type/export', params }) + return request.get({ url: '/admin-api/system/dict-type/export', params }) } diff --git a/src/api/system/menu/index.ts b/src/api/system/menu/index.ts index 4bb9a87..0dbadd5 100644 --- a/src/api/system/menu/index.ts +++ b/src/api/system/menu/index.ts @@ -20,30 +20,30 @@ export interface MenuVO { // 查询菜单(精简)列表 export const getSimpleMenusList = () => { - return request.get({ url: '/system/menu/list-all-simple' }) + return request.get({ url: '/admin-api/system/menu/list-all-simple' }) } // 查询菜单列表 export const getMenuList = (params) => { - return request.get({ url: '/system/menu/list', params }) + return request.get({ url: '/admin-api/system/menu/list', params }) } // 获取菜单详情 export const getMenu = (id: number) => { - return request.get({ url: '/system/menu/get?id=' + id }) + return request.get({ url: '/admin-api/system/menu/get?id=' + id }) } // 新增菜单 export const createMenu = (data: MenuVO) => { - return request.post({ url: '/system/menu/create', data }) + return request.post({ url: '/admin-api/system/menu/create', data }) } // 修改菜单 export const updateMenu = (data: MenuVO) => { - return request.put({ url: '/system/menu/update', data }) + return request.put({ url: '/admin-api/system/menu/update', data }) } // 删除菜单 export const deleteMenu = (id: number) => { - return request.delete({ url: '/system/menu/delete?id=' + id }) + return request.delete({ url: '/admin-api/system/menu/delete?id=' + id }) } diff --git a/src/api/system/notify/message/index.ts b/src/api/system/notify/message/index.ts index 29036b9..07b6730 100644 --- a/src/api/system/notify/message/index.ts +++ b/src/api/system/notify/message/index.ts @@ -17,32 +17,34 @@ export interface NotifyMessageVO { // 查询站内信消息列表 export const getNotifyMessagePage = async (params: PageParam) => { - return await request.get({ url: '/system/notify-message/page', params }) + return await request.get({ url: '/admin-api/system/notify-message/page', params }) } // 获得我的站内信分页 export const getMyNotifyMessagePage = async (params: PageParam) => { - return await request.get({ url: '/system/notify-message/my-page', params }) + return await request.get({ url: '/admin-api/system/notify-message/my-page', params }) } // 批量标记已读 export const updateNotifyMessageRead = async (ids) => { return await request.put({ - url: '/system/notify-message/update-read?' + qs.stringify({ ids: ids }, { indices: false }) + url: + '/admin-api/system/notify-message/update-read?' + + qs.stringify({ ids: ids }, { indices: false }) }) } // 标记所有站内信为已读 export const updateAllNotifyMessageRead = async () => { - return await request.put({ url: '/system/notify-message/update-all-read' }) + return await request.put({ url: '/admin-api/system/notify-message/update-all-read' }) } // 获取当前用户的最新站内信列表 export const getUnreadNotifyMessageList = async () => { - return await request.get({ url: '/system/notify-message/get-unread-list' }) + return await request.get({ url: '/admin-api/system/notify-message/get-unread-list' }) } // 获得当前用户的未读站内信数量 export const getUnreadNotifyMessageCount = async () => { - return await request.get({ url: '/system/notify-message/get-unread-count' }) + return await request.get({ url: '/admin-api/system/notify-message/get-unread-count' }) } diff --git a/src/api/system/permission/index.ts b/src/api/system/permission/index.ts index b3c7696..2a73d55 100644 --- a/src/api/system/permission/index.ts +++ b/src/api/system/permission/index.ts @@ -18,25 +18,25 @@ export interface PermissionAssignRoleDataScopeReqVO { // 查询角色拥有的菜单权限 export const getRoleMenuList = async (roleId: number) => { - return await request.get({ url: '/system/permission/list-role-menus?roleId=' + roleId }) + return await request.get({ url: '/admin-api/system/permission/list-role-menus?roleId=' + roleId }) } // 赋予角色菜单权限 export const assignRoleMenu = async (data: PermissionAssignRoleMenuReqVO) => { - return await request.post({ url: '/system/permission/assign-role-menu', data }) + return await request.post({ url: '/admin-api/system/permission/assign-role-menu', data }) } // 赋予角色数据权限 export const assignRoleDataScope = async (data: PermissionAssignRoleDataScopeReqVO) => { - return await request.post({ url: '/system/permission/assign-role-data-scope', data }) + return await request.post({ url: '/admin-api/system/permission/assign-role-data-scope', data }) } // 查询用户拥有的角色数组 export const getUserRoleList = async (userId: number) => { - return await request.get({ url: '/system/permission/list-user-roles?userId=' + userId }) + return await request.get({ url: '/admin-api/system/permission/list-user-roles?userId=' + userId }) } // 赋予用户角色 export const assignUserRole = async (data: PermissionAssignUserRoleReqVO) => { - return await request.post({ url: '/system/permission/assign-user-role', data }) + return await request.post({ url: '/admin-api/system/permission/assign-user-role', data }) } diff --git a/src/api/system/role/index.ts b/src/api/system/role/index.ts index d1a4428..0787876 100644 --- a/src/api/system/role/index.ts +++ b/src/api/system/role/index.ts @@ -19,30 +19,35 @@ export interface UpdateStatusReqVO { // 查询角色列表 export const getRolePage = async (params: PageParam) => { - return await request.get({ url: '/system/role/page', params }) + return await request.get({ url: '/admin-api/system/role/page', params }) } // 查询角色(精简)列表 export const getSimpleRoleList = async () => { - return await request.get({ url: '/system/role/list-all-simple' }) + return await request.get({ url: '/admin-api/system/role/list-all-simple' }) } // 查询角色详情 export const getRole = async (id: number) => { - return await request.get({ url: '/system/role/get?id=' + id }) + return await request.get({ url: '/admin-api/system/role/get?id=' + id }) } // 新增角色 export const createRole = async (data: RoleVO) => { - return await request.post({ url: '/system/role/create', data }) + return await request.post({ url: '/admin-api/system/role/create', data }) } // 修改角色 export const updateRole = async (data: RoleVO) => { - return await request.put({ url: '/system/role/update', data }) + return await request.put({ url: '/admin-api/system/role/update', data }) } // 删除角色 export const deleteRole = async (id: number) => { - return await request.delete({ url: '/system/role/delete?id=' + id }) + return await request.delete({ url: '/admin-api/system/role/delete?id=' + id }) +} + +// 角色用户 +export const getRoleUsers = async (params) => { + return await request.get({ url: '/admin-api/system/role/getUserByRole', params }) } diff --git a/src/api/system/user/index.ts b/src/api/system/user/index.ts index 6224f0e..bbfa0e8 100644 --- a/src/api/system/user/index.ts +++ b/src/api/system/user/index.ts @@ -19,37 +19,37 @@ export interface UserVO { // 查询用户管理列表 export const getUserPage = (params: PageParam) => { - return request.get({ url: '/system/user/page', params }) + return request.get({ url: '/admin-api/system/user/page', params }) } // 查询用户详情 export const getUser = (id: number) => { - return request.get({ url: '/system/user/get?id=' + id }) + return request.get({ url: '/admin-api/system/user/get?id=' + id }) } // 新增用户 export const createUser = (data: UserVO) => { - return request.post({ url: '/system/user/create', data }) + return request.post({ url: '/admin-api/system/user/create', data }) } // 修改用户 export const updateUser = (data: UserVO) => { - return request.put({ url: '/system/user/update', data }) + return request.put({ url: '/admin-api/system/user/update', data }) } // 删除用户 export const deleteUser = (id: number) => { - return request.delete({ url: '/system/user/delete?id=' + id }) + return request.delete({ url: '/admin-api/system/user/delete?id=' + id }) } // 导出用户 export const exportUser = (params) => { - return request.download({ url: '/system/user/export', params }) + return request.download({ url: '/admin-api/system/user/export', params }) } // 下载用户导入模板 export const importUserTemplate = () => { - return request.download({ url: '/system/user/get-import-template' }) + return request.download({ url: '/admin-api/system/user/get-import-template' }) } // 用户密码重置 @@ -58,7 +58,7 @@ export const resetUserPwd = (id: number, password: string) => { id, password } - return request.put({ url: '/system/user/update-password', data: data }) + return request.put({ url: '/admin-api/system/user/update-password', data: data }) } // 用户状态修改 @@ -67,10 +67,10 @@ export const updateUserStatus = (id: number, status: number) => { id, status } - return request.put({ url: '/system/user/update-status', data: data }) + return request.put({ url: '/admin-api/system/user/update-status', data: data }) } // 获取用户精简信息列表 export const getSimpleUserList = (): Promise => { - return request.get({ url: '/system/user/list-all-simple' }) + return request.get({ url: '/admin-api/system/user/list-all-simple' }) } diff --git a/src/api/system/user/profile.ts b/src/api/system/user/profile.ts index b2623c8..e96d749 100644 --- a/src/api/system/user/profile.ts +++ b/src/api/system/user/profile.ts @@ -52,18 +52,18 @@ export interface UserProfileUpdateReqVO { // 查询用户个人信息 export const getUserProfile = () => { - return request.get({ url: '/system/user/profile/get' }) + return request.get({ url: '/admin-api/system/user/profile/get' }) } // 修改用户个人信息 export const updateUserProfile = (data: UserProfileUpdateReqVO) => { - return request.put({ url: '/system/user/profile/update', data }) + return request.put({ url: '/admin-api/system/user/profile/update', data }) } // 用户密码重置 export const updateUserPassword = (oldPassword: string, newPassword: string) => { return request.put({ - url: '/system/user/profile/update-password', + url: '/admin-api/system/user/profile/update-password', data: { oldPassword: oldPassword, newPassword: newPassword @@ -73,5 +73,5 @@ export const updateUserPassword = (oldPassword: string, newPassword: string) => // 用户头像上传 export const uploadAvatar = (data) => { - return request.upload({ url: '/system/user/profile/update-avatar', data: data }) + return request.upload({ url: '/admin-api/system/user/profile/update-avatar', data: data }) } diff --git a/src/api/system/user/socialUser.ts b/src/api/system/user/socialUser.ts index 79f4d40..e3f24a6 100644 --- a/src/api/system/user/socialUser.ts +++ b/src/api/system/user/socialUser.ts @@ -3,7 +3,7 @@ import request from '@/config/axios' // 社交绑定,使用 code 授权码 export const socialBind = (type, code, state) => { return request.post({ - url: '/system/social-user/bind', + url: '/admin-api/system/social-user/bind', data: { type, code, @@ -15,7 +15,7 @@ export const socialBind = (type, code, state) => { // 取消社交绑定 export const socialUnbind = (type, openid) => { return request.delete({ - url: '/system/social-user/unbind', + url: '/admin-api/system/social-user/unbind', data: { type, openid @@ -26,6 +26,6 @@ export const socialUnbind = (type, openid) => { // 社交授权的跳转 export const socialAuthRedirect = (type, redirectUri) => { return request.get({ - url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri + url: '/admin-api/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri }) } diff --git a/src/config/axios/config.ts b/src/config/axios/config.ts index 8116508..e0b2f1a 100644 --- a/src/config/axios/config.ts +++ b/src/config/axios/config.ts @@ -7,7 +7,7 @@ const config: { /** * api请求基础路径 */ - base_url: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL, + base_url: 'http://localhost' + import.meta.env.VITE_API_BASEPATH, /** * 接口成功返回状态码 */ diff --git a/src/config/axios/service.ts b/src/config/axios/service.ts index d42dee2..2cbf69d 100644 --- a/src/config/axios/service.ts +++ b/src/config/axios/service.ts @@ -9,7 +9,14 @@ import axios, { import { ElMessage, ElMessageBox, ElNotification } from 'element-plus' import qs from 'qs' import { config } from '@/config/axios/config' -import { getAccessToken, getRefreshToken, getTenantId, removeToken, setToken } from '@/utils/auth' +import { + getAccessToken, + getRefreshToken, + getTenantId, + getAppId, + removeToken, + setToken +} from '@/utils/auth' import errorCode from './errorCode' import { resetRouter } from '@/router' @@ -58,6 +65,13 @@ service.interceptors.request.use( if (tenantId) { ;(config as Recordable).headers['tenant-id'] = tenantId } + + // 设置实例 + const appId = getAppId() + if (appId) { + ;(config as Recordable).headers['instance-id'] = appId + } + const params = config.params || {} const data = config.data || false if ( @@ -225,12 +239,15 @@ const handleAuthorized = () => { type: 'warning' }).then(() => { const { wsCache } = useCache() + const tenantId = wsCache.get('TENANT_ID') + const appId = wsCache.get('App_ID') resetRouter() // 重置静态路由表 wsCache.clear() removeToken() isRelogin.show = false // 干掉token后再走一次路由让它过router.beforeEach的校验 - window.location.href = window.location.href + // window.location.href = window.location.href + window.location.href = `/login?tenantId=${tenantId}&appId=${appId}` }) } return Promise.reject(t('sys.api.timeoutMessage')) diff --git a/src/layout/components/Message/src/Message.vue b/src/layout/components/Message/src/Message.vue index 077da48..444e461 100644 --- a/src/layout/components/Message/src/Message.vue +++ b/src/layout/components/Message/src/Message.vue @@ -16,10 +16,9 @@ const getList = async () => { // 获得未读消息数 const getUnreadCount = async () => { - unreadCount.value = 9 - // NotifyMessageApi.getUnreadNotifyMessageCount().then((data) => { - // unreadCount.value = data - // }) + NotifyMessageApi.getUnreadNotifyMessageCount().then((data) => { + unreadCount.value = data + }) } // 跳转我的站内信 diff --git a/src/permission.js b/src/permission.js index 4ad7d25..f7089c3 100644 --- a/src/permission.js +++ b/src/permission.js @@ -7,6 +7,7 @@ import { usePageLoading } from '@/hooks/web/usePageLoading' import { useDictStoreWithOut } from '@/store/modules/dict' import { useUserStoreWithOut } from '@/store/modules/user' import { usePermissionStoreWithOut } from '@/store/modules/permission' +import { getTenantId, getAppId } from '@/utils/auth' const { start, done } = useNProgress() @@ -50,7 +51,13 @@ router.beforeEach(async (to, from, next) => { if (whiteList.indexOf(to.path) !== -1) { next() } else { - next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 + const tenantId = getTenantId() + const appId = getAppId() + if (tenantId && appId) { + next(`/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页 + } else { + next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 + } } } }) diff --git a/src/views/Basic/Role/Comp/RoleEmployee.vue b/src/views/Basic/Role/Comp/RoleEmployee.vue index 69d4908..0ea272e 100644 --- a/src/views/Basic/Role/Comp/RoleEmployee.vue +++ b/src/views/Basic/Role/Comp/RoleEmployee.vue @@ -20,7 +20,7 @@