mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
c8f60547da
commit
7587b91a5c
5 changed files with 52 additions and 0 deletions
|
|
@ -32,6 +32,9 @@ import {loadPlugins, reloadPlugin} from "./plugin/loader";
|
||||||
import "./assets/scss/base.scss";
|
import "./assets/scss/base.scss";
|
||||||
import {reloadEmoji} from "./emoji";
|
import {reloadEmoji} from "./emoji";
|
||||||
import {processIOSPurchaseResponse} from "./util/iOSPurchase";
|
import {processIOSPurchaseResponse} from "./util/iOSPurchase";
|
||||||
|
/// #if BROWSER
|
||||||
|
import {setLocalShorthandCount} from "./util/noRelyPCFunction";
|
||||||
|
/// #endif
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
public plugins: import("./plugin").Plugin[] = [];
|
public plugins: import("./plugin").Plugin[] = [];
|
||||||
|
|
@ -65,6 +68,11 @@ export class App {
|
||||||
case "setDefRefCount":
|
case "setDefRefCount":
|
||||||
setDefRefCount(data.data);
|
setDefRefCount(data.data);
|
||||||
break;
|
break;
|
||||||
|
/// #if BROWSER
|
||||||
|
case "setLocalShorthandCount":
|
||||||
|
setLocalShorthandCount();
|
||||||
|
break;
|
||||||
|
/// #endif
|
||||||
case "setRefDynamicText":
|
case "setRefDynamicText":
|
||||||
setRefDynamicText(data.data);
|
setRefDynamicText(data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import {isTouchDevice} from "../../util/functions";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {refreshFileTree} from "../../dialog/processSystem";
|
import {refreshFileTree} from "../../dialog/processSystem";
|
||||||
import {hideTooltip, showTooltip} from "../../dialog/tooltip";
|
import {hideTooltip, showTooltip} from "../../dialog/tooltip";
|
||||||
|
import * as dayjs from "dayjs";
|
||||||
|
|
||||||
export class Files extends Model {
|
export class Files extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -322,6 +323,14 @@ export class Files extends Model {
|
||||||
x: event.clientX,
|
x: event.clientX,
|
||||||
y: event.clientY
|
y: event.clientY
|
||||||
});
|
});
|
||||||
|
} else if (type === "addLocal") {
|
||||||
|
fetchPost("/api/filetree/moveLocalShorthands", {
|
||||||
|
"notebook": notebookId,
|
||||||
|
"path": dayjs().format("YYYYMMDDHHmmss")
|
||||||
|
});
|
||||||
|
this.element.querySelectorAll('[data-type="addLocal"]').forEach(item => {
|
||||||
|
item.remove();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === "more-file") {
|
if (type === "more-file") {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import {MenuItem} from "../../menus/Menu";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {refreshFileTree} from "../../dialog/processSystem";
|
import {refreshFileTree} from "../../dialog/processSystem";
|
||||||
import {setStorageVal} from "../../protyle/util/compatibility";
|
import {setStorageVal} from "../../protyle/util/compatibility";
|
||||||
|
import * as dayjs from "dayjs";
|
||||||
|
|
||||||
export class MobileFiles extends Model {
|
export class MobileFiles extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -217,6 +218,14 @@ export class MobileFiles extends Model {
|
||||||
} else if (type === "more-root") {
|
} else if (type === "more-root") {
|
||||||
initNavigationMenu(app, target.parentElement);
|
initNavigationMenu(app, target.parentElement);
|
||||||
window.siyuan.menus.menu.fullscreen("bottom");
|
window.siyuan.menus.menu.fullscreen("bottom");
|
||||||
|
} else if (type === "addLocal") {
|
||||||
|
fetchPost("/api/filetree/moveLocalShorthands", {
|
||||||
|
"notebook": notebookId,
|
||||||
|
"path": dayjs().format("YYYYMMDDHHmmss")
|
||||||
|
});
|
||||||
|
this.element.querySelectorAll('[data-type="addLocal"]').forEach(item => {
|
||||||
|
item.remove();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === "more-file") {
|
if (type === "more-file") {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {reloadPlugin} from "../../plugin/loader";
|
import {reloadPlugin} from "../../plugin/loader";
|
||||||
import {reloadEmoji} from "../../emoji";
|
import {reloadEmoji} from "../../emoji";
|
||||||
|
import {setLocalShorthandCount} from "../../util/noRelyPCFunction";
|
||||||
|
|
||||||
export const onMessage = (app: App, data: IWebSocketData) => {
|
export const onMessage = (app: App, data: IWebSocketData) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
@ -16,6 +17,9 @@ export const onMessage = (app: App, data: IWebSocketData) => {
|
||||||
case "setDefRefCount":
|
case "setDefRefCount":
|
||||||
setDefRefCount(data.data);
|
setDefRefCount(data.data);
|
||||||
break;
|
break;
|
||||||
|
case "setLocalShorthandCount":
|
||||||
|
setLocalShorthandCount();
|
||||||
|
break;
|
||||||
case "setRefDynamicText":
|
case "setRefDynamicText":
|
||||||
setRefDynamicText(data.data);
|
setRefDynamicText(data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ import {fetchPost} from "./fetch";
|
||||||
import {isMobile} from "./functions";
|
import {isMobile} from "./functions";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {pathPosix} from "./pathName";
|
import {pathPosix} from "./pathName";
|
||||||
|
/// #if !MOBILE
|
||||||
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
|
import {Files} from "../layout/dock/Files";
|
||||||
|
/// #endif
|
||||||
|
|
||||||
// 需独立出来,否则移动端引用的时候会引入 pc 端大量无用代码
|
// 需独立出来,否则移动端引用的时候会引入 pc 端大量无用代码
|
||||||
export const renameTag = (labelName: string) => {
|
export const renameTag = (labelName: string) => {
|
||||||
|
|
@ -45,3 +49,21 @@ export const checkFold = (id: string, cb: (zoomIn: boolean, action: TProtyleActi
|
||||||
foldResponse.data.isRoot);
|
foldResponse.data.isRoot);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setLocalShorthandCount = () => {
|
||||||
|
let fileElement;
|
||||||
|
/// #if MOBILE
|
||||||
|
fileElement = window.siyuan.mobile.docks.file.element;
|
||||||
|
/// #else
|
||||||
|
const dockFile = getDockByType("file");
|
||||||
|
if (!dockFile) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fileElement = (dockFile.data.file as Files).element;
|
||||||
|
/// #endif
|
||||||
|
fileElement.childNodes.forEach((item: Element) => {
|
||||||
|
item.querySelector('[data-type="more-root"]').insertAdjacentHTML("beforebegin", `<span data-type="addLocal" class="b3-list-item__action">
|
||||||
|
<svg><use xlink:href="#iconRiffCard"></use></svg>
|
||||||
|
</span>`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue