Vanessa 2024-03-24 22:35:30 +08:00
parent e922c402c8
commit 1f607cf08a
9 changed files with 15 additions and 294 deletions

View file

@ -244,7 +244,7 @@ export const appearance = {
}); });
}); });
}, },
onSetappearance(data: IAppearance) { onSetappearance(data: Config.IAppearance) {
if (data.lang !== window.siyuan.config.appearance.lang) { if (data.lang !== window.siyuan.config.appearance.lang) {
exportLayout({ exportLayout({
cb() { cb() {

View file

@ -349,7 +349,7 @@ export const editor = {
}); });
}); });
}, },
_onSetEditor: (editorData: IEditor) => { _onSetEditor: (editorData: Config.IEditor) => {
const changeReadonly = editorData.readOnly !== window.siyuan.config.editor.readOnly; const changeReadonly = editorData.readOnly !== window.siyuan.config.editor.readOnly;
if (changeReadonly) { if (changeReadonly) {
editor.setReadonly(editorData.readOnly); editor.setReadonly(editorData.readOnly);

View file

@ -254,7 +254,7 @@ export const exportConfig = {
}); });
/// #endif /// #endif
}, },
onSetexport: (data: IExport) => { onSetexport: (data: Config.IExport) => {
window.siyuan.config.export = data; window.siyuan.config.export = data;
} }
}; };

View file

@ -121,7 +121,7 @@ export const fileTree = {
}); });
}); });
}, },
onSetfiletree: (fileTree: IFileTree) => { onSetfiletree: (fileTree: Config.IFileTree) => {
window.siyuan.config.fileTree = fileTree; window.siyuan.config.fileTree = fileTree;
} }
}; };

View file

