Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
deploy: 26cae1e
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYFan committed Jul 21, 2022
1 parent 4b80757 commit c332c11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
26 changes: 13 additions & 13 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,56 +211,56 @@
</body>
<script>

const $ = document.querySelector.bind(document);
const $$$ = document.querySelector.bind(document);
const changeType = (type) => {
$('#ring').style.display = 'none';
$('#error').style.display = 'none';
$('#success').style.display = 'none';
$$$('#ring').style.display = 'none';
$$$('#error').style.display = 'none';
$$$('#success').style.display = 'none';
switch (type) {
case 'ring':
$('#ring').style["display"] = 'block';
$$$('#ring').style["display"] = 'block';
break;
case 'error':
$('#error').style["display"] = 'block';
$$$('#error').style["display"] = 'block';
break;
case 'success':
$('#success').style["display"] = 'block';
$$$('#success').style["display"] = 'block';
break;
}
}
changeType('ring');
$('#info').innerHTML = '正在安装ClientWorker...';
$$$('#info').innerHTML = '正在安装ClientWorker...';
navigator.serviceWorker.register('/cw.js?t=' + new Date().getTime()).then(async (registration) => {
const conf = () => {
$('#info').innerHTML = 'ClientWorker已安装,等待配置中...';
$$$('#info').innerHTML = 'ClientWorker已安装,等待配置中...';
fetch('/cw-cgi/api?type=config')
.then(res => res.text())
.then(text => {
if (text === 'ok') {
changeType('success');
$('#info').innerHTML = 'ClientWorker已安装并配置完成,正在无刷新启动...';
$$$('#info').innerHTML = 'ClientWorker已安装并配置完成,正在无刷新启动...';
fetch(window.location.href).then(res => res.text()).then(text => {
document.open()
document.write(text);
document.close();
});
} else {
$('#info').innerHTML = 'ClientWorker配置失败,可能还没有准备好,正在进行第二次...';
$$$('#info').innerHTML = 'ClientWorker配置失败,可能还没有准备好,正在进行第二次...';
setTimeout(() => {
conf()
}, 200);
}
}).catch(err => {
changeType('error');
$('#info').innerHTML = 'ClientWorker配置失败,请检查您的配置!错误原因:' + err.message;
$$$('#info').innerHTML = 'ClientWorker配置失败,请检查您的配置!错误原因:' + err.message;
});
}
setTimeout(() => {
conf()
}, 50);
}).catch(err => {
changeType('error');
$('#info').innerHTML = 'ClientWorker安装失败,错误原因:' + err.message;
$$$('#info').innerHTML = 'ClientWorker安装失败,错误原因:' + err.message;
});
</script>

Expand Down
17 changes: 15 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ catch_rules: #转换规则


- search: _ #ClientWorker语法糖,匹配捕捉规则的路由
replace: docroot/clientworker@2.3.1/doc/docs/.vitepress/dist
replace: docroot/clientworker@2.4.0/doc/docs/.vitepress/dist


- search: ^https\:\/\/docroot
Expand Down Expand Up @@ -84,7 +84,20 @@ catch_rules: #转换规则
replace: .webp
replacein: url
replacekey: .jpg

- rule: ^https\:\/\/cdn\.jsdelivr\.net\/npm\/chenyfan\-happypic\@0\.0\.33\/1\.jpg$
transform_rules:
- search: _
replace: https://cdn.jsdelivr.net/npm/chenyfan-happypic@0.0.33/2.jpg
action: fetch
fetch:
status: 200
engine: crazy
preflight: false
threads: 5
timeout: 30000
cache:
enable: true
expire: 1000*60



Expand Down
Loading

0 comments on commit c332c11

Please sign in to comment.