From 87875a78b80aecd45067fd8ce2c30bdf88ac893b Mon Sep 17 00:00:00 2001 From: stapxs <1007028430.stapx@gmail.com> Date: Fri, 7 Jun 2024 15:15:25 +0800 Subject: [PATCH] =?UTF-8?q?[linux]=20=E4=B8=BA=E5=85=A8=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=AF=9B=E7=8E=BB=E7=92=83=E4=BB=98=E5=87=BA=E4=BA=86=E5=A4=AA?= =?UTF-8?q?=E5=A4=9A=20:sparkles:=20=E6=94=AF=E6=8C=81=20gnome=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20blur=20my=20shell=EF=BC=8Csql2=20=E4=BC=9A=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A3=80=E6=9F=A5=20gnome=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E9=80=8F=E6=98=8E=E6=A8=A1=E5=BC=8F=20:wheel?= =?UTF-8?q?chair:=20=E4=BB=8E=E5=BD=93=E5=89=8D=E7=89=88=E6=9C=AC=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=EF=BC=8C=E9=92=88=E5=AF=B9=E6=9F=90=E4=B8=AA=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E7=9A=84=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E5=B0=86?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E6=8E=A8=E9=80=81=E7=BB=99=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=EF=BC=8C=E4=BB=A5=E5=87=8F=E5=B0=91=E6=97=A0?= =?UTF-8?q?=E5=85=B3=E6=9B=B4=E6=96=B0=E7=9A=84=E9=A2=91=E7=8E=87=20:green?= =?UTF-8?q?=5Fheart:=20[build-electron]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/assets/css/append/append_gnome.css | 20 ++++++++++++++++++++ src/function/electron/ipc.ts | 22 +++++++++++++++++++++- src/function/electron/util.ts | 16 ++++++++++++++++ src/function/utils/appUtil.ts | 23 +++++++++++++++++++++++ 5 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 src/assets/css/append/append_gnome.css diff --git a/package.json b/package.json index d8b505a0..eec376e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stapxs-qq-lite", - "version": "2.7.11", + "version": "2.7.12", "private": false, "author": "Stapx Steve [林槐]", "description": "一个兼容 OneBot 的非官方网页版 QQ 客户端,使用 Vue 重制的全新版本。", @@ -14,8 +14,8 @@ "postuninstall": "electron-builder install-app-deps" }, "dependencies": { - "@stapxs/umami-logger-typescript": "^1.0.12", "@jakejarrett/gtk-theme": "^2.0.1", + "@stapxs/umami-logger-typescript": "^1.0.12", "browser-image-compression": "^2.0.0", "char-dust": "^0.1.0", "core-js": "^3.8.3", diff --git a/src/assets/css/append/append_gnome.css b/src/assets/css/append/append_gnome.css new file mode 100644 index 00000000..8b1e6593 --- /dev/null +++ b/src/assets/css/append/append_gnome.css @@ -0,0 +1,20 @@ +#app { + margin: 0; + width: calc(100% - 2px); + height: calc(100% - 2px); +} +.top-bar { + width: calc(100% - 2px); +} +.chat-pan.withBar { + height: calc(100% - 27px); + margin-right: 1px; + top: 1px; +} +.friend-list>div:last-child { + margin-left: 0; +} +.opt-main>div:last-child { + padding-top: 35px; + height: calc(100% - 26px); +} \ No newline at end of file diff --git a/src/function/electron/ipc.ts b/src/function/electron/ipc.ts index f84d92d7..966e27c4 100644 --- a/src/function/electron/ipc.ts +++ b/src/function/electron/ipc.ts @@ -4,7 +4,7 @@ import os from 'os' import { ipcMain, shell, systemPreferences, app, Menu, MenuItemConstructorOptions } from "electron" import { GtkTheme, GtkData } from '@jakejarrett/gtk-theme' -import { queryKeys } from './util' +import { queryKeys, runCommand } from './util' import { win } from '@/background' import { Notification as ELNotification } from 'electron' @@ -219,6 +219,26 @@ export function regIpcListener() { }}) return gtkTheme.getTheme().gtk.css }) + // Linux:获取 gnome extension 设置 + // dconf dump /org/gnome/shell/extensions/ | awk -v RS='' '/\[blur-my-shell\/applications\]/' + ipcMain.handle('sys:getGnomeExt', async () => { + try { + const info = await runCommand('dconf dump /org/gnome/shell/extensions/ | awk -v RS=\'\' \'/\\[blur-my-shell\\/applications\\]/\'') + const str = info.stdout as string + const data = {} as {[key: string]: string} + if(str && str.startsWith('[blur-my-shell/applications]')) { + const lines = str.split('\n').slice(1) + lines.forEach((line) => { + const [key, value] = line.split('=') + if(key != '') + data[key] = value + }) + } + return data + } catch(ex) { + return (ex as Error).message + } + }) // MacOS:初始化菜单 // PS:由于本地化的存在,需要让 vue 获取到本地化信息之后再由 electron 构建 diff --git a/src/function/electron/util.ts b/src/function/electron/util.ts index db4f0f40..9c74bf7f 100644 --- a/src/function/electron/util.ts +++ b/src/function/electron/util.ts @@ -14,4 +14,20 @@ export function queryKeys(keyPath: string, value: string) { reject(error) } }) as Promise<{stdout: any, stderr: any}> +} + +export function runCommand(command: string) { + return new Promise(function (resolve, reject) { + try { + child_process.exec(command, (error, stdout, stderr) => { + if (error) { + reject(error) + return + } + resolve({stdout, stderr}) + }); + } catch (error) { + reject(error) + } + }) as Promise<{stdout: any, stderr: any}> } \ No newline at end of file diff --git a/src/function/utils/appUtil.ts b/src/function/utils/appUtil.ts index c983258c..c1513d43 100644 --- a/src/function/utils/appUtil.ts +++ b/src/function/utils/appUtil.ts @@ -476,6 +476,22 @@ export function loadAppendStyle() { logger.info('透明 UI 附加样式加载完成') }) } + if(runtimeData.tags.isElectron && platform == 'linux') { + const gnomeExtInfo = runtimeData.reader?.invoke('sys:getGnomeExt') + if(gnomeExtInfo) { + gnomeExtInfo.then((info: any) => { + console.log(info) + if(info['enable-all'] == 'true' || info['whitelist'].indexOf('stapxs-qq-lite') != -1) { + import('@/assets/css/append/append_vibrancy.css').then(() => { + logger.info('透明 UI 附加样式加载完成') + }) + import('@/assets/css/append/append_gnome.css').then(() => { + logger.info('Blur my sell 附加样式加载完成') + }) + } + }) + } + } } export function checkUpdate() { @@ -519,6 +535,13 @@ function showGitChangeLog(version: string, mainTree: string, from: string) { // 过滤掉一些不作为更新记录的提交 info = info.filter((item: any) => !item.commit.message.startsWith('[nl]')) const json = info[0] + // 如果标题是 [ 开头的但不是 [platform],则不显示 + let platform = runtimeData.tags.platform + if(from == 'web') platform = 'web' + if (json.commit.message.startsWith('[') && !json.commit.message.startsWith('[' + platform + ']')) { + return + } + // 如果是 electron 构建的版本,只显示 [build-electron] 的提交 if (from == 'web' || json.commit.message.indexOf('[build-electron]') > 0) { const popInfo = { template: UpdatePan,