配置文件
This commit is contained in:
@@ -33,7 +33,7 @@ init()
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped lang="scss">
|
||||
@import "style/index.scss";
|
||||
body {
|
||||
//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 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user