mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-03-25 08:34:16 +08:00
add hint message
This commit is contained in:
@@ -124,6 +124,14 @@ export default ({
|
|||||||
UI_Read: 'Copy',
|
UI_Read: 'Copy',
|
||||||
UI_Write: 'Paste',
|
UI_Write: 'Paste',
|
||||||
|
|
||||||
|
UI_CopySuccess: 'Copy to clipboard success',
|
||||||
|
UI_CopyFaild: 'Copy to clipboard faild',
|
||||||
|
|
||||||
|
UI_PasteSuccessDecodeSuccess: 'Load Success!',
|
||||||
|
UI_PasteSuccessDecodeFaild: 'Paste success, but load faild!',
|
||||||
|
UI_PasteFaildDecodeSuccess: 'Paste faild, use input load success!',
|
||||||
|
UI_PasteFaildDecodeFaild: 'Paste faild, use input load faild!',
|
||||||
|
|
||||||
UI_LoadSuccess: 'Load Success!',
|
UI_LoadSuccess: 'Load Success!',
|
||||||
UI_LoadFaild: 'Load Faild!',
|
UI_LoadFaild: 'Load Faild!',
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,14 @@ export default ({
|
|||||||
UI_LoadSuccess: '读档成功!',
|
UI_LoadSuccess: '读档成功!',
|
||||||
UI_LoadFaild: '读档失败!',
|
UI_LoadFaild: '读档失败!',
|
||||||
|
|
||||||
|
UI_CopySuccess: '成功复制存档到剪贴板',
|
||||||
|
UI_CopyFaild: '复制存档到剪贴板失败,请手动复制存档内容',
|
||||||
|
|
||||||
|
UI_PasteSuccessDecodeSuccess: '读档成功!',
|
||||||
|
UI_PasteSuccessDecodeFaild: '粘贴剪贴板存档内容成功,但剪贴板内容读档失败',
|
||||||
|
UI_PasteFaildDecodeSuccess: '粘贴剪贴板存档内容失败,使用输入的内容读档成功',
|
||||||
|
UI_PasteFaildDecodeFaild: '粘贴剪贴板存档内容失败,使用输入的内容读档失败',
|
||||||
|
|
||||||
M_NoRank: '别卷了,没有排行榜',
|
M_NoRank: '别卷了,没有排行榜',
|
||||||
|
|
||||||
F_RemakeTimes: '已重开{0}次',
|
F_RemakeTimes: '已重开{0}次',
|
||||||
|
|||||||
@@ -38,15 +38,16 @@ globalThis.$$copy = async text => {
|
|||||||
const result = await navigator.permissions.query({ name: "clipboard-write" })
|
const result = await navigator.permissions.query({ name: "clipboard-write" })
|
||||||
if (result.state == "granted" || result.state == "prompt") {
|
if (result.state == "granted" || result.state == "prompt") {
|
||||||
navigator.clipboard.writeText(text)
|
navigator.clipboard.writeText(text)
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.setAttribute('style', 'opacity: 0;');
|
input.setAttribute('style', 'opacity: 0;');
|
||||||
document.body.appendChild(input);
|
document.body.appendChild(input);
|
||||||
input.value = text;
|
input.value = text;
|
||||||
input.select();
|
input.select();
|
||||||
document.execCommand("copy");
|
const r = document.execCommand("copy");
|
||||||
document.body.removeChild(input);
|
document.body.removeChild(input);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.$$read = async ()=>{
|
globalThis.$$read = async ()=>{
|
||||||
@@ -58,10 +59,10 @@ globalThis.$$read = async ()=>{
|
|||||||
input.setAttribute('style', 'opacity: 0;');
|
input.setAttribute('style', 'opacity: 0;');
|
||||||
document.body.appendChild(input);
|
document.body.appendChild(input);
|
||||||
input.focus();
|
input.focus();
|
||||||
document.execCommand("paste");
|
const r = document.execCommand("paste");
|
||||||
const text = input.value;
|
const text = input.value;
|
||||||
document.body.removeChild(input);
|
document.body.removeChild(input);
|
||||||
return text;
|
return r?text:r;
|
||||||
};
|
};
|
||||||
|
|
||||||
const core = new Life();
|
const core = new Life();
|
||||||
|
|||||||
@@ -5,13 +5,25 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
|||||||
await this.close();
|
await this.close();
|
||||||
$ui.switchView(UI.pages.MAIN);
|
$ui.switchView(UI.pages.MAIN);
|
||||||
});
|
});
|
||||||
this.btnRead.on(Laya.Event.CLICK, this,()=>$$copy(this.input.text = this.data));
|
this.btnRead.on(Laya.Event.CLICK, this, async ()=>{
|
||||||
|
const result = await $$copy(this.input.text = this.data);
|
||||||
|
$$event('message', [result? 'UI_CopySuccess': 'UI_CopyFaild']);
|
||||||
|
});
|
||||||
this.btnWrite.on(Laya.Event.CLICK, this, async ()=>{
|
this.btnWrite.on(Laya.Event.CLICK, this, async ()=>{
|
||||||
const text = await $$read();
|
const text = await $$read();
|
||||||
if(text) {
|
if(text == false) {
|
||||||
this.data = this.input.text = text;
|
this.data = [
|
||||||
|
this.input.text,
|
||||||
|
'UI_PasteFaildDecodeSuccess',
|
||||||
|
'UI_PasteFaildDecodeFaild'
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
this.data = this.input.text;
|
this.input.text = text;
|
||||||
|
this.data = [
|
||||||
|
text,
|
||||||
|
'UI_PasteSuccessDecodeSuccess',
|
||||||
|
'UI_PasteSuccessDecodeFaild'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,7 +52,7 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
|||||||
const file = e.target.files[0];
|
const file = e.target.files[0];
|
||||||
if(!file) return;
|
if(!file) return;
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = () => this.data = reader.result;
|
reader.onload = () => this.data = [reader.result];
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
document.body.removeChild(file);
|
document.body.removeChild(file);
|
||||||
};
|
};
|
||||||
@@ -67,17 +79,17 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
|||||||
return JSON.stringify(data);
|
return JSON.stringify(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
set data(v) {
|
set data([v, success = 'UI_LoadSuccess', faild = 'UI_LoadFaild']) {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(v);
|
const data = JSON.parse(v);
|
||||||
for(const key in data)
|
for(const key in data)
|
||||||
localStorage.setItem(key, data[key]);
|
localStorage.setItem(key, data[key]);
|
||||||
$$event('message', ['UI_LoadSuccess']);
|
$$event('message', [success]);
|
||||||
$ui.theme = $ui.theme;
|
$ui.theme = $ui.theme;
|
||||||
this.btnClose.event(Laya.Event.CLICK);
|
this.btnClose.event(Laya.Event.CLICK);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
$$event('message', ['UI_LoadFaild']);
|
$$event('message', [faild]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user