diff --git a/healthlink-his-mobile/.gitignore b/healthlink-his-mobile/.gitignore index c2458765e..ef1ea7305 100644 --- a/healthlink-his-mobile/.gitignore +++ b/healthlink-his-mobile/.gitignore @@ -3,3 +3,4 @@ dist/ .env.local .env.*.local *.log +package-lock.json diff --git a/healthlink-his-mobile/src/api/index.js b/healthlink-his-mobile/src/api/index.js index 2eb812550..30065b7b6 100644 --- a/healthlink-his-mobile/src/api/index.js +++ b/healthlink-his-mobile/src/api/index.js @@ -7,17 +7,17 @@ const request = axios.create({ }) request.interceptors.request.use(config => { - const token = localStorage.getItem('token') - if (token) config.headers.Authorization = `Bearer ${token}` - const tenantId = localStorage.getItem('tenantId') - if (tenantId) config.headers['tenant-id'] = tenantId + const token = localStorage.getItem('Admin-Token') + if (token && !(config.headers && config.headers.isToken === false)) { + config.headers.Authorization = 'Bearer ' + token + } return config }) request.interceptors.response.use( res => { if (res.data?.code === 401) { - localStorage.removeItem('token') + localStorage.removeItem('Admin-Token') window.location.href = '/login' return Promise.reject(new Error('登录已过期')) } @@ -25,18 +25,16 @@ request.interceptors.response.use( }, err => { if (err.response?.status === 401) { - localStorage.removeItem('token') + localStorage.removeItem('Admin-Token') window.location.href = '/login' } - ElMessage.error(err.response?.data?.msg || '请求失败') return Promise.reject(err) } ) export const authApi = { - login: (data) => request.post('/login', data), - getTenants: () => request.get('/tenant/list'), - logout: () => request.post('/logout') + login: (data) => request.post('/login', data, { headers: { isToken: false } }), + getTenants: (username) => request.get('/system/tenant/user-bind/' + username, { headers: { isToken: false } }) } export const nursingApi = { diff --git a/healthlink-his-mobile/src/router/index.js b/healthlink-his-mobile/src/router/index.js index 4075999db..6d3175a3a 100644 --- a/healthlink-his-mobile/src/router/index.js +++ b/healthlink-his-mobile/src/router/index.js @@ -17,7 +17,7 @@ const router = createRouter({ history: createWebHistory(), routes }) router.beforeEach((to, from, next) => { if (to.meta.requiresAuth) { - const token = localStorage.getItem('token') + const token = localStorage.getItem('Admin-Token') if (!token) { next('/login'); return } } next() diff --git a/healthlink-his-mobile/src/views/Login.vue b/healthlink-his-mobile/src/views/Login.vue index 8ce499626..db00df726 100644 --- a/healthlink-his-mobile/src/views/Login.vue +++ b/healthlink-his-mobile/src/views/Login.vue @@ -7,78 +7,78 @@
+ + +
+
-
- - -
- +
+
{{ errorMsg }}
diff --git a/healthlink-his-mobile/src/views/Mine.vue b/healthlink-his-mobile/src/views/Mine.vue index fecb50355..100261431 100644 --- a/healthlink-his-mobile/src/views/Mine.vue +++ b/healthlink-his-mobile/src/views/Mine.vue @@ -22,7 +22,7 @@ import { ElMessageBox } from 'element-plus' const logout = async () => { try { await ElMessageBox.confirm('确认退出登录?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消' }) - localStorage.removeItem('token') + localStorage.removeItem('Admin-Token') window.location.href = '/login' } catch {} }