+ Added new, empty dialog where the browser option is going to go
+ Added menu item to open browser option dialog
This commit is contained in:
parent
7bad376750
commit
683b0701b5
|
@ -0,0 +1,114 @@
|
|||
<template>
|
||||
<div style="display: flex;flex-direction:column;height:100%" :class="getThemeClass()" @auxclick.prevent>
|
||||
<div v-html="styling"></div>
|
||||
<div style="display:flex;align-items:stretch;border-bottom-width:1px" class="border-bottom" id="window-tabs">
|
||||
<h4 style="padding:2px 0">F-Chat</h4>
|
||||
<div style="flex:1;display:flex;justify-content:flex-end;-webkit-app-region:drag" class="btn-group"
|
||||
id="windowButtons">
|
||||
<i class="far fa-window-minimize btn btn-light" @click.stop="minimize()"></i>
|
||||
<i class="far btn btn-light" :class="'fa-window-' + (isMaximized ? 'restore' : 'maximize')" @click="maximize()"></i>
|
||||
<span class="btn btn-light" @click.stop="close()">
|
||||
<i class="fa fa-times fa-lg"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {Component} from '@f-list/vue-ts';
|
||||
import * as remote from '@electron/remote';
|
||||
import Vue from 'vue';
|
||||
import l from '../chat/localize';
|
||||
import {GeneralSettings} from './common';
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const browserWindow = remote.getCurrentWindow();
|
||||
@Component
|
||||
export default class BrowserOption extends Vue {
|
||||
settings!: GeneralSettings;
|
||||
isMaximized = false;
|
||||
l = l;
|
||||
platform = process.platform;
|
||||
hasCompletedUpgrades = false;
|
||||
|
||||
get styling(): string {
|
||||
try {
|
||||
return `<style>${fs.readFileSync(path.join(__dirname, `themes/${this.settings.theme}.css`), 'utf8').toString()}</style>`;
|
||||
} catch(e) {
|
||||
if((<Error & {code: string}>e).code === 'ENOENT' && this.settings.theme !== 'default') {
|
||||
this.settings.theme = 'default';
|
||||
return this.styling;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
minimize(): void {
|
||||
browserWindow.minimize();
|
||||
}
|
||||
|
||||
maximize(): void {
|
||||
if(browserWindow.isMaximized()) browserWindow.unmaximize();
|
||||
else browserWindow.maximize();
|
||||
}
|
||||
|
||||
close(): void {
|
||||
browserWindow.close();
|
||||
}
|
||||
|
||||
getThemeClass() {
|
||||
// console.log('getThemeClassWindow', this.settings?.risingDisableWindowsHighContrast);
|
||||
|
||||
try {
|
||||
// Hack!
|
||||
if (process.platform === 'win32') {
|
||||
if (this.settings?.risingDisableWindowsHighContrast) {
|
||||
document.querySelector('html')?.classList.add('disableWindowsHighContrast');
|
||||
} else {
|
||||
document.querySelector('html')?.classList.remove('disableWindowsHighContrast');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
['platform-' + this.platform]: true,
|
||||
disableWindowsHighContrast: this.settings?.risingDisableWindowsHighContrast || false
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
['platform-' + this.platform]: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
#windowButtons .btn {
|
||||
border-top: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.platform-darwin {
|
||||
#windowButtons .btn, #settings {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#window-tabs {
|
||||
h4 {
|
||||
margin: 0 15px 0 77px;
|
||||
}
|
||||
|
||||
.btn, li a {
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.disableWindowsHighContrast, .disableWindowsHighContrast * {
|
||||
forced-color-adjust: none;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline'; img-src https://static.f-list.net">
|
||||
<title>F-Chat</title>
|
||||
<link href="fa.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="browser-option"></div>
|
||||
<script type="text/javascript" src="common.js"></script>
|
||||
<script type="text/javascript" src="browser_option.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
import * as qs from 'querystring';
|
||||
import log from 'electron-log'; //tslint:disable-line:match-default-export-name
|
||||
|
||||
import {GeneralSettings} from './common';
|
||||
import BrowserOption from './BrowserOption.vue';
|
||||
|
||||
log.info('init.browser_option');
|
||||
|
||||
const params = <{[key: string]: string | undefined}>qs.parse(window.location.search.substr(1));
|
||||
const settings = <GeneralSettings>JSON.parse(params['settings']!);
|
||||
|
||||
const logLevel = (process.env.NODE_ENV === 'production') ? 'info' : 'silly';
|
||||
|
||||
log.transports.file.level = settings.risingSystemLogLevel || logLevel;
|
||||
log.transports.console.level = settings.risingSystemLogLevel || logLevel;
|
||||
log.transports.file.maxSize = 5 * 1024 * 1024;
|
||||
|
||||
log.info('init.browser_option.vue');
|
||||
|
||||
//tslint:disable-next-line:no-unused-expression
|
||||
export default new BrowserOption({
|
||||
el: '#browser-option',
|
||||
data: {settings}
|
||||
});
|
||||
|
||||
log.debug('init.browser_option.vue.done');
|
|
@ -31,6 +31,7 @@ export class GeneralSettings {
|
|||
risingCacheExpiryDays = 30;
|
||||
risingSystemLogLevel: log.LevelOption = 'info';
|
||||
risingDisableWindowsHighContrast = false;
|
||||
browserCommand = '';
|
||||
}
|
||||
|
||||
// //tslint:disable
|
||||
|
|
|
@ -284,6 +284,25 @@ function showPatchNotes(): void {
|
|||
electron.shell.openExternal('https://github.com/hearmeneigh/fchat-rising/blob/master/CHANGELOG.md');
|
||||
}
|
||||
|
||||
function openBrowserSettings(): void {
|
||||
const windowProperties: electron.BrowserWindowConstructorOptions = {
|
||||
center: true,
|
||||
show: false,
|
||||
icon: process.platform === 'win32' ? winIcon : pngIcon,
|
||||
webPreferences: {
|
||||
webviewTag: true, nodeIntegration: true, nodeIntegrationInWorker: true, spellcheck: true,
|
||||
enableRemoteModule: true, contextIsolation: false, partition: 'persist:fchat'
|
||||
} as any
|
||||
};
|
||||
|
||||
const browserWindow = new electron.BrowserWindow(windowProperties);
|
||||
browserWindow.removeMenu();
|
||||
browserWindow.loadFile(path.join(__dirname, 'browser_option.html')).then(r => {
|
||||
console.log(r);
|
||||
browserWindow.show();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let zoomLevel = 0;
|
||||
|
||||
|
@ -529,6 +548,12 @@ function onReady(): void {
|
|||
settings.risingDisableWindowsHighContrast = item.checked;
|
||||
setGeneralSettings(settings);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Set command for opening clicked links',
|
||||
click: () => {
|
||||
openBrowserSettings();
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -47,7 +47,8 @@ const mainConfig = {
|
|||
}, rendererConfig = {
|
||||
entry: {
|
||||
chat: [path.join(__dirname, 'chat.ts'), path.join(__dirname, 'index.html')],
|
||||
window: [path.join(__dirname, 'window.ts'), path.join(__dirname, 'window.html'), path.join(__dirname, 'build', 'tray@2x.png')]
|
||||
window: [path.join(__dirname, 'window.ts'), path.join(__dirname, 'window.html'), path.join(__dirname, 'build', 'tray@2x.png')],
|
||||
browser_option: [path.join(__dirname, 'browser_option.ts'), path.join(__dirname, 'browser_option.html'), path.join(__dirname, 'build', 'tray@2x.png')]
|
||||
},
|
||||
output: {
|
||||
path: __dirname + '/app',
|
||||
|
|
Loading…
Reference in New Issue