[tag] 完善了登录功能
This commit is contained in:
parent
e5e12f2b63
commit
84b54a02a4
|
|
@ -17,7 +17,7 @@ withDefaults(defineProps<Props>(), {
|
|||
|
||||
<template>
|
||||
<RouterLink to="/" class="w-full flex-center nowrap-hidden">
|
||||
<SystemLogo class="text-32px text-primary" />
|
||||
<!-- <SystemLogo class="text-32px text-primary" /> -->
|
||||
<h2 v-show="showTitle" class="pl-8px text-16px text-primary font-bold transition duration-300 ease-in-out">
|
||||
{{ $t('system.title') }}
|
||||
</h2>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const local: App.I18n.Schema = {
|
||||
system: {
|
||||
title: '后台管理系统',
|
||||
title: '智慧水务后台管理系统',
|
||||
updateTitle: '系统版本更新通知',
|
||||
updateContent: '检测到系统有新版本发布,是否立即刷新页面?',
|
||||
updateConfirm: '立即刷新',
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export function fetchLogin(username: string, password: string) {
|
|||
|
||||
/** Get user info */
|
||||
export function fetchGetUserInfo() {
|
||||
return request<Api.Auth.UserInfo>({ url: '/auth/getUserInfo' });
|
||||
return request<Api.Auth.UserInfo>({ url: '/employees/getUserInfo' });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -63,11 +63,16 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|||
async function login(userName: string, password: string, redirect = true) {
|
||||
startLoading();
|
||||
|
||||
const { data: loginToken, error } = await fetchLogin(userName, password);
|
||||
console.log(loginToken)
|
||||
const { response, error } = await fetchLogin(userName, password);
|
||||
|
||||
if (!error) {
|
||||
const pass = await loginByToken(loginToken);
|
||||
console.log(response)
|
||||
|
||||
let accessToken = response.data.token;
|
||||
let loginToken: Api.Auth.LoginToken = { token: accessToken, refreshToken: "" };
|
||||
let userId = response.data.employeeId
|
||||
|
||||
if (1) {
|
||||
const pass = await loginByToken(loginToken,userId);
|
||||
|
||||
if (pass) {
|
||||
await redirectFromLogin(redirect);
|
||||
|
|
@ -84,7 +89,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|||
endLoading();
|
||||
}
|
||||
|
||||
async function loginByToken(loginToken: Api.Auth.LoginToken) {
|
||||
async function loginByToken(loginToken: Api.Auth.LoginToken,id:number) {
|
||||
// 1. stored in the localStorage, the later requests need it in headers
|
||||
localStg.set('token', loginToken.token);
|
||||
localStg.set('refreshToken', loginToken.refreshToken);
|
||||
|
|
@ -102,10 +107,18 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|||
}
|
||||
|
||||
async function getUserInfo() {
|
||||
const { data: info, error } = await fetchGetUserInfo();
|
||||
const { response, error } = await fetchGetUserInfo();
|
||||
let data:any = response.data.data
|
||||
console.log(data.name)
|
||||
console.log(error?.status == 200)
|
||||
|
||||
if (!error) {
|
||||
// update store
|
||||
if (error?.status == 200) {
|
||||
let info: Api.Auth.UserInfo = {
|
||||
userId: data.employeeId.toString(),
|
||||
userName: data.name,
|
||||
roles: [data.position],
|
||||
buttons: []
|
||||
};
|
||||
Object.assign(userInfo, info);
|
||||
|
||||
return true;
|
||||
|
|
@ -116,7 +129,6 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|||
|
||||
async function initUserInfo() {
|
||||
const hasToken = getToken();
|
||||
|
||||
if (hasToken) {
|
||||
const pass = await getUserInfo();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ import CreativityBanner from './modules/creativity-banner.vue';
|
|||
<template>
|
||||
<ASpace direction="vertical" :size="16">
|
||||
<HeaderBanner />
|
||||
<CardData />
|
||||
<!-- <CardData /> -->
|
||||
<!--
|
||||
<ARow :gutter="[16, 16]">
|
||||
<ACol :span="24" :lg="14">
|
||||
<LineChart />
|
||||
|
|
@ -18,14 +19,17 @@ import CreativityBanner from './modules/creativity-banner.vue';
|
|||
<ACol :span="24" :lg="10">
|
||||
<PieChart />
|
||||
</ACol>
|
||||
</ARow>
|
||||
</ARow>
|
||||
-->
|
||||
<ARow :gutter="[16, 16]">
|
||||
<ACol :span="24" :lg="14">
|
||||
<ProjectNews />
|
||||
</ACol>
|
||||
<!--
|
||||
<ACol :span="24" :lg="10">
|
||||
<CreativityBanner />
|
||||
</ACol>
|
||||
-->
|
||||
</ARow>
|
||||
</ASpace>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export default defineConfig(configEnv => {
|
|||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 9527,
|
||||
open: true,
|
||||
open: false,
|
||||
proxy: createViteProxy(viteEnv, enableProxy)
|
||||
},
|
||||
preview: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue