mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🐛 Android 端无法复制数据仓库密钥 Fix https://github.com/siyuan-note/siyuan/issues/5198
This commit is contained in:
parent
3538a01d3b
commit
b1e34173e0
2 changed files with 12 additions and 0 deletions
|
|
@ -319,6 +319,7 @@ ${accountHTML}
|
||||||
writeText(window.siyuan.config.repo.key);
|
writeText(window.siyuan.config.repo.key);
|
||||||
});
|
});
|
||||||
modelMainElement.querySelector("#token").addEventListener("click", () => {
|
modelMainElement.querySelector("#token").addEventListener("click", () => {
|
||||||
|
showMessage(window.siyuan.languages.copied);
|
||||||
writeText(window.siyuan.config.api.token);
|
writeText(window.siyuan.config.api.token);
|
||||||
});
|
});
|
||||||
modelMainElement.querySelector("#exportData").addEventListener("click", () => {
|
modelMainElement.querySelector("#exportData").addEventListener("click", () => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,16 @@
|
||||||
export const writeText = async (text: string) => {
|
export const writeText = async (text: string) => {
|
||||||
try {
|
try {
|
||||||
|
// navigator.clipboard.writeText 抛出异常不进入 catch,这里需要先处理移动端复制
|
||||||
|
if ("android" === window.siyuan.config.system.container && window.JSAndroid) {
|
||||||
|
|
||||||
|
window.JSAndroid.writeClipboard(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (window.siyuan.config.system.container === "ios" && window.webkit?.messageHandlers) {
|
||||||
|
window.webkit.messageHandlers.setClipboard.postMessage(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (window.siyuan.config.system.container === "ios" && window.webkit?.messageHandlers) {
|
if (window.siyuan.config.system.container === "ios" && window.webkit?.messageHandlers) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue