Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new BrowserWindow時に背景色を設定し、不具合#1425 を修正 #1446

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ async function uninstallVvppEngine(engineId: EngineId) {
}
}

// テーマの読み込み
const themes = readThemeFiles();
function readThemeFiles() {
const themes: ThemeConf[] = [];
const dir = path.join(__static, "themes");
for (const file of fs.readdirSync(dir)) {
const theme = JSON.parse(fs.readFileSync(path.join(dir, file)).toString());
themes.push(theme);
}
return themes;
}

// 使い方テキストの読み込み
const howToUseText = fs.readFileSync(
path.join(__static, HowToUseTextFileName),
Expand Down Expand Up @@ -467,6 +479,10 @@ async function createWindow() {
defaultHeight: 600,
});

const currentTheme = store.get("currentTheme");
const backgroundColor = themes.find((value) => value.name == currentTheme)
?.colors.background;

win = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
Expand All @@ -477,6 +493,7 @@ async function createWindow() {
trafficLightPosition: { x: 6, y: 4 },
minWidth: 320,
show: false,
backgroundColor,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: false,
Expand Down Expand Up @@ -900,14 +917,10 @@ ipcMainHandle("THEME", (_, { newData }) => {
store.set("currentTheme", newData);
return;
}
const dir = path.join(__static, "themes");
const themes: ThemeConf[] = [];
const files = fs.readdirSync(dir);
files.forEach((file) => {
const theme = JSON.parse(fs.readFileSync(path.join(dir, file)).toString());
themes.push(theme);
});
return { currentTheme: store.get("currentTheme"), availableThemes: themes };
return {
currentTheme: store.get("currentTheme"),
availableThemes: themes,
};
});

ipcMainHandle("ON_VUEX_READY", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/browser/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ export const api: Sandbox = {
await this.setSetting("currentTheme", newData);
return;
}
// NOTE: Electron版では起動時にテーマ情報が必要なので、
// この実装とは違って起動時に読み込んだキャッシュを返すだけになっている。
return Promise.all(
// FIXME: themeファイルのいい感じのパスの設定
["/themes/default.json", "/themes/dark.json"].map((url) =>
Expand Down