Skip to content

Commit c93cc8a

Browse files
committed
新增:setting.darkModeSupport 配置项,默认为false
1 parent 00687e7 commit c93cc8a

5 files changed

Lines changed: 18 additions & 10 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## v0.3.0
22

3+
- 新增:setting.darkModeSupport 配置项,默认为false
34
- 修复:插件管理左侧溢出样式异常问题
45
- 优化:插件发布错误提醒增加错误码
56
- 优化:打开开发者调试默认为激活状态

electron/mapi/manager/lib/hooks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {BrowserView, BrowserWindow} from "electron";
22
import {AppsMain} from "../../app/main";
3+
import {PluginRecord} from "../../../../src/types/Manager";
34

45
type PluginHookType = never
56
| 'PluginReady'
@@ -53,12 +54,11 @@ export const executeHooks = async (win: BrowserWindow, hook: HookType, data?: an
5354
}
5455

5556
export const executeDarkMode = async (view: BrowserWindow | BrowserView, data: {
57+
plugin: PluginRecord,
5658
isSystem: boolean,
5759
}) => {
58-
data = Object.assign({
59-
isSystem: false
60-
}, data)
61-
if (await AppsMain.shouldDarkMode()) {
60+
// console.log('executeDarkMode', data.plugin.setting);
61+
if (await AppsMain.shouldDarkMode() && (data.plugin.setting?.darkModeSupport || data.isSystem)) {
6262
// body and html
6363
view.webContents.executeJavaScript(`
6464
document.body.setAttribute('data-theme', 'dark');

electron/mapi/manager/window/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export const ManagerWindow = {
205205
DevToolsManager.register(`PluginView.${plugin.name}`, view)
206206
view.webContents.once('did-finish-load', async () => {
207207
await executeDarkMode(view, {
208+
plugin,
208209
isSystem: ManagerSystem.match(plugin.name)
209210
})
210211
Events.sendRaw(view.webContents, 'APP_READY', {
@@ -439,6 +440,7 @@ export const ManagerWindow = {
439440
return new Promise((resolve, reject) => {
440441
win.webContents.once('did-finish-load', async () => {
441442
await executeDarkMode(win, {
443+
plugin,
442444
isSystem: true
443445
})
444446
view.setAutoResize({width: true, height: true});

sdk/config.schema.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@
263263
"properties": {
264264
"autoDetach": {
265265
"type": "boolean",
266-
"description": "是否默认分离模式打开"
266+
"description": "是否默认分离模式打开,默认为 false"
267267
},
268268
"detachPosition": {
269269
"type": "string",
270-
"description": "分离模式默认位置",
270+
"description": "分离模式默认位置,默认为 center",
271271
"enum": [
272272
"center",
273273
"left-top",
@@ -278,15 +278,15 @@
278278
},
279279
"detachAlwaysOnTop": {
280280
"type": "boolean",
281-
"description": "分离模式默认是否置顶"
281+
"description": "分离模式默认是否置顶,默认为 false"
282282
},
283283
"height": {
284284
"type": "string",
285-
"description": "窗口高度,支持 数字 或 百分比,设置后窗口大小将默认为分离模式"
285+
"description": "窗口高度,支持 数字 或 百分比,设置后窗口大小将默认为分离模式,默认为 600"
286286
},
287287
"width": {
288288
"type": "string",
289-
"description": "窗口宽度,支持 数字 或 百分比,设置后窗口大小将默认为分离模式"
289+
"description": "窗口宽度,支持 数字 或 百分比,设置后窗口大小将默认为分离模式,默认为 800"
290290
},
291291
"heightFastPanel": {
292292
"type": "integer",
@@ -298,7 +298,7 @@
298298
},
299299
"zoom": {
300300
"type": "number",
301-
"description": "窗口缩放比例,100表示原始大小"
301+
"description": "窗口缩放比例,100表示原始大小,默认为 100"
302302
},
303303
"preloadBase": {
304304
"type": "string",
@@ -307,6 +307,10 @@
307307
"nodeIntegration": {
308308
"type": "boolean",
309309
"description": "是否启用 nodejs,普通应用不需要设置"
310+
},
311+
"darkModeSupport": {
312+
"type": "boolean",
313+
"description": "是否支持暗黑模式,默认为 false"
310314
}
311315
}
312316
}

src/types/Manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export type PluginRecord = {
4949
zoom?: number,
5050
preloadBase?: string,
5151
nodeIntegration?: boolean,
52+
darkModeSupport?: boolean,
5253
},
5354
permissions: PluginPermissionType[],
5455
development?: {

0 commit comments

Comments
 (0)