@ -185,7 +185,7 @@ export const keymap = {
</div>`; </div>`;
}, },
_setkeymap(app: App) { _setkeymap(app: App) {
const data: IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP)); const data: Config.IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP));
keymap.element.querySelectorAll("label.b3-list-item input").forEach((item) => { keymap.element.querySelectorAll("label.b3-list-item input").forEach((item) => {
const keys = item.getAttribute("data-key").split(Constants.ZWSP); const keys = item.getAttribute("data-key").split(Constants.ZWSP);
const newHotkey = item.getAttribute("data-value"); const newHotkey = item.getAttribute("data-value");

View file

@ -286,7 +286,7 @@ export abstract class Constants {
// "⌘", "⇧", "⌥", "⌃" // "⌘", "⇧", "⌥", "⌃"
// "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←", // "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←",
// "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape" 不可自定义 // "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape" 不可自定义
public static readonly SIYUAN_KEYMAP: IKeymap = { public static readonly SIYUAN_KEYMAP: Config.IKeymap = {
general: { general: {
mainMenu: {default: "⌥\\", custom: "⌥\\"}, mainMenu: {default: "⌥\\", custom: "⌥\\"},
commandPanel: {default: "⌥⇧P", custom: "⌥⇧P"}, commandPanel: {default: "⌥⇧P", custom: "⌥⇧P"},

View file

@ -1,16 +1,16 @@
/** /**
* Copyright (C) 2023 SiYuan Community * Copyright (C) 2023 SiYuan Community
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -65,6 +65,7 @@ declare namespace Config {
openHelp: boolean; openHelp: boolean;
/** /**
* Whether it is running in read-only mode * Whether it is running in read-only mode
*
*/ */
readonly: boolean; readonly: boolean;
repo: IRepo; repo: IRepo;
@ -133,6 +134,7 @@ declare namespace Config {
apiModel: TOpenAIModel; apiModel: TOpenAIModel;
/** /**
* API Provider * API Provider
* OpenAI, Azure
*/ */
apiProvider: APIProvider; apiProvider: APIProvider;
/** /**
@ -1191,8 +1193,8 @@ declare namespace Config {
/** /**
* Cloud storage service provider * Cloud storage service provider
* - `0`: SiYuan official cloud storage service * - `0`: SiYuan official cloud storage service
* - `1`: Object storage service compatible with S3 protocol * - `2`: Object storage service compatible with S3 protocol
* - `2`: Network storage service using WebDAV protocol * - `3`: Network storage service using WebDAV protocol
*/ */
provider: number; provider: number;
s3: ISyncS3; s3: ISyncS3;

View file

@ -607,61 +607,6 @@ interface ITab {
callback?: (tab: import("../layout/Tab").Tab) => void callback?: (tab: import("../layout/Tab").Tab) => void
} }
interface IExport {
fileAnnotationRefMode: number
blockRefMode: number
blockEmbedMode: number
blockRefTextLeft: string
blockRefTextRight: string
tagOpenMarker: string
tagCloseMarker: string
pandocBin: string
paragraphBeginningSpace: boolean;
addTitle: boolean;
markdownYFM: boolean;
pdfFooter: string;
pdfWatermarkStr: string;
pdfWatermarkDesc: string;
imageWatermarkStr: string;
imageWatermarkDesc: string;
docxTemplate: string;
}
interface IEditor {
justify: boolean;
fontSizeScrollZoom: boolean;
rtl: boolean;
readOnly: boolean;
listLogicalOutdent: boolean;
listItemDotNumberClickFocus: boolean;
spellcheck: boolean;
onlySearchForDoc: boolean;
katexMacros: string;
fullWidth: boolean;
floatWindowMode: number;
dynamicLoadBlocks: number;
fontSize: number;
generateHistoryInterval: number;
historyRetentionDays: number;
codeLineWrap: boolean;
displayBookmarkIcon: boolean;
displayNetImgMark: boolean;
codeSyntaxHighlightLineNum: boolean;
embedBlockBreadcrumb: boolean;
plantUMLServePath: string;
codeLigatures: boolean;
codeTabSpaces: number;
fontFamily: string;
virtualBlockRef: boolean;
virtualBlockRefExclude: string;
virtualBlockRefInclude: string;
blockRefDynamicAnchorTextMaxLen: number;
backlinkExpandCount: number;
backmentionExpandCount: number;
emoji: string[];
}
interface IWebSocketData { interface IWebSocketData {
cmd?: string cmd?: string
callback?: string callback?: string
@ -671,194 +616,6 @@ interface IWebSocketData {
sid?: string sid?: string
} }
interface IAppearance {
modeOS: boolean,
hideStatusBar: boolean,
themeJS: boolean,
mode: number, // 1 暗黑0 明亮
icon: string,
closeButtonBehavior: number // 0退出1最小化到托盘
codeBlockThemeDark: string
codeBlockThemeLight: string
themeDark: string
themeLight: string
icons: string[]
lang: string
iconVer: string
themeVer: string
lightThemes: string[]
darkThemes: string[]
}
interface IFileTree {
closeTabsOnStart: boolean
alwaysSelectOpenedFile: boolean
openFilesUseCurrentTab: boolean
removeDocWithoutConfirm: boolean
useSingleLineSave: boolean
allowCreateDeeper: boolean
refCreateSavePath: string
docCreateSavePath: string
sort: number
maxOpenTabCount: number
maxListCount: number
}
interface IAccount {
displayTitle: boolean
displayVIP: boolean
}
interface IConfig {
snippet: {
enabledCSS: boolean
enabledJS: boolean
}
cloudRegion: number
bazaar: {
trust: boolean
petalDisabled: boolean
}
repo: {
key: string
},
flashcard: {
newCardLimit: number
reviewCardLimit: number
mark: boolean
list: boolean
superBlock: boolean
heading: boolean
deck: boolean
reviewMode: number
requestRetention: number
maximumInterval: number
weights: string
}
ai: {
openAI: {
apiProvider: string // OpenAI, Azure
apiUserAgent: string
apiBaseURL: string
apiVersion: string
apiKey: string
apiModel: string
apiMaxTokens: number
apiTemperature: number
apiMaxContexts: number
apiProxy: string
apiTimeout: number
},
}
sync: {
generateConflictDoc: boolean
enabled: boolean
perception: boolean
mode: number
synced: number
stat: string
interval: number
cloudName: string
provider: number // 0 官方同步, 2 S3 3 WebDAV
s3: {
endpoint: string
pathStyle: boolean
accessKey: string
secretKey: string
bucket: string
region: string
skipTlsVerify: boolean
timeout: number
}
webdav: {
endpoint: string
username: string
password: string
skipTlsVerify: boolean
timeout: number
}
},
lang: string
api: {
token: string
}
openHelp: boolean
system: {
lockScreenMode: number // 0手动1手动+跟随系统
networkProxy: {
host: string
port: string
scheme: string
}
name: string
kernelVersion: string
isInsider: boolean
appDir: string
workspaceDir: string
confDir: string
dataDir: string
container: "std" | "android" | "docker" | "ios"
isMicrosoftStore: boolean
os: "windows" | "linux" | "darwin"
osPlatform: string
homeDir: string
xanadu: boolean
udanax: boolean
uploadErrLog: boolean
disableGoogleAnalytics: boolean
downloadInstallPkg: boolean
networkServe: boolean
fixedPort: boolean
autoLaunch: boolean
}
localIPs: string[]
readonly: boolean // 全局只读
uiLayout: Record<string, any>
langs: {
label: string,
name: string
}[]
appearance: IAppearance
editor: IEditor,
fileTree: IFileTree
graph: IGraph
keymap: IKeymap
export: IExport
accessAuthCode: string
account: IAccount
tag: {
sort: number
}
search: ISearchType & {
name: boolean
alias: boolean
memo: boolean
indexAssetPath: boolean
ial: boolean
limit: number
caseSensitive: boolean
backlinkMentionName: boolean
backlinkMentionAlias: boolean
backlinkMentionAnchor: boolean
backlinkMentionDoc: boolean
backlinkMentionKeywordsLimit: boolean
virtualRefName: boolean
virtualRefAlias: boolean
virtualRefAnchor: boolean
virtualRefDoc: boolean
},
stat: {
treeCount: number
cTreeCount: number
blockCount: number
cBlockCount: number
dataSize: number
cDataSize: number
assetsSize: number
cAssetsSize: number
}
}
interface IGraphCommon { interface IGraphCommon {
d3: { d3: {
centerStrength: number centerStrength: number
@ -884,44 +641,6 @@ interface IGraphCommon {
} }
} }
interface IGraph {
global: {
minRefs: number
dailyNote: boolean
} & IGraphCommon
local: {
dailyNote: boolean
} & IGraphCommon
}
interface IKeymap {
plugin: {
[key: string]: {
[key: string]: IKeymapItem
}
}
general: {
[key: string]: IKeymapItem
}
editor: {
general: {
[key: string]: IKeymapItem
}
insert: {
[key: string]: IKeymapItem
}
heading: {
[key: string]: IKeymapItem
}
list: {
[key: string]: IKeymapItem
}
table: {
[key: string]: IKeymapItem
}
}
}
interface IKeymapItem { interface IKeymapItem {
default: string, default: string,
custom: string custom: string

View file

@ -9,7 +9,7 @@ import {fetchPost} from "./fetch";
import {appearance} from "../config/appearance"; import {appearance} from "../config/appearance";
import {isInAndroid, isInIOS} from "../protyle/util/compatibility"; import {isInAndroid, isInIOS} from "../protyle/util/compatibility";
const loadThirdIcon = (iconURL: string, data: IAppearance) => { const loadThirdIcon = (iconURL: string, data: Config.IAppearance) => {
addScript(iconURL, "iconDefaultScript").then(() => { addScript(iconURL, "iconDefaultScript").then(() => {
if (!["ant", "material"].includes(data.icon)) { if (!["ant", "material"].includes(data.icon)) {
const iconScriptElement = document.getElementById("iconScript"); const iconScriptElement = document.getElementById("iconScript");
@ -21,7 +21,7 @@ const loadThirdIcon = (iconURL: string, data: IAppearance) => {
}); });
}; };
export const loadAssets = (data: IAppearance) => { export const loadAssets = (data: Config.IAppearance) => {
const htmlElement = document.getElementsByTagName("html")[0]; const htmlElement = document.getElementsByTagName("html")[0];
htmlElement.setAttribute("lang", window.siyuan.config.appearance.lang); htmlElement.setAttribute("lang", window.siyuan.config.appearance.lang);
htmlElement.setAttribute("data-theme-mode", getThemeMode()); htmlElement.setAttribute("data-theme-mode", getThemeMode());