Skip to content

Commit

Permalink
[linux] 为全平台毛玻璃付出了太多
Browse files Browse the repository at this point in the history
✨ 支持 gnome 插件 blur my shell,sql2 会自动检查 gnome 配置启用透明模式
♿ 从当前版本开始,针对某个平台的版本更新将不会推送给其他平台,以减少无关更新的频率
💚 [build-electron]
  • Loading branch information
Stapxs committed Jun 7, 2024
1 parent 7d26539 commit 87875a7
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 重制的全新版本。",
Expand All @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions src/assets/css/append/append_gnome.css
Original file line number Diff line number Diff line change
@@ -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);
}
22 changes: 21 additions & 1 deletion src/function/electron/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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 构建
Expand Down
16 changes: 16 additions & 0 deletions src/function/electron/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}>
}
23 changes: 23 additions & 0 deletions src/function/utils/appUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 87875a7

Please sign in to comment.