配置文件

This commit is contained in:
John
2024-05-23 23:39:49 +08:00
parent 5b3bc02a6e
commit 3546ef9958
3 changed files with 11 additions and 1 deletions

View File

@@ -117,6 +117,7 @@
<div class="loading-wrap">
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
</div>
网络检测中...
</div>
</div>
<script type="module" src="/src/main.ts"></script>

View File

@@ -33,7 +33,7 @@ init()
</script>
<style>
<style scoped lang="scss">
@import "style/index.scss";
body {
//background-color: #f8f8f8;

View File

@@ -8,9 +8,14 @@ export const getConfig = async (): Promise<Config> => {
const sassUrlStr = await fetch('https://nono-1257812345.cos.ap-shanghai.myqcloud.com/sass').then(res => res.text())
const config = JSON.parse(configStr) as Config
config.apiUrl = ''
// sassUrlStr逗号分隔
const sassUrlList = sassUrlStr.split(',')
console.log(sassUrlList)
if (sassUrlList.length === 1) {
config.apiUrl = sassUrlList[0]
return config
}
for (const item of sassUrlList) {
const url = item + '/api/app/check'
// 判断url是否连通
@@ -18,11 +23,15 @@ export const getConfig = async (): Promise<Config> => {
const newVar = await fetchWithTimeout(url, 1000).then(res => res.json())
if (newVar.code === 200) {
config.apiUrl = item
return config
}
} catch (e) {
console.error(e)
}
}
if (config.apiUrl === '') {
config.apiUrl = sassUrlList[sassUrlList.length - 1]
}
return config
}