} onClick={() => setOpen(false)}>
diff --git a/src/modules/layout/index.tsx b/src/modules/layout/index.tsx
index ff2aa0e..20f9fd3 100644
--- a/src/modules/layout/index.tsx
+++ b/src/modules/layout/index.tsx
@@ -3,9 +3,9 @@ import { MenuOutlined, SwapOutlined } from '@ant-design/icons';
import { Button, Tooltip } from 'antd';
import { Outlet } from 'react-router-dom';
import { LayoutMenu } from './Menu';
-import { useLayoutStore } from './store';
+import { useLayoutStore, usePlatformStore } from './store';
import { useShallow } from 'zustand/react/shallow';
-import { useEffect } from 'react';
+import { useEffect, useLayoutEffect, useState } from 'react';
import { LayoutUser } from './LayoutUser';
import PandaPNG from '@/assets/panda.png';
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
@@ -28,27 +28,46 @@ export const LayoutMain = (props: LayoutMainProps) => {
};
}),
);
+ const platformStore = usePlatformStore(
+ useShallow((state) => {
+ return {
+ isMac: state.isMac,
+ mount: state.mount,
+ isElectron: state.isElectron,
+ init: state.init,
+ };
+ }),
+ );
+ const { isMac, mount, isElectron } = platformStore;
const aiStore = useAiStore(
useShallow((state) => {
return { open: state.open };
}),
);
+ useLayoutEffect(() => {
+ platformStore.init();
+ }, []);
+
useEffect(() => {
menuStore.getMe();
}, []);
return (
-
+
{props.title}
-
+
{menuStore.me?.type === 'org' && (
diff --git a/src/modules/layout/store/index.ts b/src/modules/layout/store/index.ts
index fc82606..cdfeffa 100644
--- a/src/modules/layout/store/index.ts
+++ b/src/modules/layout/store/index.ts
@@ -1,6 +1,47 @@
import { query } from '@/modules/query';
import { message } from 'antd';
import { create } from 'zustand';
+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;
+};
+export const usePlatformStore = create((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;
diff --git a/vite.config.ts b/vite.config.ts
index dfbc199..c741e4c 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -4,10 +4,23 @@ import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';
import path from 'path';
import nesting from 'tailwindcss/nesting';
-
+const isDev = process.env.NODE_ENV === 'development';
+const unamiPlugin = {
+ name: 'html-transform',
+ transformIndexHtml(html: string) {
+ return html.replace(
+ '',
+ ``,
+ );
+ },
+};
+const plugins = [];
+if (!isDev) {
+ plugins.push(unamiPlugin);
+}
// https://vitejs.dev/config/
export default defineConfig({
- plugins: [react()],
+ plugins: [react(), ...plugins],
css: {
postcss: {