This commit is contained in:
yj 2025-03-05 15:58:18 +08:00
parent e90186e4b9
commit 00c16d44ff
2 changed files with 30 additions and 27 deletions

View File

@ -51,17 +51,19 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
}) })
}, []) }, [])
function getContent() { function getContent() {
fetch(`${getUpdateUrl()}/update.txt?t=${+new Date()}`) // 配置服务器地址 window.electron.getEnv().then(res => {
.then(async response => { fetch(`${getUpdateUrl(res)}/update.txt?t=${+new Date()}`) // 配置服务器地址
if (response.status === 200) { .then(async response => {
return setUpdateContent(await response.text()) if (response.status === 200) {
} return setUpdateContent(await response.text())
throw new Error('Network response was not ok.'); }
}) throw new Error('Network response was not ok.');
.then(textContent => { })
}) .then(textContent => {
.catch(error => { })
}); .catch(error => {
});
})
} }
function closeModal() { function closeModal() {

View File

@ -58,8 +58,7 @@ export const storageSeeting: any = {
}, },
} }
export const getUpdateUrl = async () => { export const getUpdateUrl = (env: string) => {
let env = await window.electron.getEnv()
switch (env) { switch (env) {
case 'xy': case 'xy':
return 'https://meeting-api.23544.com/meeting/xysz' 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) => { export const isVersion = (callBack: Function) => {
axios.get(`${getUpdateUrl()}/latest.yml`).then(res => { window.electron.getEnv().then(res => {
if (res.status === 200 && res.data) { axios.get(`${getUpdateUrl(res)}/latest.yml`).then(res => {
const data = yaml.load(res.data); // 解析 YAML 内容 if (res.status === 200 && res.data) {
window.electron.getVersion().then(req => { const data = yaml.load(res.data); // 解析 YAML 内容
if (compareVersions(data.version, req) == 1) { window.electron.getVersion().then(req => {
callBack(true) if (compareVersions(data.version, req) == 1) {
} else { callBack(true)
callBack(false) } else {
} callBack(false)
}) }
} else { })
} else {
callBack(false)
}
}).catch(() => {
callBack(false) callBack(false)
} })
}).catch(() => {
callBack(false)
}) })
} }