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) }