From b6fcbad720939170352eec01c2c7376671d44eab Mon Sep 17 00:00:00 2001 From: Folltoshe Date: Tue, 29 Nov 2022 23:39:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E8=BD=AF=E4=BB=B6=E6=95=B0=E6=8D=AE=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=B8=8Bstyle.css=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ipcNames.ts | 1 + .../commonRenderers/common/rendererEvent.ts | 4 ++++ src/renderer/App.vue | 21 ++++++++++++++++++- src/renderer/utils/ipc.ts | 4 ++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/common/ipcNames.ts b/src/common/ipcNames.ts index a1f31ca7..bc3bec0e 100644 --- a/src/common/ipcNames.ts +++ b/src/common/ipcNames.ts @@ -8,6 +8,7 @@ const modules = { get_system_fonts: 'get_system_fonts', get_app_setting: 'get_app_setting', set_app_setting: 'set_app_setting', + get_data_path: 'get_data_path' }, player: { invoke_play_music: 'play_music', diff --git a/src/main/modules/commonRenderers/common/rendererEvent.ts b/src/main/modules/commonRenderers/common/rendererEvent.ts index 1529bb07..c76c159d 100644 --- a/src/main/modules/commonRenderers/common/rendererEvent.ts +++ b/src/main/modules/commonRenderers/common/rendererEvent.ts @@ -4,6 +4,10 @@ import { getFonts } from '@main/utils/fontManage' // 公共操作事件(公共,只注册一次) export default () => { + mainHandle(CMMON_EVENT_NAME.get_data_path, async() => { + return global.lxOldDataPath + }) + mainHandle(CMMON_EVENT_NAME.get_app_setting, async() => { return global.lx.appSetting }) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index f75e1978..847aac18 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -18,12 +18,31 @@ import { onMounted } from '@common/utils/vueTools' // import BubbleCursor from '@common/utils/cursor-effects/bubbleCursor' import useApp from '@renderer/core/useApp' +import { getDataPath } from '@renderer/utils/ipc' +import fs from 'fs' +import path from 'path' + +function loadCss(path) { + const head = document.getElementsByTagName('head')[0] + const link = document.createElement('link') + link.type = 'text/css' + link.rel = 'stylesheet' + link.href = path + head.appendChild(link) +} useApp() onMounted(() => { document.getElementById('root').style.display = 'block' - + getDataPath().then(value => { + console.log(value) + // 判断目录下是否有style.css + if (fs.existsSync(path.join(value + '/style.css'))) { + loadCss(path.join(value + '/style.css')) + console.log('Load style.css') + } + }) // const styles = getComputedStyle(document.documentElement) // window.lxData.bubbleCursor = new BubbleCursor({ // fillStyle: styles.getPropertyValue('--color-primary-alpha-900'), diff --git a/src/renderer/utils/ipc.ts b/src/renderer/utils/ipc.ts index 7b13bd97..5170b62a 100644 --- a/src/renderer/utils/ipc.ts +++ b/src/renderer/utils/ipc.ts @@ -7,6 +7,10 @@ import { APP_EVENT_NAMES, DATA_KEYS, DEFAULT_SETTING } from '@common/constants' type RemoveListener = () => void +export const getDataPath = async() => { + return rendererInvoke(CMMON_EVENT_NAME.get_data_path) +} + export const getSetting = async() => { return rendererInvoke(CMMON_EVENT_NAME.get_app_setting) }