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;
|
||||
}
|
||||
if (!isTabWindow && matchHotKey(window.siyuan.config.keymap.general.dailyNote.custom, event)) {
|
||||
newDailyNote();
|
||||
newDailyNote(app);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -135,9 +135,6 @@ export class App {
|
|||
(document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
|
||||
}
|
||||
break;
|
||||
case "createdailynote":
|
||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||
break;
|
||||
case "openFileById":
|
||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {ipcRenderer} from "electron";
|
|||
/// #endif
|
||||
import {openHistory} from "../history/history";
|
||||
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 {Constants} from "../constants";
|
||||
import {isInAndroid, isInIOS, setStorageVal, writeText} from "../protyle/util/compatibility";
|
||||
|
|
@ -324,7 +324,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
|||
icon: "iconCalendar",
|
||||
accelerator: window.siyuan.config.keymap.general.dailyNote.custom,
|
||||
click: () => {
|
||||
newDailyNote();
|
||||
newDailyNote(app);
|
||||
}
|
||||
}).element);
|
||||
} else {
|
||||
|
|
@ -336,10 +336,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
|||
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 : "",
|
||||
click: () => {
|
||||
fetchPost("/api/filetree/createDailyNote", {
|
||||
notebook: item.id,
|
||||
app: Constants.SIYUAN_APPID,
|
||||
});
|
||||
fetchNewDailyNote(app, item.id);
|
||||
window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] = item.id;
|
||||
setStorageVal(Constants.LOCAL_DAILYNOTEID, window.siyuan.storage[Constants.LOCAL_DAILYNOTEID]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ export const initRightMenu = (app: App) => {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.id === "menuNewDaily") {
|
||||
newDailyNote();
|
||||
newDailyNote(app);
|
||||
closePanel();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ export const onMessage = (app: App, data: IWebSocketData) => {
|
|||
document.getElementById("toolbarSync").classList.add("fn__none");
|
||||
}
|
||||
break;
|
||||
case "createdailynote":
|
||||
openMobileFileById(app, data.data.id);
|
||||
break;
|
||||
case "openFileById":
|
||||
openMobileFileById(app, data.data.id, [Constants.CB_GET_FOCUS]);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,24 @@ import {Dialog} from "../dialog";
|
|||
import {getOpenNotebookCount} from "./pathName";
|
||||
import {validateName} from "../editor/rename";
|
||||
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 => {
|
||||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.dailyNote.custom) {
|
||||
item.destroy();
|
||||
|
|
@ -29,10 +45,7 @@ export const newDailyNote = () => {
|
|||
notebookId = item.id;
|
||||
}
|
||||
});
|
||||
fetchPost("/api/filetree/createDailyNote", {
|
||||
notebook: notebookId,
|
||||
app: Constants.SIYUAN_APPID,
|
||||
});
|
||||
fetchNewDailyNote(app, notebookId);
|
||||
return;
|
||||
}
|
||||
const localNotebookId = window.siyuan.storage[Constants.LOCAL_DAILYNOTEID];
|
||||
|
|
@ -42,10 +55,7 @@ export const newDailyNote = () => {
|
|||
}
|
||||
});
|
||||
if (localNotebookId && localNotebookIsOpen && !isMobile()) {
|
||||
fetchPost("/api/filetree/createDailyNote", {
|
||||
notebook: localNotebookId,
|
||||
app: Constants.SIYUAN_APPID,
|
||||
});
|
||||
fetchNewDailyNote(app, localNotebookId);
|
||||
} else {
|
||||
let optionsHTML = "";
|
||||
window.siyuan.notebooks.forEach(item => {
|
||||
|
|
@ -75,10 +85,7 @@ export const newDailyNote = () => {
|
|||
const notebook = selectElement.value;
|
||||
window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] = notebook;
|
||||
setStorageVal(Constants.LOCAL_DAILYNOTEID, window.siyuan.storage[Constants.LOCAL_DAILYNOTEID]);
|
||||
fetchPost("/api/filetree/createDailyNote", {
|
||||
notebook,
|
||||
app: Constants.SIYUAN_APPID,
|
||||
});
|
||||
fetchNewDailyNote(app, notebook);
|
||||
dialog.destroy();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,9 +117,6 @@ class App {
|
|||
(document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
|
||||
}
|
||||
break;
|
||||
case "createdailynote":
|
||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||
break;
|
||||
case "openFileById":
|
||||
openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue