mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-11 01:34:20 +01:00
➖
This commit is contained in:
parent
77560d6601
commit
c5f35969eb
7 changed files with 52 additions and 62 deletions
33
app/src/util/noRelyPCFunction.ts
Normal file
33
app/src/util/noRelyPCFunction.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import {Dialog} from "../dialog";
|
||||
import {fetchPost} from "./fetch";
|
||||
import {isMobile} from "./functions";
|
||||
|
||||
// 需独立出来,否则移动端引用的时候会引入 pc 端大量无用代码
|
||||
export const renameTag = (labelName: string) => {
|
||||
const dialog = new Dialog({
|
||||
title: window.siyuan.languages.rename,
|
||||
content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value="${labelName}"></div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||
</div>`,
|
||||
width: isMobile() ? "80vw": "520px",
|
||||
});
|
||||
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
dialog.destroy();
|
||||
});
|
||||
const inputElement = dialog.element.querySelector("input");
|
||||
dialog.bindInput(inputElement, () => {
|
||||
(btnsElement[1] as HTMLButtonElement).click();
|
||||
});
|
||||
inputElement.focus();
|
||||
inputElement.select();
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
fetchPost("/api/tag/renameTag", {oldLabel: labelName, newLabel: inputElement.value});
|
||||
});
|
||||
};
|
||||
|
||||
export const getWorkspaceName = () => {
|
||||
return window.siyuan.config.system.workspaceDir.replace(/^.*[\\\/]/, "");
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue