Skip to content

Commit

Permalink
修复对轻量工具箱的适配
Browse files Browse the repository at this point in the history
  • Loading branch information
MUKAPP committed Aug 25, 2024
1 parent 90f2727 commit c93ebe8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
const { BrowserWindow, ipcMain, shell, net } = require("electron");
const { BrowserWindow, ipcMain, shell, net, systemPreferences } = require("electron");

function log(...args) {
console.log(`[MSpring Theme]`, ...args);
Expand Down Expand Up @@ -283,6 +283,10 @@ ipcMain.handle("LiteLoader.mspring_theme.fetchData", (event, url) => {
return fetchData(url);
});

ipcMain.handle("LiteLoader.mspring_theme.readFile", (event, filePath) => {
return fs.readFileSync(filePath, "utf-8");
});

// 创建窗口时触发
module.exports.onBrowserWindowCreated = window => {
const settingsPath = path.join(pluginDataPath, "settings.json");
Expand Down
3 changes: 2 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ contextBridge.exposeInMainWorld("mspring_theme", {
...args
),
openWeb: (url) => ipcRenderer.send("LiteLoader.mspring_theme.openWeb", url),
fetchData: (url) => ipcRenderer.invoke("LiteLoader.mspring_theme.fetchData", url)
fetchData: (url) => ipcRenderer.invoke("LiteLoader.mspring_theme.fetchData", url),
readFile: (path) => ipcRenderer.invoke("LiteLoader.mspring_theme.readFile", path),
});
3 changes: 2 additions & 1 deletion renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ try {
// 判断插件lite_tools是否存在且启用
if (LiteLoader.plugins["lite_tools"] && !LiteLoader.plugins["lite_tools"].disabled) {
log("[检测]", "已启用轻量工具箱");
const ltOptions = await lite_tools.getOptions();
const ltData = await mspring_theme.readFile(LiteLoader.plugins["lite_tools"].path.data+"/config.json");
const ltOptions = JSON.parse(ltData);
if (ltOptions && ltOptions.background) {
if (ltOptions.background.enabled) {
log("[检测]", "已启用轻量工具箱-自定义背景");
Expand Down

0 comments on commit c93ebe8

Please sign in to comment.