diff --git a/feature/src/App.vue b/feature/src/App.vue index 5f92dd5..5a0a199 100644 --- a/feature/src/App.vue +++ b/feature/src/App.vue @@ -68,7 +68,7 @@ const store = useStore(); const init = () => store.dispatch("init"); init(); - diff --git a/feature/src/assets/ant-reset.less b/feature/src/assets/ant-reset.less index 99c8c39..fe5d98e 100644 --- a/feature/src/assets/ant-reset.less +++ b/feature/src/assets/ant-reset.less @@ -1,5 +1,31 @@ -@import '~ant-design-vue/dist/antd.less'; // 引入官方提供的 less 样式入口文件 +@import "~ant-design-vue/dist/antd.less"; // 引入官方提供的 less 样式入口文件 @primary-color: #ff4ea4; // 全局主色 @link-color: #ff4ea4; // 链接色 @error-color: #ff4ea4; // 错误色 + +:root { + --color-text-primary: rgba(0, 0, 0, 0.85); + --color-text-content: #141414; + --color-text-desc: rgba(0, 0, 0, 0.45); + // 背景色 + --color-body-bg: #fff; + --color-menu-bg: #f3efef; + --color-list-hover: #e2e2e2; + --color-input-hover: #fff; + // 边框 + --color-border-light: #f0f0f0; +} + +.dark { + --color-text-primary: #e8e8f0; + --color-text-content: #ccccd8; + --color-text-desc: #8f8fa6; + // 背景色 + --color-body-bg: #1c1c28; + --color-menu-bg: #1c1c28; + --color-list-hover: #33333d; + --color-input-hover: #33333d; + // 边框 + --color-border-light: #33333d; +} diff --git a/feature/src/assets/common.less b/feature/src/assets/common.less index 7e9ce10..c870765 100644 --- a/feature/src/assets/common.less +++ b/feature/src/assets/common.less @@ -1,20 +1,37 @@ .left-menu { width: 200px; height: 100vh; + border-right: 1px solid var(--color-border-light); .search-container { padding: 10px; } .ant-input-affix-wrapper { border: none; + background: var(--color-input-hover); + :deep(input) { + background: none; + color: var(--color-text-desc); + } + :deep(.anticon) { + color: var(--color-text-desc); + } } :deep(.ant-menu) { - background: #F3EFEF; + background: var(--color-menu-bg); + height: 100%; + border-right: none; + .ant-menu-item { + color: var(--color-text-content); + &:active { + background: none; + } + } .ant-menu-item-selected { - background-color: #E2E2E2; - color: #141414; + background-color: var(--color-list-hover); + color: var(--color-text-primary); &:after { display: none; } } } -} \ No newline at end of file +} diff --git a/feature/src/views/account/index.vue b/feature/src/views/account/index.vue index b89eaa0..03f76a6 100644 --- a/feature/src/views/account/index.vue +++ b/feature/src/views/account/index.vue @@ -10,12 +10,18 @@ export default { }; - diff --git a/feature/src/views/dev/index.vue b/feature/src/views/dev/index.vue index a045b6b..c45ffd1 100644 --- a/feature/src/views/dev/index.vue +++ b/feature/src/views/dev/index.vue @@ -64,13 +64,20 @@ const labelCol = { span: 4 }; const wrapperCol = { span: 14 }; - diff --git a/feature/src/views/installed/index.vue b/feature/src/views/installed/index.vue index f5184a4..fd82099 100644 --- a/feature/src/views/installed/index.vue +++ b/feature/src/views/installed/index.vue @@ -15,7 +15,7 @@ @click="currentSelect = [index]" v-for="(plugin, index) in localPlugins" > - +
{{ plugin.pluginName }} @@ -33,7 +33,7 @@ {{ pluginDetail.version }}
- 开发者:{{ `${pluginDetail.author || "未知"}` }} + 开发者:{{ `${pluginDetail.author || '未知'}` }}
{{ pluginDetail.description }} @@ -66,20 +66,35 @@ :class="{ executable: !cmd.label }" :color="!cmd.label && '#87d068'" > - {{ cmd.label || cmd }} @@ -96,29 +111,29 @@ + + diff --git a/package.json b/package.json index 890e47f..23753ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rubick", - "version": "2.0.10", + "version": "2.1.0", "author": "muwoo <2424880409@qq.com>", "private": true, "scripts": { diff --git a/src/common/constans/defaultConfig.ts b/src/common/constans/defaultConfig.ts index 6502a43..a22c03b 100644 --- a/src/common/constans/defaultConfig.ts +++ b/src/common/constans/defaultConfig.ts @@ -1,7 +1,7 @@ import commonConst from "@/common/utils/commonConst"; export default { - version: 2, + version: 4, perf: { shortCut: { showAndHidden: "Option+R", @@ -14,6 +14,7 @@ export default { // 是否失焦隐藏。默认在dev环境不隐藏,在打包后隐藏。 hideOnBlur: commonConst.production(), autoPast: false, + darkMode: false }, local: { search: true, diff --git a/src/main/browsers/runner.ts b/src/main/browsers/runner.ts index b3c5c22..7cd9e22 100644 --- a/src/main/browsers/runner.ts +++ b/src/main/browsers/runner.ts @@ -41,6 +41,7 @@ export default () => { plugin; let pluginIndexPath = tplPath || indexPath; let preloadPath; + let darkMode; // 开发环境 if (commonConst.dev() && development) { pluginIndexPath = development; @@ -81,8 +82,13 @@ export default () => { window.setSize(800, height || 660); view.setBounds({ x: 0, y: 60, width: 800, height: height || 660 }); view.setAutoResize({ width: true }); - executeHooks('PluginEnter', ext); - executeHooks('PluginReady', ext); + executeHooks('PluginEnter', plugin.ext); + executeHooks('PluginReady', plugin.ext); + darkMode = global.OP_CONFIG.get().perf.common.darkMode; + darkMode && + view.webContents.executeJavaScript( + `document.body.classList.add("dark");window.rubick.theme="dark"` + ); window.webContents.executeJavaScript(`window.pluginLoaded()`); }); // 修复请求跨域问题 diff --git a/src/main/common/registerHotKey.ts b/src/main/common/registerHotKey.ts index 4d800ca..8a23f52 100644 --- a/src/main/common/registerHotKey.ts +++ b/src/main/common/registerHotKey.ts @@ -1,4 +1,12 @@ -import { globalShortcut, BrowserWindow, screen, ipcMain, app } from "electron"; +import { + globalShortcut, + nativeTheme, + BrowserWindow, + BrowserView, + screen, + ipcMain, + app +} from "electron"; const registerHotKey = (mainWindow: BrowserWindow): void => { // 设置开机启动 @@ -9,9 +17,36 @@ const registerHotKey = (mainWindow: BrowserWindow): void => { openAsHidden: true }); }; + // 设置暗黑模式 + const setDarkMode = () => { + const config = global.OP_CONFIG.get(); + const isDark = config.perf.common.darkMode; + if (isDark) { + nativeTheme.themeSource = "dark"; + mainWindow.webContents.executeJavaScript( + `document.body.classList.add("dark");window.rubick.theme="dark"` + ); + mainWindow.getBrowserViews().forEach((view: BrowserView) => { + view.webContents.executeJavaScript( + `document.body.classList.add("dark");window.rubick.theme="dark"` + ); + }); + } else { + nativeTheme.themeSource = "light"; + mainWindow.webContents.executeJavaScript( + `document.body.classList.remove("dark");window.rubick.theme="light"` + ); + mainWindow.getBrowserViews().forEach((view: BrowserView) => { + view.webContents.executeJavaScript( + `document.body.classList.remove("dark");window.rubick.theme="light"` + ); + }); + } + }; const init = () => { setAutoLogin(); + setDarkMode(); const config = global.OP_CONFIG.get(); globalShortcut.unregisterAll(); // 注册偏好快捷键 diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 409f563..092b6bd 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -35,7 +35,7 @@
- -