优化升级时的观感

This commit is contained in:
nonameShijian 2024-05-17 15:31:19 +08:00
parent cf6ec448a9
commit 79d833e15a
2 changed files with 43 additions and 1 deletions

View File

@ -46,8 +46,14 @@ boot().then(() => {
3. 保存http/s协议的状态以后不再以file协议启动
*/
// 导出数据到根目录的noname.config.txt
if (navigator.notification) {
navigator.notification.activityStart("正在进行升级", "请稍候");
}
let data;
let export_data = function (data) {
if (navigator.notification) {
navigator.notification.activityStop();
}
game.promises
.writeFile(
lib.init.encode(JSON.stringify(data)),
@ -83,6 +89,9 @@ boot().then(() => {
for (let [key, value] of searchParams) {
// 成功导入后删除noname.config.txt
if (key === "sendUpdate" && value === "true") {
if (navigator.notification) {
navigator.notification.activityStart("正在导入旧版数据", "请稍候");
}
game.promises
.readFileAsText("noname.config.txt")
.then((data) => {
@ -112,7 +121,10 @@ boot().then(() => {
}
return;
}
alert("导入成功, 即将自动重启");
if (navigator.notification) {
navigator.notification.activityStop();
}
alert("升级前的配置导入成功, 即将自动重启");
// @ts-ignore
if (!lib.db) {
const noname_inited =
@ -164,6 +176,10 @@ boot().then(() => {
.then(() => {
const url = new URL(location.href);
location.href = url.origin + url.pathname;
}).catch(e => {
if (navigator.notification) {
navigator.notification.activityStop();
}
});
}
// 新客户端导入扩展

View File

@ -55,6 +55,32 @@ interface Notification {
title?: string,
buttonLabels?: string[],
defaultText?: string): void;
/**
* open an activity dialog
*/
activityStart(title: string, message: string): void;
/**
* Close an activity dialog
*/
activityStop(): void;
/**
* Display a progress dialog with progress bar that goes from 0 to 100.
*
* @param title Title of the progress dialog.
* @param message Message to display in the dialog.
*/
progressStart(title: string, message: string): void;
/**
* Close the progress dialog.
*/
progressStop(): void;
/**
* Set the progress dialog value.
*
* @param value 0-100
*/
progressValue(value: number): void;
}
/** Object, passed to promptCallback */