From 2a6b17a48e5bf442d0edc21077545857d8f93a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 12 May 2024 16:21:04 +0800 Subject: [PATCH] fix: try support win7 --- src/common/utils/system.ts | 10 +++++++++- vite.config.ts | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/utils/system.ts b/src/common/utils/system.ts index 77b5ea6f..a0873b0a 100644 --- a/src/common/utils/system.ts +++ b/src/common/utils/system.ts @@ -1,10 +1,18 @@ import os from 'node:os'; import path from 'node:path'; +// 缓解Win7设备兼容性问题 +let osName: string; +try { + osName = os.hostname(); +} catch (e) { + osName = "NapCat" + +} export const systemPlatform = os.platform(); export const cpuArch = os.arch(); export const systemVersion = os.release(); -export const hostname = os.hostname(); +export const hostname = osName; const homeDir = os.homedir(); export const downloadsPath = path.join(homeDir, 'Downloads'); export const systemName = os.type(); diff --git a/vite.config.ts b/vite.config.ts index 281cbba0..e651ac77 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,7 +7,6 @@ import { PluginOption, Plugin } from 'vite'; import nodeResolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import { builtinModules } from 'module'; -import os from 'node:os'; import fs from 'node:fs'; const external = ['silk-wasm', 'ws', 'express', 'uuid', 'fluent-ffmpeg', 'sqlite3', 'log4js',