配置文件
This commit is contained in:
@@ -117,6 +117,7 @@
|
|||||||
<div class="loading-wrap">
|
<div class="loading-wrap">
|
||||||
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
|
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
|
||||||
</div>
|
</div>
|
||||||
|
网络检测中...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ init()
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped lang="scss">
|
||||||
@import "style/index.scss";
|
@import "style/index.scss";
|
||||||
body {
|
body {
|
||||||
//background-color: #f8f8f8;
|
//background-color: #f8f8f8;
|
||||||
|
|||||||
@@ -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 sassUrlStr = await fetch('https://nono-1257812345.cos.ap-shanghai.myqcloud.com/sass').then(res => res.text())
|
||||||
|
|
||||||
const config = JSON.parse(configStr) as Config
|
const config = JSON.parse(configStr) as Config
|
||||||
|
config.apiUrl = ''
|
||||||
// sassUrlStr逗号分隔
|
// sassUrlStr逗号分隔
|
||||||
const sassUrlList = sassUrlStr.split(',')
|
const sassUrlList = sassUrlStr.split(',')
|
||||||
console.log(sassUrlList)
|
console.log(sassUrlList)
|
||||||
|
if (sassUrlList.length === 1) {
|
||||||
|
config.apiUrl = sassUrlList[0]
|
||||||
|
return config
|
||||||
|
}
|
||||||
for (const item of sassUrlList) {
|
for (const item of sassUrlList) {
|
||||||
const url = item + '/api/app/check'
|
const url = item + '/api/app/check'
|
||||||
// 判断url是否连通
|
// 判断url是否连通
|
||||||
@@ -18,11 +23,15 @@ export const getConfig = async (): Promise<Config> => {
|
|||||||
const newVar = await fetchWithTimeout(url, 1000).then(res => res.json())
|
const newVar = await fetchWithTimeout(url, 1000).then(res => res.json())
|
||||||
if (newVar.code === 200) {
|
if (newVar.code === 200) {
|
||||||
config.apiUrl = item
|
config.apiUrl = item
|
||||||
|
return config
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.apiUrl === '') {
|
||||||
|
config.apiUrl = sassUrlList[sassUrlList.length - 1]
|
||||||
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user