新增:token登录方式
This commit is contained in:
@@ -15,6 +15,11 @@ export const routes = [
|
|||||||
component: () => import('@/views/passport/login/index.vue'),
|
component: () => import('@/views/passport/login/index.vue'),
|
||||||
meta: { title: '登录' }
|
meta: { title: '登录' }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/token-login',
|
||||||
|
component: () => import('@/views/passport/loginToken/index.vue'),
|
||||||
|
meta: { title: 'token登录' }
|
||||||
|
},
|
||||||
// {
|
// {
|
||||||
// path: '/forget',
|
// path: '/forget',
|
||||||
// component: () => import('@/views/passport/forget/index.vue'),
|
// component: () => import('@/views/passport/forget/index.vue'),
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export function openSpmUrl(path: string, d?: any, id = 0): void {
|
|||||||
|
|
||||||
// 跳转页面
|
// 跳转页面
|
||||||
url.value = `${domain}${path}${spm.value}${token.value}`;
|
url.value = `${domain}${path}${spm.value}${token.value}`;
|
||||||
console.log(url.value,'domain>>>>');
|
console.log(url.value, 'domain>>>>');
|
||||||
window.open(`${url.value}`);
|
window.open(`${url.value}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,3 +396,23 @@ export const getPageTitle = () => {
|
|||||||
const { title } = meta;
|
const { title } = meta;
|
||||||
return title;
|
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