49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
import WuhuBase from "../WuhuBase";
|
|
import Popup from "../utils/Popup";
|
|
import CommonUtils from "../utils/CommonUtils";
|
|
import MDUtils from "../utils/MDUtils";
|
|
import Log from "../Log";
|
|
|
|
export default class ChangeLogHandler extends WuhuBase {
|
|
className = 'ChangeLogHandler';
|
|
|
|
public handle(): void {
|
|
let popup = new Popup(
|
|
'更新历史:<br/><a target="_blank" href="https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md">https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md</a><br/>',
|
|
'更新历史'
|
|
).getElement();
|
|
popup.classList.add('wh-changeLog');
|
|
let progressBar = document.createElement('div');
|
|
progressBar.style.height = '2px';
|
|
progressBar.style.width = '1%';
|
|
progressBar.style.backgroundColor = 'red';
|
|
let progressText = document.createElement('p');
|
|
progressText.innerText = '加载更新文件……';
|
|
progressText.style.textAlign = 'center';
|
|
let style = document.createElement('style');
|
|
style.innerHTML = `.wh-changeLog h2,.wh-changeLog h3,.wh-changeLog h4 {margin:8px 0;}.wh-changeLog li{list-style: inside;}`;
|
|
|
|
popup.append(progressBar, progressText, style);
|
|
|
|
CommonUtils
|
|
.COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md?' + performance.now())
|
|
.then(update => {
|
|
progressBar.style.width = '60%';
|
|
progressText.innerText = '解析中……';
|
|
let md = MDUtils.getInstance().parse(update);
|
|
popup.append(md);
|
|
progressBar.style.width = '100%';
|
|
progressText.innerText = '加载完成';
|
|
|
|
window.setTimeout(() => {
|
|
progressBar.remove();
|
|
progressText.remove()
|
|
}, 3000);
|
|
})
|
|
.catch(e => {
|
|
Log.error(e);
|
|
progressBar.remove();
|
|
progressText.innerText = '无法加载';
|
|
});
|
|
}
|
|
} |