From c69d9651836379434959fe045f5c875d594327f9 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Wed, 5 Mar 2025 11:11:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 ++-- src/App.tsx | 2 +- src/components/UpdateModal/index.tsx | 2 +- src/page/Login/index.tsx | 4 +++- src/utils/package/public.ts | 10 +++++----- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/main.js b/main.js index 0a30fd9..bfd6920 100644 --- a/main.js +++ b/main.js @@ -25,7 +25,7 @@ app.allowRendererProcessReuse = false; let mainWindow = null; let childWindow = {} let isMaximized = false; -let env = 'production'; //development production xy +let env = 'development'; //development production xy let regKey; let connection = null; let startNumber = 0; @@ -77,7 +77,7 @@ let tray; // 检查网络状态 function checkNetworkStatus() { if (!net.isOnline()) { - dialog.showErrorBox('智汇享-网络连接错误', '当前无网络连接,请检查您的网络设置。'); + dialog.showErrorBox(`${env === 'xy' ? '湖北襄阳四中教研平台' : '智汇享'}-网络连接错误', '当前无网络连接,请检查您的网络设置。`); app.quit(); return false; } diff --git a/src/App.tsx b/src/App.tsx index ef813d9..d5b1bb7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -201,7 +201,7 @@ const App: React.FC = () => { event.preventDefault(); } }); - document.getElementsByTagName('title')[0].innerText = getTitle(storage.getItem('env') as string) + document.getElementsByTagName('title')[0].innerText = getTitle() }, []) const handleResize = (): void => { setWindowSize({ diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index c3590e7..7f8ce77 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -47,7 +47,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { const [updateContent, setUpdateContent] = useState('') // 版本更新内容 function getContent() { - fetch(`${getUpdateUrl(storage.getItem('env') as string)}/update.txt?t=${+new Date()}`) // 配置服务器地址 + fetch(`${getUpdateUrl()}/update.txt?t=${+new Date()}`) // 配置服务器地址 .then(async response => { if (response.status === 200) { return setUpdateContent(await response.text()) diff --git a/src/page/Login/index.tsx b/src/page/Login/index.tsx index b277f52..64354b2 100644 --- a/src/page/Login/index.tsx +++ b/src/page/Login/index.tsx @@ -40,6 +40,7 @@ const Login: React.FC = () => { roomNum: '', }) const [nameModal, setNameModal] = useState(false) + const [env, setEnv] = useState('') useEffect(() => { window.electron.setMainWindowSize({ @@ -47,6 +48,7 @@ const Login: React.FC = () => { height: 520, key: 'login' }) + setEnv(storage.getItem('env') as string) if (storage.getItem('login')) { const login = JSON.parse(storage.getItem('login') as string); const data = { @@ -201,7 +203,7 @@ const Login: React.FC = () => { <>
- +
diff --git a/src/utils/package/public.ts b/src/utils/package/public.ts index 6a8b53f..b2a605a 100644 --- a/src/utils/package/public.ts +++ b/src/utils/package/public.ts @@ -58,8 +58,8 @@ export const storageSeeting: any = { }, } -export const getUpdateUrl = (env: string) => { - switch (env) { +export const getUpdateUrl = () => { + switch (storage.getItem('env')) { case 'xy': return 'https://meeting-api.23544.com/meeting/xysz' case 'development': @@ -68,8 +68,8 @@ export const getUpdateUrl = (env: string) => { return 'https://meeting-api.23544.com/meeting/update' } } -export const getTitle = (env: string) => { - switch (env) { +export const getTitle = () => { + switch (storage.getItem('env')) { case 'xy': return '湖北襄阳四中教研平台' case 'development': @@ -95,7 +95,7 @@ export const compareVersions = (version1: string, version2: string): number => { } export const isVersion = (callBack: Function) => { - axios.get(`${getUpdateUrl(storage.getItem('env') as string)}/latest.yml`).then(res => { + axios.get(`${getUpdateUrl()}/latest.yml`).then(res => { if (res.status === 200 && res.data) { const data = yaml.load(res.data); // 解析 YAML 内容 window.electron.getVersion().then(req => {