This commit is contained in:
Vanessa 2024-05-21 00:24:54 +08:00
parent 8db6015709
commit 358047dea0
6 changed files with 11 additions and 20 deletions

View file

@ -236,17 +236,12 @@ const isOpenAsHidden = function () {
}; };
const initMainWindow = () => { const initMainWindow = () => {
let windowStateInitialized = true;
// 恢复主窗体状态 // 恢复主窗体状态
let oldWindowState = {}; let oldWindowState = {};
try { try {
oldWindowState = JSON.parse(fs.readFileSync(windowStatePath, "utf8")); oldWindowState = JSON.parse(fs.readFileSync(windowStatePath, "utf8"));
if (!oldWindowState.x) {
windowStateInitialized = false;
}
} catch (e) { } catch (e) {
fs.writeFileSync(windowStatePath, "{}"); fs.writeFileSync(windowStatePath, "{}");
windowStateInitialized = false;
} }
let defaultWidth; let defaultWidth;
let defaultHeight; let defaultHeight;
@ -270,7 +265,7 @@ const initMainWindow = () => {
writeLog("windowStat [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + "], default [width=" + defaultWidth + ", height=" + defaultHeight + "], workArea [width=" + workArea.width + ", height=" + workArea.height + "]"); writeLog("windowStat [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + "], default [width=" + defaultWidth + ", height=" + defaultHeight + "], workArea [width=" + workArea.width + ", height=" + workArea.height + "]");
let resetToCenter = false let resetToCenter = false;
let x = windowState.x; let x = windowState.x;
let y = windowState.y; let y = windowState.y;
if (workArea) { if (workArea) {

View file

@ -7,7 +7,6 @@ import {
writeText writeText
} from "../../protyle/util/compatibility"; } from "../../protyle/util/compatibility";
import {matchAuxiliaryHotKey, matchHotKey} from "../../protyle/util/hotKey"; import {matchAuxiliaryHotKey, matchHotKey} from "../../protyle/util/hotKey";
import {openSearch} from "../../search/spread";
import { import {
hasClosestBlock, hasClosestBlock,
hasClosestByAttribute, hasClosestByAttribute,
@ -18,7 +17,7 @@ import {newFile} from "../../util/newFile";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {openSetting} from "../../config"; import {openSetting} from "../../config";
import {getInstanceById} from "../../layout/util"; import {getInstanceById} from "../../layout/util";
import {copyTab, getActiveTab, getDockByType, resizeTabs, switchTabByIndex} from "../../layout/tabUtil"; import {getActiveTab, getDockByType, switchTabByIndex} from "../../layout/tabUtil";
import {Tab} from "../../layout/Tab"; import {Tab} from "../../layout/Tab";
import {Editor} from "../../editor"; import {Editor} from "../../editor";
import {setEditMode} from "../../protyle/util/setEditMode"; import {setEditMode} from "../../protyle/util/setEditMode";
@ -29,10 +28,9 @@ import {hideElements} from "../../protyle/ui/hideElements";
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
import {goBack, goForward} from "../../util/backForward"; import {goBack, goForward} from "../../util/backForward";
import {onGet} from "../../protyle/util/onGet"; import {onGet} from "../../protyle/util/onGet";
import {getDisplayName, getNotebookName, getTopPaths, movePathTo, moveToPath} from "../../util/pathName"; import {getDisplayName, getNotebookName} from "../../util/pathName";
import {openFileById} from "../../editor/util"; import {openFileById} from "../../editor/util";
import {getAllDocks, getAllModels, getAllTabs} from "../../layout/getAll"; import {getAllDocks, getAllModels, getAllTabs} from "../../layout/getAll";
import {openGlobalSearch} from "../../search/util";
import {focusBlock, focusByOffset, focusByRange, getSelectionOffset} from "../../protyle/util/selection"; import {focusBlock, focusByOffset, focusByRange, getSelectionOffset} from "../../protyle/util/selection";
import {initFileMenu, initNavigationMenu} from "../../menus/navigation"; import {initFileMenu, initNavigationMenu} from "../../menus/navigation";
import {bindMenuKeydown} from "../../menus/Menu"; import {bindMenuKeydown} from "../../menus/Menu";
@ -65,7 +63,6 @@ import {transaction} from "../../protyle/wysiwyg/transaction";
import {quickMakeCard} from "../../card/makeCard"; import {quickMakeCard} from "../../card/makeCard";
import {getContentByInlineHTML} from "../../protyle/wysiwyg/keydown"; import {getContentByInlineHTML} from "../../protyle/wysiwyg/keydown";
import {searchKeydown} from "./searchKeydown"; import {searchKeydown} from "./searchKeydown";
import {openNewWindow} from "../../window/openNewWindow";
import {historyKeydown} from "../../history/keydown"; import {historyKeydown} from "../../history/keydown";
import {zoomOut} from "../../menus/protyle"; import {zoomOut} from "../../menus/protyle";
import {getPlainText} from "../../protyle/util/paste"; import {getPlainText} from "../../protyle/util/paste";

View file

@ -3,7 +3,6 @@ import {fetchPost} from "../../util/fetch";
import {hasClosestByClassName} from "../../protyle/util/hasClosest"; import {hasClosestByClassName} from "../../protyle/util/hasClosest";
import {MenuItem} from "../../menus/Menu"; import {MenuItem} from "../../menus/Menu";
import {popSearch} from "../menu/search"; import {popSearch} from "../menu/search";
import {Constants} from "../../constants";
import {App} from "../../index"; import {App} from "../../index";
import {openTagMenu} from "../../menus/tag"; import {openTagMenu} from "../../menus/tag";

View file

@ -574,12 +574,12 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
let link = protyle.lute.GetLinkDest(value); let link = protyle.lute.GetLinkDest(value);
let name = ""; let name = "";
if (html) { if (html) {
const tempElement = document.createElement("template") const tempElement = document.createElement("template");
tempElement.innerHTML = html tempElement.innerHTML = html;
const aElement = tempElement.content.querySelector('[data-type~="a"]') const aElement = tempElement.content.querySelector('[data-type~="a"]');
if (aElement) { if (aElement) {
link = aElement.getAttribute("data-href"); link = aElement.getAttribute("data-href");
name = aElement.textContent name = aElement.textContent;
} }
} }
if (!link && !name) { if (!link && !name) {

View file

@ -583,7 +583,7 @@ export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID:
} }
}); });
if (!needAdd) { if (!needAdd) {
const newColor = ((column.options?.length || 0) % 13 + 1).toString() const newColor = ((column.options?.length || 0) % 13 + 1).toString();
column.options.push({ column.options.push({
name: item.content, name: item.content,
color: newColor color: newColor
@ -594,7 +594,7 @@ export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID:
id: column.id, id: column.id,
avID, avID,
data: column.options data: column.options
}) });
undoOperations.push({ undoOperations.push({
action: "removeAttrViewColOption", action: "removeAttrViewColOption",
id: column.id, id: column.id,
@ -607,4 +607,4 @@ export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID:
doOperations, doOperations,
undoOperations undoOperations
}; };
} };

View file

@ -99,4 +99,4 @@ export const duplicateNameAddOne = (name:string) => {
name = `${name} (1)`; name = `${name} (1)`;
} }
return name; return name;
} };