1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

dark theme in electron

This commit is contained in:
Andrew Simachev 2021-11-10 11:20:40 +03:00
parent 3e04eac482
commit 824f690b13
5 changed files with 44 additions and 16 deletions

View file

@ -185,7 +185,7 @@ function createWindow () {
});
let param = {
backgroundColor: '#fff',
backgroundColor: getBgColor(),
show: false,
x: state.x,
y: state.y,
@ -306,6 +306,10 @@ function createWindow () {
exit(true);
});
ipcMain.on('configSet', (e, config) => {
setConfig(config);
});
ipcMain.on('updateCancel', (e) => {
isUpdating = false;
clearTimeout(timeoutUpdate);
@ -355,23 +359,27 @@ function createWindow () {
};
});
storage.get(CONFIG_NAME, (error, data) => {
config = data || {};
config.channel = String(config.channel || defaultChannel);
autoUpdaterInit();
menuInit();
};
if (error) {
console.error(error);
};
function getBgColor () {
let { theme } = config;
let bg = '#fff';
Util.log('info', 'Config: ' + JSON.stringify(config, null, 3));
switch (theme) {
case 'dark':
bg = '#2c2b27';
break;
};
autoUpdaterInit();
menuInit();
});
return bg;
};
function openAboutWindow () {
let { theme } = config;
let window = new BrowserWindow({
backgroundColor: getBgColor(),
width: 400,
height: 400,
useContentSize: true,
@ -383,7 +391,7 @@ function openAboutWindow () {
},
});
window.loadURL('file://' + path.join(__dirname, 'electron', 'about.html?version=' + version));
window.loadURL('file://' + path.join(__dirname, 'electron', `about.html?version=${version}&theme=${theme}`));
window.once('closed', () => {
window = null;
@ -719,7 +727,20 @@ function autoUpdaterInit () {
});
};
app.on('ready', waitForLibraryAndCreateWindows);
app.on('ready', () => {
storage.get(CONFIG_NAME, (error, data) => {
config = data || {};
config.channel = String(config.channel || defaultChannel);
if (error) {
console.error(error);
};
Util.log('info', 'Config: ' + JSON.stringify(config, null, 3));
waitForLibraryAndCreateWindows();
});
});
app.on('second-instance', (event, argv, cwd) => {
Util.log('info', 'second-instance');

View file

@ -37,4 +37,8 @@ body {
font-size: 14px; vertical-align: middle; position: relative; overflow: hidden; letter-spacing: 0.2px;
background: #ffb522; color: #fff;
}
.buttons button:hover { background: #f1981a; }
.buttons button:hover { background: #f1981a; }
html.dark body { background: #2c2b27; color: #929082; }
html.dark .title { color: #cbc9bd; }
html.dark .copyright { color: #5c5a54; }

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html id="html">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">

View file

@ -12,4 +12,5 @@ document.getElementById('version').innerText = 'Version: ' + param.version;
document.getElementById('close').addEventListener('click', e => {
e.preventDefault();
window.close();
});
});
document.getElementById('html').className = param.theme;

View file

@ -27,6 +27,7 @@ interface Cover {
};
const $ = require('jquery');
const { ipcRenderer } = window.require('electron');
class CommonStore {
@ -183,6 +184,7 @@ class CommonStore {
Storage.set('theme', v);
Util.addBodyClass('theme', v);
ipcRenderer.send('configSet', { theme: v });
analytics.event('ThemeSet', { id: v });
};