新增:token登录方式

This commit is contained in:
2024-09-06 17:09:36 +08:00
parent 9438021a08
commit 42730a4429
3 changed files with 42 additions and 1 deletions

View File

@@ -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'),

View File

@@ -97,7 +97,7 @@ export function openSpmUrl(path: string, d?: any, id = 0): void {
// 跳转页面
url.value = `${domain}${path}${spm.value}${token.value}`;
console.log(url.value,'domain>>>>');
console.log(url.value, 'domain>>>>');
window.open(`${url.value}`);
}
@@ -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);
};

View 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>