mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
fb0e5b20cb
commit
363466025e
7 changed files with 25 additions and 30 deletions
|
|
@ -1265,7 +1265,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isTabWindow && matchHotKey(window.siyuan.config.keymap.general.dailyNote.custom, event)) {
|
if (!isTabWindow && matchHotKey(window.siyuan.config.keymap.general.dailyNote.custom, event)) {
|
||||||
newDailyNote();
|
newDailyNote(app);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,6 @@ export class App {
|
||||||
(document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
|
(document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "createdailynote":
|
|
||||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
|
||||||
break;
|
|
||||||
case "openFileById":
|
case "openFileById":
|
||||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {ipcRenderer} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {openHistory} from "../history/history";
|
import {openHistory} from "../history/history";
|
||||||
import {getOpenNotebookCount, originalPath, pathPosix, showFileInFolder} from "../util/pathName";
|
import {getOpenNotebookCount, originalPath, pathPosix, showFileInFolder} from "../util/pathName";
|
||||||
import {mountHelp, newDailyNote} from "../util/mount";
|
import {fetchNewDailyNote, mountHelp, newDailyNote} from "../util/mount";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {isInAndroid, isInIOS, setStorageVal, writeText} from "../protyle/util/compatibility";
|
import {isInAndroid, isInIOS, setStorageVal, writeText} from "../protyle/util/compatibility";
|
||||||
|
|
@ -324,7 +324,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
icon: "iconCalendar",
|
icon: "iconCalendar",
|
||||||
accelerator: window.siyuan.config.keymap.general.dailyNote.custom,
|
accelerator: window.siyuan.config.keymap.general.dailyNote.custom,
|
||||||
click: () => {
|
click: () => {
|
||||||
newDailyNote();
|
newDailyNote(app);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -336,10 +336,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
iconHTML: unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE, "b3-menu__icon", true),
|
iconHTML: unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE, "b3-menu__icon", true),
|
||||||
accelerator: window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] === item.id ? window.siyuan.config.keymap.general.dailyNote.custom : "",
|
accelerator: window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] === item.id ? window.siyuan.config.keymap.general.dailyNote.custom : "",
|
||||||
click: () => {
|
click: () => {
|
||||||
fetchPost("/api/filetree/createDailyNote", {
|
fetchNewDailyNote(app, item.id);
|
||||||
notebook: item.id,
|
|
||||||
app: Constants.SIYUAN_APPID,
|
|
||||||
});
|
|
||||||
window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] = item.id;
|
window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] = item.id;
|
||||||
setStorageVal(Constants.LOCAL_DAILYNOTEID, window.siyuan.storage[Constants.LOCAL_DAILYNOTEID]);
|
setStorageVal(Constants.LOCAL_DAILYNOTEID, window.siyuan.storage[Constants.LOCAL_DAILYNOTEID]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ export const initRightMenu = (app: App) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "menuNewDaily") {
|
} else if (target.id === "menuNewDaily") {
|
||||||
newDailyNote();
|
newDailyNote(app);
|
||||||
closePanel();
|
closePanel();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@ export const onMessage = (app: App, data: IWebSocketData) => {
|
||||||
document.getElementById("toolbarSync").classList.add("fn__none");
|
document.getElementById("toolbarSync").classList.add("fn__none");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "createdailynote":
|
|
||||||
openMobileFileById(app, data.data.id);
|
|
||||||
break;
|
|
||||||
case "openFileById":
|
case "openFileById":
|
||||||
openMobileFileById(app, data.data.id, [Constants.CB_GET_FOCUS]);
|
openMobileFileById(app, data.data.id, [Constants.CB_GET_FOCUS]);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,24 @@ import {Dialog} from "../dialog";
|
||||||
import {getOpenNotebookCount} from "./pathName";
|
import {getOpenNotebookCount} from "./pathName";
|
||||||
import {validateName} from "../editor/rename";
|
import {validateName} from "../editor/rename";
|
||||||
import {setStorageVal} from "../protyle/util/compatibility";
|
import {setStorageVal} from "../protyle/util/compatibility";
|
||||||
|
import {openFileById} from "../editor/util";
|
||||||
|
import {openMobileFileById} from "../mobile/editor";
|
||||||
|
import {App} from "../index";
|
||||||
|
|
||||||
export const newDailyNote = () => {
|
export const fetchNewDailyNote = (app: App, notebook: string) => {
|
||||||
|
fetchPost("/api/filetree/createDailyNote", {
|
||||||
|
notebook,
|
||||||
|
app: Constants.SIYUAN_APPID,
|
||||||
|
}, (response) => {
|
||||||
|
/// #if MOBILE
|
||||||
|
openMobileFileById(app, response.data.id);
|
||||||
|
/// #else
|
||||||
|
openFileById({app, id: response.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||||
|
/// #endif
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const newDailyNote = (app: App) => {
|
||||||
const exit = window.siyuan.dialogs.find(item => {
|
const exit = window.siyuan.dialogs.find(item => {
|
||||||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.dailyNote.custom) {
|
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.dailyNote.custom) {
|
||||||
item.destroy();
|
item.destroy();
|
||||||
|
|
@ -29,10 +45,7 @@ export const newDailyNote = () => {
|
||||||
notebookId = item.id;
|
notebookId = item.id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fetchPost("/api/filetree/createDailyNote", {
|
fetchNewDailyNote(app, notebookId);
|
||||||
notebook: notebookId,
|
|
||||||
app: Constants.SIYUAN_APPID,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const localNotebookId = window.siyuan.storage[Constants.LOCAL_DAILYNOTEID];
|
const localNotebookId = window.siyuan.storage[Constants.LOCAL_DAILYNOTEID];
|
||||||
|
|
@ -42,10 +55,7 @@ export const newDailyNote = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (localNotebookId && localNotebookIsOpen && !isMobile()) {
|
if (localNotebookId && localNotebookIsOpen && !isMobile()) {
|
||||||
fetchPost("/api/filetree/createDailyNote", {
|
fetchNewDailyNote(app, localNotebookId);
|
||||||
notebook: localNotebookId,
|
|
||||||
app: Constants.SIYUAN_APPID,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
let optionsHTML = "";
|
let optionsHTML = "";
|
||||||
window.siyuan.notebooks.forEach(item => {
|
window.siyuan.notebooks.forEach(item => {
|
||||||
|
|
@ -75,10 +85,7 @@ export const newDailyNote = () => {
|
||||||
const notebook = selectElement.value;
|
const notebook = selectElement.value;
|
||||||
window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] = notebook;
|
window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] = notebook;
|
||||||
setStorageVal(Constants.LOCAL_DAILYNOTEID, window.siyuan.storage[Constants.LOCAL_DAILYNOTEID]);
|
setStorageVal(Constants.LOCAL_DAILYNOTEID, window.siyuan.storage[Constants.LOCAL_DAILYNOTEID]);
|
||||||
fetchPost("/api/filetree/createDailyNote", {
|
fetchNewDailyNote(app, notebook);
|
||||||
notebook,
|
|
||||||
app: Constants.SIYUAN_APPID,
|
|
||||||
});
|
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,6 @@ class App {
|
||||||
(document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
|
(document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "createdailynote":
|
|
||||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
|
||||||
break;
|
|
||||||
case "openFileById":
|
case "openFileById":
|
||||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue