diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index 8d16b7f..69b9c86 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -51,17 +51,19 @@ const UpdateModal = forwardRef((props: any, ref: any) => { }) }, []) function getContent() { - fetch(`${getUpdateUrl()}/update.txt?t=${+new Date()}`) // 配置服务器地址 - .then(async response => { - if (response.status === 200) { - return setUpdateContent(await response.text()) - } - throw new Error('Network response was not ok.'); - }) - .then(textContent => { - }) - .catch(error => { - }); + window.electron.getEnv().then(res => { + fetch(`${getUpdateUrl(res)}/update.txt?t=${+new Date()}`) // 配置服务器地址 + .then(async response => { + if (response.status === 200) { + return setUpdateContent(await response.text()) + } + throw new Error('Network response was not ok.'); + }) + .then(textContent => { + }) + .catch(error => { + }); + }) } function closeModal() { diff --git a/src/utils/package/public.ts b/src/utils/package/public.ts index 566a45d..ec71c0b 100644 --- a/src/utils/package/public.ts +++ b/src/utils/package/public.ts @@ -58,8 +58,7 @@ export const storageSeeting: any = { }, } -export const getUpdateUrl = async () => { - let env = await window.electron.getEnv() +export const getUpdateUrl = (env: string) => { switch (env) { case 'xy': return 'https://meeting-api.23544.com/meeting/xysz' @@ -102,20 +101,22 @@ export const compareVersions = (version1: string, version2: string): number => { } export const isVersion = (callBack: Function) => { - 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 => { - if (compareVersions(data.version, req) == 1) { - callBack(true) - } else { - callBack(false) - } - }) - } else { + window.electron.getEnv().then(res => { + axios.get(`${getUpdateUrl(res)}/latest.yml`).then(res => { + if (res.status === 200 && res.data) { + const data = yaml.load(res.data); // 解析 YAML 内容 + window.electron.getVersion().then(req => { + if (compareVersions(data.version, req) == 1) { + callBack(true) + } else { + callBack(false) + } + }) + } else { + callBack(false) + } + }).catch(() => { callBack(false) - } - }).catch(() => { - callBack(false) + }) }) } \ No newline at end of file