From 683b0701b584d417c0e783c7b69149584bbab4c5 Mon Sep 17 00:00:00 2001 From: Greyhoof <132987288+greyhoof@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:39:59 +0200 Subject: [PATCH 01/13] + Added new, empty dialog where the browser option is going to go + Added menu item to open browser option dialog --- electron/BrowserOption.vue | 114 +++++++++++++++++++++++++++++++++++ electron/browser_option.html | 14 +++++ electron/browser_option.ts | 26 ++++++++ electron/common.ts | 1 + electron/main.ts | 25 ++++++++ electron/webpack.config.js | 3 +- 6 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 electron/BrowserOption.vue create mode 100644 electron/browser_option.html create mode 100644 electron/browser_option.ts diff --git a/electron/BrowserOption.vue b/electron/BrowserOption.vue new file mode 100644 index 0000000..5ff127a --- /dev/null +++ b/electron/BrowserOption.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/electron/browser_option.html b/electron/browser_option.html new file mode 100644 index 0000000..a34ba1c --- /dev/null +++ b/electron/browser_option.html @@ -0,0 +1,14 @@ + + + + + + F-Chat + + + +
+ + + + diff --git a/electron/browser_option.ts b/electron/browser_option.ts new file mode 100644 index 0000000..451e173 --- /dev/null +++ b/electron/browser_option.ts @@ -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 = 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'); diff --git a/electron/common.ts b/electron/common.ts index 0425a81..198fd03 100644 --- a/electron/common.ts +++ b/electron/common.ts @@ -31,6 +31,7 @@ export class GeneralSettings { risingCacheExpiryDays = 30; risingSystemLogLevel: log.LevelOption = 'info'; risingDisableWindowsHighContrast = false; + browserCommand = ''; } // //tslint:disable diff --git a/electron/main.ts b/electron/main.ts index ee53899..bade67d 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -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(); + } } ] }, diff --git a/electron/webpack.config.js b/electron/webpack.config.js index f7893e5..924c549 100644 --- a/electron/webpack.config.js +++ b/electron/webpack.config.js @@ -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', From d173e5863ed8fed93f40c38fc79fa3bffad4b142 Mon Sep 17 00:00:00 2001 From: Greyhoof <132987288+greyhoof@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:29:37 +0200 Subject: [PATCH 02/13] x Fixed browser settings dialog (placeholder) so that it actually works and looks correct --- chat/localize.ts | 5 + electron/BrowserOption.vue | 181 ++++++++++++++++++++++------------- electron/browser_option.html | 2 +- electron/browser_option.ts | 5 +- electron/common.ts | 3 +- electron/main.ts | 16 +++- 6 files changed, 133 insertions(+), 79 deletions(-) diff --git a/chat/localize.ts b/chat/localize.ts index 36e998e..c7a1e9b 100644 --- a/chat/localize.ts +++ b/chat/localize.ts @@ -189,6 +189,11 @@ Current log location: {1}`, 'settings.beta': 'Opt-in to test unstable prerelease updates', 'settings.hwAcceleration': 'Enable hardware acceleration (requires restart)', 'settings.bbCodeBar': 'Show BBCode formatting bar', + 'settings.browserOption': 'Set command for opening clicked links', + 'settings.browserOptionTitle': 'Browser Path', + 'settings.browserOptionPath': 'Path to browser executable', + 'settings.browserOptionArguments': 'Arguments to pass to executable', + 'settings.browserOptionArgumentsHelp': 'Arguments are separated by spaces. Use %s to insert the URL.', 'fixLogs.action': 'Fix corrupted logs', 'fixLogs.text': `There are a few reason log files can become corrupted - log files from old versions with bugs that have since been fixed or incomplete file operations caused by computer crashes are the most common. If one of your log files is corrupted, you may get an "Unknown Type" error when you log in or when you open a specific tab. You may also experience other issues. diff --git a/electron/BrowserOption.vue b/electron/BrowserOption.vue index 5ff127a..c4d4a7f 100644 --- a/electron/BrowserOption.vue +++ b/electron/BrowserOption.vue @@ -1,8 +1,8 @@ `; } catch (e) { @@ -65,6 +96,12 @@ export default class BrowserOption extends Vue { } } + @Hook('mounted') + async mounted(): Promise { + this.browserPath = this.settings.browserPath; + this.browserArgs = this.settings.browserArgs; + } + minimize(): void { browserWindow.minimize(); } @@ -102,19 +139,29 @@ export default class BrowserOption extends Vue { } } - async load(): Promise { - this.browserPath = this.settings.browserPath; - this.browserArgs = this.settings.browserArgs; - } - async submit(): Promise { this.settings.browserPath = this.browserPath; this.settings.browserArgs = this.browserArgs; } + + browseForPath(): void { + ipcRenderer.invoke('browser-option-browse').then((result) => { + this.browserPath = result; + }); + } }