mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
5bc1367b1c
commit
fd60867b3a
3 changed files with 14 additions and 15 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {app, ipcRenderer, shell} from "electron";
|
import {app, shell} from "electron";
|
||||||
import {dialog} from "@electron/remote";
|
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isBrowser} from "../util/functions";
|
import {isBrowser} from "../util/functions";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {dialog} from "@electron/remote";
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {openHistory} from "../history/history";
|
import {openHistory} from "../history/history";
|
||||||
import {getOpenNotebookCount, pathPosix} from "../util/pathName";
|
import {getOpenNotebookCount} from "../util/pathName";
|
||||||
import {mountHelp, newDailyNote} from "../util/mount";
|
import {mountHelp, newDailyNote} from "../util/mount";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
|
@ -33,7 +33,7 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
} else {
|
} else {
|
||||||
const submenu: IMenu[] = []
|
const submenu: IMenu[] = [];
|
||||||
window.siyuan.notebooks.forEach(item => {
|
window.siyuan.notebooks.forEach(item => {
|
||||||
if (!item.closed) {
|
if (!item.closed) {
|
||||||
submenu.push({
|
submenu.push({
|
||||||
|
|
@ -84,7 +84,7 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
if (localPath.filePaths.length === 0) {
|
if (localPath.filePaths.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openWorkspace(localPath.filePaths[0])
|
openWorkspace(localPath.filePaths[0]);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
|
|
@ -97,9 +97,9 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: pathPosix().basename(item.path),
|
label: item.path,
|
||||||
click: () => {
|
click: () => {
|
||||||
openWorkspace(item.path)
|
openWorkspace(item.path);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
});
|
});
|
||||||
|
|
@ -110,16 +110,16 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
}).element);
|
}).element);
|
||||||
response.data.forEach((item: IWorkspace) => {
|
response.data.forEach((item: IWorkspace) => {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: pathPosix().basename(item.path),
|
label: item.path,
|
||||||
click: () => {
|
click: () => {
|
||||||
openWorkspace(item.path)
|
openWorkspace(item.path);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom});
|
window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const openWorkspace = (workspace: string) => {
|
const openWorkspace = (workspace: string) => {
|
||||||
fetchPost("/api/system/setWorkspaceDir", {
|
fetchPost("/api/system/setWorkspaceDir", {
|
||||||
|
|
@ -130,4 +130,4 @@ const openWorkspace = (workspace: string) => {
|
||||||
lang: window.siyuan.config.appearance.lang
|
lang: window.siyuan.config.appearance.lang
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import {mountHelp} from "./mount";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
import {addGA, initAssets, setInlineStyle, setMode} from "./assets";
|
import {addGA, initAssets, setInlineStyle, setMode} from "./assets";
|
||||||
import {renderSnippet} from "../config/util/snippets";
|
import {renderSnippet} from "../config/util/snippets";
|
||||||
import {pathPosix} from "./pathName";
|
import {originalPath} from "./pathName";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
import {focusByRange} from "../protyle/util/selection";
|
import {focusByRange} from "../protyle/util/selection";
|
||||||
import {exitSiYuan} from "../dialog/processSystem";
|
import {exitSiYuan} from "../dialog/processSystem";
|
||||||
|
|
@ -182,7 +182,7 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
const initBar = () => {
|
const initBar = () => {
|
||||||
document.querySelector(".toolbar").innerHTML = `
|
document.querySelector(".toolbar").innerHTML = `
|
||||||
<div id="barWorkspace" class="toolbar__item">
|
<div id="barWorkspace" class="toolbar__item">
|
||||||
${pathPosix().basename(window.siyuan.config.system.workspaceDir)}
|
${originalPath().basename(window.siyuan.config.system.workspaceDir)}
|
||||||
<svg class="toolbar__svg"><use xlink:href="#iconDown"></use></svg>
|
<svg class="toolbar__svg"><use xlink:href="#iconDown"></use></svg>
|
||||||
</div>
|
</div>
|
||||||
<div id="barSync" class="toolbar__item b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom))}">
|
<div id="barSync" class="toolbar__item b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom))}">
|
||||||
|
|
@ -225,7 +225,7 @@ const initBar = () => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "barWorkspace") {
|
} else if (target.id === "barWorkspace") {
|
||||||
workspaceMenu(target.getBoundingClientRect())
|
workspaceMenu(target.getBoundingClientRect());
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "barReadonly") {
|
} else if (target.id === "barReadonly") {
|
||||||
|
|
@ -258,7 +258,7 @@ const initBar = () => {
|
||||||
setMode(2);
|
setMode(2);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
const rect = target.getBoundingClientRect()
|
const rect = target.getBoundingClientRect();
|
||||||
window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom});
|
window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom});
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue