refactor: replace Button with div for consistent styling in AIEditorLink refactor: update navigation handling in AppVersionList and remove LayoutMain wrapper refactor: remove unused LayoutMain imports and components across various pages fix: ensure user app list is set correctly in useUserAppStore fix: update login URL format in AuthProvider fix: adjust layout styles in EnvPage and other pages for better responsiveness chore: update route definitions and create new routes for apps, config, domain, flowme, org, remote, token, user, and users style: replace Button with div for delete confirmation in various components fix: ensure correct handling of user profile image source
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
'use strict';
|
|
import { query, queryLogin } from '@/modules/query';
|
|
import { create } from 'zustand';
|
|
import { toast as message } from 'sonner';
|
|
import { useLayoutStore } from '@/pages/auth/store';
|
|
export const getIsMac = async () => {
|
|
// @ts-ignore
|
|
const userAgentData = navigator.userAgentData;
|
|
if (userAgentData) {
|
|
const ua = await userAgentData.getHighEntropyValues(['platform']);
|
|
if (ua.platform === 'macOS') {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
export const getIsElectron = () => {
|
|
// 检查 window.process 和 navigator.userAgent 中是否包含 Electron 信息
|
|
return (
|
|
// @ts-ignore
|
|
(typeof window !== 'undefined' && typeof window.process !== 'undefined' && window.process.type === 'renderer') ||
|
|
(typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0)
|
|
);
|
|
};
|
|
|
|
type PlatfromStore = {
|
|
isMac: boolean;
|
|
setIsMac: (mac: boolean) => void;
|
|
mount: boolean;
|
|
isElectron: boolean;
|
|
init: () => Promise<void>;
|
|
};
|
|
export const usePlatformStore = create<PlatfromStore>((set) => {
|
|
return {
|
|
isMac: false,
|
|
mount: false,
|
|
isElectron: false,
|
|
setIsMac: (mac) => set({ isMac: mac }),
|
|
init: async () => {
|
|
const mac = await getIsMac();
|
|
// @ts-ignore
|
|
const isElectron = getIsElectron();
|
|
set({ isMac: isElectron && mac, isElectron: isElectron, mount: true });
|
|
},
|
|
};
|
|
});
|
|
|
|
type Me = {
|
|
id?: string;
|
|
username?: string;
|
|
nickname?: string | null;
|
|
needChangePassword?: boolean;
|
|
role?: string;
|
|
description?: string | null;
|
|
type?: 'user' | 'org';
|
|
orgs?: string[];
|
|
avatar?: string;
|
|
};
|
|
export type LayoutStore = {
|
|
open: boolean;
|
|
setOpen: (open: boolean) => void;
|
|
me: Me;
|
|
setMe: (me: Me) => void;
|
|
getMe: () => Promise<void>;
|
|
openUser: boolean;
|
|
setOpenUser: (openUser: boolean) => void;
|
|
switchOrg: (username?: string, type?: 'user' | 'org') => Promise<void>;
|
|
isAdmin: boolean;
|
|
setIsAdmin: (isAdmin: boolean) => void;
|
|
checkHasOrg: () => boolean;
|
|
};
|
|
export { useLayoutStore } |