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() {
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() {

View File

@ -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)
})
})
}