update query login

This commit is contained in:
2025-03-21 20:40:43 +08:00
parent ca269e5ae2
commit b2ad3da8d8
8 changed files with 75 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
import { query } from '@/modules/query';
import { query, queryLogin } from '@/modules';
import { create } from 'zustand';
import { message } from '@/modules/message';
export const getIsMac = async () => {
@@ -69,10 +69,7 @@ export const useLayoutStore = create<LayoutStore>((set) => ({
me: {},
setMe: (me) => set({ me }),
getMe: async () => {
const res = await query.post({
path: 'user',
key: 'me',
});
const res = await queryLogin.getMe();
if (res.code === 200) {
set({ me: res.data });
}
@@ -80,19 +77,12 @@ export const useLayoutStore = create<LayoutStore>((set) => ({
openUser: false,
setOpenUser: (openUser) => set({ openUser }),
switchOrg: async (username?: string, type?: string) => {
const res = await query.post({
path: 'user',
key: 'switchOrg',
data: {
username,
type,
},
});
const res = await queryLogin.switchUser(username || '');
if (res.code === 200) {
const { token } = res.data;
query.saveToken(token);
message.success('Switch success');
window.location.reload();
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
message.error(res.message || 'Request failed');
}