Add: Option to toggle DPI scaling

This commit is contained in:
LmeSzinc 2022-01-16 12:16:59 +08:00
parent b46d7dea19
commit 186c78eae9
5 changed files with 13 additions and 5 deletions

View File

@ -99,6 +99,10 @@ Deploy:
# 'default' for light theme
# 'dark' for dark theme
Theme: default
# Follow system DPI scaling
# [In most cases] true
# [In few cases] false to make Alas smaller, if you have a low resolution but high DPI scaling.
DpiScaling: true
# --key. Password of web ui
# Useful when expose Alas to the public network
Password: null

View File

@ -20,4 +20,4 @@ aiofiles
wrapt==1.13.1
prettytable==2.2.1
pypresence==4.2.1
alas-webapp==0.3.6
alas-webapp==0.3.7

View File

@ -6,7 +6,7 @@
#
adbutils==0.11.0 # via uiautomator2
aiofiles==0.7.0 # via -r requirements-in.txt
alas-webapp==0.3.6 # via -r requirements-in.txt
alas-webapp==0.3.7 # via -r requirements-in.txt
anyio==1.3.1 # via -r requirements-in.txt
apkutils2==1.0.0 # via adbutils
asgiref==3.4.1 # via uvicorn

View File

@ -14,3 +14,4 @@ export const pythonPath = (path.isAbsolute(PythonExecutable) ? PythonExecutable
export const webuiUrl = `http://127.0.0.1:${WebuiPort}`;
export const webuiPath = 'gui.py';
export const webuiArgs = ['--port', WebuiPort, '--electron'];
export const dpiScaling = Boolean(config.Deploy.Webui.DpiScaling) || (config.Deploy.Webui.DpiScaling === undefined) ;

View File

@ -1,7 +1,7 @@
import {app, Menu, Tray, BrowserWindow, ipcMain, globalShortcut} from 'electron';
import {URL} from 'url';
import {PyShell} from '/@/pyshell';
import {webuiArgs, webuiPath} from '/@/config';
import {webuiArgs, webuiPath, dpiScaling} from '/@/config';
const path = require('path');
@ -143,8 +143,11 @@ const createWindow = async () => {
// No DPI scaling
// app.commandLine.appendSwitch('high-dpi-support', '1');
// app.commandLine.appendSwitch('force-device-scale-factor', '1');
if (!dpiScaling) {
app.commandLine.appendSwitch('high-dpi-support', '1');
app.commandLine.appendSwitch('force-device-scale-factor', '1');
}
function loadURL() {
/**