Skip to content
Snippets Groups Projects
Unverified Commit 1b44ae09 authored by GyDi's avatar GyDi
Browse files

fix: add os platform value

parent 453c2307
No related branches found
No related tags found
No related merge requests found
......@@ -24,10 +24,6 @@ import useCustomTheme from "@/components/layout/use-custom-theme";
import getSystem from "@/utils/get-system";
import "dayjs/locale/zh-cn";
declare global {
const WIN_PORTABLE: boolean;
}
dayjs.extend(relativeTime);
const OS = getSystem();
......
type Platform =
| "aix"
| "android"
| "darwin"
| "freebsd"
| "haiku"
| "linux"
| "openbsd"
| "sunos"
| "win32"
| "cygwin"
| "netbsd";
/**
* defines in `vite.config.ts`
*/
declare const WIN_PORTABLE: boolean;
declare const OS_PLATFORM: Platform;
/**
* Some interface for clash api
*/
......
......@@ -2,10 +2,11 @@
// according to UA
export default function getSystem() {
const ua = navigator.userAgent;
const platform = OS_PLATFORM;
if (ua.includes("Mac OS X")) return "macos";
if (ua.includes("Mac OS X") || platform === "darwin") return "macos";
if (/win64|win32/i.test(ua)) return "windows";
if (/win64|win32/i.test(ua) || platform === "win32") return "windows";
if (/linux/i.test(ua)) return "linux";
......
......@@ -24,6 +24,7 @@ export default defineConfig({
},
},
define: {
OS_PLATFORM: `"${process.platform}"`,
WIN_PORTABLE: !!process.env.VITE_WIN_PORTABLE,
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment