优化升级时的观感
This commit is contained in:
parent
cf6ec448a9
commit
79d833e15a
|
@ -46,8 +46,14 @@ boot().then(() => {
|
||||||
3. 保存http/s协议的状态,以后不再以file协议启动
|
3. 保存http/s协议的状态,以后不再以file协议启动
|
||||||
*/
|
*/
|
||||||
// 导出数据到根目录的noname.config.txt
|
// 导出数据到根目录的noname.config.txt
|
||||||
|
if (navigator.notification) {
|
||||||
|
navigator.notification.activityStart("正在进行升级", "请稍候");
|
||||||
|
}
|
||||||
let data;
|
let data;
|
||||||
let export_data = function (data) {
|
let export_data = function (data) {
|
||||||
|
if (navigator.notification) {
|
||||||
|
navigator.notification.activityStop();
|
||||||
|
}
|
||||||
game.promises
|
game.promises
|
||||||
.writeFile(
|
.writeFile(
|
||||||
lib.init.encode(JSON.stringify(data)),
|
lib.init.encode(JSON.stringify(data)),
|
||||||
|
@ -83,6 +89,9 @@ boot().then(() => {
|
||||||
for (let [key, value] of searchParams) {
|
for (let [key, value] of searchParams) {
|
||||||
// 成功导入后删除noname.config.txt
|
// 成功导入后删除noname.config.txt
|
||||||
if (key === "sendUpdate" && value === "true") {
|
if (key === "sendUpdate" && value === "true") {
|
||||||
|
if (navigator.notification) {
|
||||||
|
navigator.notification.activityStart("正在导入旧版数据", "请稍候");
|
||||||
|
}
|
||||||
game.promises
|
game.promises
|
||||||
.readFileAsText("noname.config.txt")
|
.readFileAsText("noname.config.txt")
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
@ -112,7 +121,10 @@ boot().then(() => {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
alert("导入成功, 即将自动重启");
|
if (navigator.notification) {
|
||||||
|
navigator.notification.activityStop();
|
||||||
|
}
|
||||||
|
alert("升级前的配置导入成功, 即将自动重启");
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!lib.db) {
|
if (!lib.db) {
|
||||||
const noname_inited =
|
const noname_inited =
|
||||||
|
@ -164,6 +176,10 @@ boot().then(() => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const url = new URL(location.href);
|
const url = new URL(location.href);
|
||||||
location.href = url.origin + url.pathname;
|
location.href = url.origin + url.pathname;
|
||||||
|
}).catch(e => {
|
||||||
|
if (navigator.notification) {
|
||||||
|
navigator.notification.activityStop();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 新客户端导入扩展
|
// 新客户端导入扩展
|
||||||
|
|
|
@ -55,6 +55,32 @@ interface Notification {
|
||||||
title?: string,
|
title?: string,
|
||||||
buttonLabels?: string[],
|
buttonLabels?: string[],
|
||||||
defaultText?: string): void;
|
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 */
|
/** Object, passed to promptCallback */
|
||||||
|
|
Loading…
Reference in New Issue