新增:token登录方式
This commit is contained in:
@@ -15,6 +15,11 @@ export const routes = [
|
||||
component: () => import('@/views/passport/login/index.vue'),
|
||||
meta: { title: '登录' }
|
||||
},
|
||||
{
|
||||
path: '/token-login',
|
||||
component: () => import('@/views/passport/loginToken/index.vue'),
|
||||
meta: { title: 'token登录' }
|
||||
},
|
||||
// {
|
||||
// path: '/forget',
|
||||
// component: () => import('@/views/passport/forget/index.vue'),
|
||||
|
||||
@@ -396,3 +396,23 @@ export const getPageTitle = () => {
|
||||
const { title } = meta;
|
||||
return title;
|
||||
};
|
||||
|
||||
/**
|
||||
* 提取传参中的ID
|
||||
* param 12334.html
|
||||
* return 1234
|
||||
* @param index
|
||||
*/
|
||||
export const getIdBySpm = (index: number) => {
|
||||
console.log('split', router.currentRoute.value.query.spm);
|
||||
const split = String(router.currentRoute.value.query.spm).split('.');
|
||||
console.log(split);
|
||||
return split[index];
|
||||
};
|
||||
|
||||
/**
|
||||
* 提取传参中的token
|
||||
*/
|
||||
export const getTokenBySpm = () => {
|
||||
return JSON.parse(router.currentRoute.value.query.token);
|
||||
};
|
||||
|
||||
16
src/views/passport/loginToken/index.vue
Normal file
16
src/views/passport/loginToken/index.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getIdBySpm, getTokenBySpm, push } from '@/utils/common';
|
||||
import { setToken } from '@/utils/token-util';
|
||||
|
||||
if (getTokenBySpm()) {
|
||||
setToken(getTokenBySpm(), true);
|
||||
localStorage.setItem('TenantId', String(getIdBySpm(2)));
|
||||
localStorage.setItem('UserId', String(getIdBySpm(1)));
|
||||
push('/');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
||||
Reference in New Issue
Block a user