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:
parent
3e04eac482
commit
824f690b13
5 changed files with 44 additions and 16 deletions
47
electron.js
47
electron.js
|
@ -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');
|
||||
|
|
|
@ -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; }
|
|
@ -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">
|
||||
|
|
|
@ -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;
|
|
@ -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 });
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue