From 26ad0a568eab0c10cc85724ee545f14b9ebbe745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=B0=91=E4=BC=9F?= Date: Wed, 19 Mar 2025 10:08:49 +0800 Subject: [PATCH] fix: login user --- src/api/jyh/index.ts | 85 +++++++++++++++++++++++++++++--------------- src/stores/user.ts | 6 ++-- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/src/api/jyh/index.ts b/src/api/jyh/index.ts index 814bd0c..30be22b 100644 --- a/src/api/jyh/index.ts +++ b/src/api/jyh/index.ts @@ -2,7 +2,7 @@ import { reqCatchV2, type catchRt } from '@/utils/catch'; import request from '@/utils/request'; // 详情-获取版本信息 -export function releaseInfo(params: { softwareId: string }): Promise { +export function releaseInfo(params: { softwareId: string }): Promise { const { softwareId } = params; return request({ url: `/api/v1/repo/release/info?softwareId=${softwareId}`, @@ -21,34 +21,49 @@ export function releasePage(data): Promise { // 获取邀请列表 export function getInviteListData(): catchRt { - return reqCatchV2(() => request({ - url: '/api/v1/group/member/invite/list', - method: 'get' - }, { - customError: true - })); + return reqCatchV2(() => + request( + { + url: '/api/v1/group/member/invite/list', + method: 'get' + }, + { + customError: true + } + ) + ); } // 处理邀请 export function acceptInvite(params): catchRt { - return reqCatchV2(() => request({ - url: '/api/v1/group/member/invite/accept', - method: 'post', - data: params, - }, { - customError: true - })); + return reqCatchV2(() => + request( + { + url: '/api/v1/group/member/invite/accept', + method: 'post', + data: params + }, + { + customError: true + } + ) + ); } // 发送订阅 export function subscribeSoftware(params): catchRt { - return reqCatchV2(() => request({ - url: '/api/v1/alert/subscribe', - method: 'post', - data: params, - }, { - customError: true - })); + return reqCatchV2(() => + request( + { + url: '/api/v1/alert/subscribe', + method: 'post', + data: params + }, + { + customError: true + } + ) + ); } // 获取高级筛选语言列表 @@ -59,7 +74,6 @@ export function searchLanguageList() { }); } - // 获取首页公告列表 export function getHomeNoticeList() { return request({ @@ -74,7 +88,7 @@ export function getDepencyList(softwareId: string) { return request({ url: '/api/v1/repo/dependency/info', method: 'POST', - data: { + data: { softwareId: 47, current: 1, size: 20 @@ -88,9 +102,9 @@ export function getRepairInfo() { url: '/api/v1/repo/repair/info', method: 'POST', data: { - "current": 1, - "size": 10, - "softwareId": 47 + current: 1, + size: 10, + softwareId: 47 } }); } @@ -101,9 +115,22 @@ export function getLicenseList() { url: '/api/v1/repo/license/list', method: 'GET', params: { - "current": 1, - "size": 10, - "softwareId": 47 + current: 1, + size: 10, + softwareId: 47 + } + }); +} + +// 获取详情漏洞列表 +export function getVulnerabilityList() { + return request({ + url: '/api/v1/repo/vulnerability/page', + method: 'GET', + params: { + current: 1, + size: 10, + softwareId: 47 } }); } diff --git a/src/stores/user.ts b/src/stores/user.ts index d2a05fa..d0a557e 100644 --- a/src/stores/user.ts +++ b/src/stores/user.ts @@ -66,12 +66,14 @@ export const useAccountStore = defineStore('accountInfo', () => { localStorage.setItem('access_token', access_token); localStorage.setItem('refresh_token', refresh_token); saveStatus(true); + saveAccountInfo({ + access_token: localStorage.getItem('access_token') || '', + refresh_token: localStorage.getItem('refresh_token') || '' + }); const userRes = await getUserInfo(); if (userRes.data?.data) { localStorage.setItem('userInfo', JSON.stringify(userRes.data?.data)); saveAccountInfo({ - access_token: localStorage.getItem('access_token') || '', - refresh_token: localStorage.getItem('refresh_token') || '', ...userRes.data?.data }); // }