重构代码, 优化加载js逻辑
This commit is contained in:
parent
a480918c29
commit
eb1a7c4414
@ -18,7 +18,7 @@ export class AppleClient {
|
||||
});
|
||||
}
|
||||
async initAppleClient() {
|
||||
await loadSingleScript([scripts[0]]);
|
||||
await loadScripts(scripts.map((script) => [script]));
|
||||
this.initClient();
|
||||
}
|
||||
async login(funid) {
|
||||
|
@ -24,7 +24,7 @@ export class GoogleClient {
|
||||
console.log('google client init success');
|
||||
}
|
||||
async initGoolgeClient() {
|
||||
await Promise.all([loadSingleScript([scripts[0]]), loadSingleScript([scripts[1]])]);
|
||||
await loadScripts(scripts.map((script) => [script]));
|
||||
await this.initGApi();
|
||||
this.initTokenClient(SCOPES);
|
||||
}
|
||||
|
28
index.html
28
index.html
@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>game page</title>
|
||||
@ -18,10 +18,10 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<style>
|
||||
body{background-color:#FFFFFF;padding: 20px;}
|
||||
button{
|
||||
body{background-color:#FFFFFF;padding: 20px;}
|
||||
button{
|
||||
padding: 10px 20px;
|
||||
}
|
||||
}
|
||||
.app{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
@ -37,8 +37,8 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
</head>
|
||||
<body>
|
||||
<div class='app' id='app'>
|
||||
|
||||
</div>
|
||||
@ -73,25 +73,27 @@
|
||||
['assets/scripts/run_sample.js'],
|
||||
]
|
||||
|
||||
var loadScripts = async function (list, callback) {
|
||||
var loadScripts = function (list, refresh = false) {
|
||||
var loaded = 0;
|
||||
var loadNext = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
// list[loaded][0] = list[loaded][0] + (list[loaded][0].indexOf("?") == -1 ? "?" : "&") + "t=" + Date.now();
|
||||
var loadNext = function () {
|
||||
if (refresh) {
|
||||
list[loaded][0] = list[loaded][0] + (list[loaded][0].indexOf("?") == -1 ? "?" : "&") + "t=" + Date.now();
|
||||
}
|
||||
loadSingleScript(list[loaded]).then(() => {
|
||||
loaded++;
|
||||
if (loaded >= list.length) {
|
||||
resolve();
|
||||
resolve && resolve();
|
||||
} else {
|
||||
return loadNext();
|
||||
}
|
||||
})
|
||||
})
|
||||
};
|
||||
loadNext();
|
||||
})
|
||||
};
|
||||
loadScripts(scripts, ()=> {})
|
||||
loadScripts(scripts);
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user