Commit 73f2ac34 authored by jiaxu.yan's avatar jiaxu.yan

feat:文件类型声明

parent e0bd8504
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
export interface LoginParams { export interface LoginParams {
username: string; username: string;
password: string; password: string | boolean;
redirectUrl: string; redirectUrl: string;
redirectUri: string; redirectUri: string;
rememberMe: boolean; rememberMe: boolean;
...@@ -27,5 +27,15 @@ export interface LoginResultModel { ...@@ -27,5 +27,15 @@ export interface LoginResultModel {
* @description: Get user information return value * @description: Get user information return value
*/ */
export interface GetUserInfoModel { export interface GetUserInfoModel {
data: any; roles: RoleInfo[];
// 用户id
userId: string | number;
// 用户名
username: string;
// 真实名字
realName: string;
// 头像
avatar: string;
// 介绍
desc?: string;
} }
...@@ -98,7 +98,7 @@ export const useUserStore = defineStore({ ...@@ -98,7 +98,7 @@ export const useUserStore = defineStore({
// const { token } = data; // const { token } = data;
// save token // save token
// this.setToken(token); this.setToken('c061d9c2-a0f2-44c8-a869-cad99e9c1fea');
return this.afterLoginAction(goHome); return this.afterLoginAction(goHome);
} catch (error) { } catch (error) {
return Promise.reject(error); return Promise.reject(error);
...@@ -108,7 +108,6 @@ export const useUserStore = defineStore({ ...@@ -108,7 +108,6 @@ export const useUserStore = defineStore({
// if (!this.getToken) return null; // if (!this.getToken) return null;
// get user info // get user info
const userInfo = await this.getUserInfoAction(); const userInfo = await this.getUserInfoAction();
console.log(userInfo);
const sessionTimeout = this.sessionTimeout; const sessionTimeout = this.sessionTimeout;
if (sessionTimeout) { if (sessionTimeout) {
this.setSessionTimeout(false); this.setSessionTimeout(false);
...@@ -133,7 +132,6 @@ export const useUserStore = defineStore({ ...@@ -133,7 +132,6 @@ export const useUserStore = defineStore({
// if (!this.getToken) return null; // if (!this.getToken) return null;
const userInfo = await getUserInfo(); const userInfo = await getUserInfo();
const { data } = userInfo; const { data } = userInfo;
console.log(data);
// if (isArray(roles)) { // if (isArray(roles)) {
// const roleList = roles.map((item) => item.value) as RoleEnum[]; // const roleList = roles.map((item) => item.value) as RoleEnum[];
// this.setRoleList(roleList); // this.setRoleList(roleList);
......
...@@ -3,7 +3,7 @@ import { JSEncrypt } from 'jsencrypt'; ...@@ -3,7 +3,7 @@ import { JSEncrypt } from 'jsencrypt';
const keyHex = const keyHex =
'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMvGlIdli5G4Wpq780OxXm6U81CFIEyRAQkLsV+z/org+ut2Uz2z9tUOw5oMWEMZRwLhHcYDjm6Kh9DQmRKRnyMCAwEAAQ=='; 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMvGlIdli5G4Wpq780OxXm6U81CFIEyRAQkLsV+z/org+ut2Uz2z9tUOw5oMWEMZRwLhHcYDjm6Kh9DQmRKRnyMCAwEAAQ==';
// 加密 // 加密
function encryptText(text) { function encryptText(text: string): string | boolean {
const instance = new JSEncrypt(); const instance = new JSEncrypt();
instance.setPublicKey(keyHex.trim()); instance.setPublicKey(keyHex.trim());
console.log(keyHex); console.log(keyHex);
......
...@@ -133,26 +133,26 @@ ...@@ -133,26 +133,26 @@
onMounted(async () => { onMounted(async () => {
// const token = Cookies.get('JSESSIONID'); // const token = Cookies.get('JSESSIONID');
const cookies = getJSESSIONID(); const cookies = document.cookie;
// getSessionId();
console.log(cookies); console.log(cookies);
// console.log(token);
// // 异步操作 // // 异步操作
// if (!token) { // if (!token) {
// await handleLogin(); // await handleLogin();
// } // }
}); });
function getSessionId() {
function getJSESSIONID() { var c_name = 'JSESSIONID';
var cookies = document.cookie.split(';'); if (document.cookie.length > 0) {
for (var i = 0; i < cookies.length; i++) { var c_start = document.cookie.indexOf(c_name + '=');
var cookie = cookies[i].trim(); if (c_start != -1) {
// 检查当前cookie是否是'JSESSIONID' c_start = c_start + c_name.length + 1;
if (cookie.startsWith('JSESSIONID')) { var c_end = document.cookie.indexOf(';', c_start);
// 获取等号后面的部分,即JSESSIONID的值 if (c_end == -1) c_end = document.cookie.length;
var value = cookie.split('=')[1]; return unescape(document.cookie.substring(c_start, c_end));
return value;
} }
} }
return null; // 如果没有找到JSESSIONID,则返回null
} }
async function handleLogin() { async function handleLogin() {
const data = await validForm(); const data = await validForm();
......
...@@ -37,7 +37,6 @@ export interface RetryRequest { ...@@ -37,7 +37,6 @@ export interface RetryRequest {
} }
export interface Result<T = any> { export interface Result<T = any> {
code: number; code: number;
// type: 'success' | 'error' | 'warning';
dara: T; dara: T;
msg: string; msg: string;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment