Skip to content

Commit e7302b6

Browse files
committed
optimize: Update main
optimize: Update release optimize: Update test optimize: Update optimize: Update README.en-US optimize: Update README optimize: Update changelog optimize: Update electron-builder
1 parent 07d6a62 commit e7302b6

23 files changed

Lines changed: 1827 additions & 1820 deletions

‎.github/workflows/main.yml‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- name: Setup Node.js
6262
uses: actions/setup-node@v4
6363
with:
64-
node-version: 20
64+
node-version: 24
6565

6666
- name: Setup Go
6767
uses: actions/setup-go@v5
@@ -156,24 +156,11 @@ jobs:
156156
working-directory: code
157157
shell: pwsh
158158
run: |
159-
# Skip lifecycle scripts: better-sqlite3 12.x ships no prebuilt binaries
160-
# for Node 20 (ABI 115), so a plain `npm install` falls back to node-gyp
161-
# and fails on the current runner image (node-gyp 10.1.0 cannot detect
162-
# Visual Studio 18 / VS2026). Nothing in this build needs a Node-ABI
163-
# binary - the app loads the Electron-ABI build created below.
159+
# Skip lifecycle scripts: every native module in this build is N-API based
160+
# (better-sqlite3 ships prebuilt binaries for each platform, node-mac-permissions
161+
# is macOS-only), so nothing has to be rebuilt for the Electron ABI and no
162+
# compiler is involved.
164163
npm install --ignore-scripts
165-
# iconv is an unused native dependency (iconv-lite is used instead).
166-
# Dropping binding.gyp keeps electron-builder from rebuilding it.
167-
if (Test-Path "node_modules\iconv\binding.gyp") {
168-
Remove-Item "node_modules\iconv\binding.gyp" -Force
169-
}
170-
if (Test-Path "node_modules\iconv\build") {
171-
Remove-Item -Recurse -Force "node_modules\iconv\build"
172-
}
173-
# Rebuild native modules against the Electron ABI. better-sqlite3
174-
# publishes electron-v121 (Electron 29) prebuilt binaries, so this
175-
# downloads them instead of invoking a compiler.
176-
npx electron-builder install-app-deps
177164
178165
- name: Build Release Files
179166
working-directory: code

‎.github/workflows/release.yml‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Setup Node.js
6161
uses: actions/setup-node@v4
6262
with:
63-
node-version: 20
63+
node-version: 24
6464

6565
- name: Setup Go
6666
uses: actions/setup-go@v5
@@ -153,24 +153,11 @@ jobs:
153153
working-directory: code
154154
shell: pwsh
155155
run: |
156-
# Skip lifecycle scripts: better-sqlite3 12.x ships no prebuilt binaries
157-
# for Node 20 (ABI 115), so a plain `npm install` falls back to node-gyp
158-
# and fails on the current runner image (node-gyp 10.1.0 cannot detect
159-
# Visual Studio 18 / VS2026). Nothing in this build needs a Node-ABI
160-
# binary - the app loads the Electron-ABI build created below.
156+
# Skip lifecycle scripts: every native module in this build is N-API based
157+
# (better-sqlite3 ships prebuilt binaries for each platform, node-mac-permissions
158+
# is macOS-only), so nothing has to be rebuilt for the Electron ABI and no
159+
# compiler is involved.
161160
npm install --ignore-scripts
162-
# iconv is an unused native dependency (iconv-lite is used instead).
163-
# Dropping binding.gyp keeps electron-builder from rebuilding it.
164-
if (Test-Path "node_modules\iconv\binding.gyp") {
165-
Remove-Item "node_modules\iconv\binding.gyp" -Force
166-
}
167-
if (Test-Path "node_modules\iconv\build") {
168-
Remove-Item -Recurse -Force "node_modules\iconv\build"
169-
}
170-
# Rebuild native modules against the Electron ABI. better-sqlite3
171-
# publishes electron-v121 (Electron 29) prebuilt binaries, so this
172-
# downloads them instead of invoking a compiler.
173-
npx electron-builder install-app-deps
174161
175162
- name: Build Release Files
176163
working-directory: code

‎.github/workflows/test.yml‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Setup Node.js
4040
uses: actions/setup-node@v4
4141
with:
42-
node-version: 20
42+
node-version: 24
4343

4444
- name: Setup Go
4545
uses: actions/setup-go@v5
@@ -130,24 +130,11 @@ jobs:
130130
if: runner.os == 'Windows'
131131
shell: pwsh
132132
run: |
133-
# Skip lifecycle scripts: better-sqlite3 12.x ships no prebuilt binaries
134-
# for Node 20 (ABI 115), so a plain `npm install` falls back to node-gyp
135-
# and fails on the current runner image (node-gyp 10.1.0 cannot detect
136-
# Visual Studio 18 / VS2026). Nothing in this build needs a Node-ABI
137-
# binary - the app loads the Electron-ABI build created below.
133+
# Skip lifecycle scripts: every native module in this build is N-API based
134+
# (better-sqlite3 ships prebuilt binaries for each platform, node-mac-permissions
135+
# is macOS-only), so nothing has to be rebuilt for the Electron ABI and no
136+
# compiler is involved.
138137
npm install --ignore-scripts
139-
# iconv is an unused native dependency (iconv-lite is used instead).
140-
# Dropping binding.gyp keeps electron-builder from rebuilding it.
141-
if (Test-Path "node_modules\iconv\binding.gyp") {
142-
Remove-Item "node_modules\iconv\binding.gyp" -Force
143-
}
144-
if (Test-Path "node_modules\iconv\build") {
145-
Remove-Item -Recurse -Force "node_modules\iconv\build"
146-
}
147-
# Rebuild native modules against the Electron ABI. better-sqlite3
148-
# publishes electron-v121 (Electron 29) prebuilt binaries, so this
149-
# downloads them instead of invoking a compiler.
150-
npx electron-builder install-app-deps
151138
152139
- name: Build Release Files
153140
run: npm run build

‎.nvmrc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
24

‎README.en-US.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Choose from **Light**, **Dark**, or **Follow System** themes for a comfortable v
162162

163163
## 🚀 Development
164164

165-
> Tested with **Node.js 20** only.
165+
> Tested with **Node.js 24** only.
166166
167167
```bash
168168
# Clone the repository

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162

163163
## 🚀 本地开发
164164

165-
> 仅在 **Node.js 20** 环境下测试过。
165+
> 仅在 **Node.js 24** 环境下测试过。
166166
167167
```bash
168168
# 克隆仓库

‎changelog.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- 修复:投屏期间同时运行预览进程,部分机型会因两个画面编码互相抢占而让投屏断开,现在投屏时不再额外启动预览,投屏结束后自动恢复预览
77
- 修复:部分机型预览进程反复启动失败时每几秒重试一次,导致投屏窗口被拖断、投屏状态反复跳变,现在失败会逐步退避并在多次失败后停止重试
88
- 修复:设备已经从电脑断开时仍会尝试拉起投屏窗口并报错,现在会先确认设备在线,掉线重连时也不会短时间内反复弹窗
9+
- 优化:软件运行内核升级到新版本,网页与视频渲染、音视频解码同步更新,并合入最新的系统安全补丁
10+
- 优化:设备设置弹窗标题直接写明「设备设置」,一眼可知弹窗用途
911

1012
## v2.5.0 自动更新上线,软件自己检查并安装新版本
1113

‎electron-builder.json5‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
44
"appId": "LinkAndroid",
55
"asar": true,
6-
"npmRebuild": true,
6+
"npmRebuild": false,
77
"publish": [],
88
"productName": "LinkAndroid",
99
"directories": {
@@ -97,10 +97,10 @@
9797
"entitlementsInherit": "./entitlements.mac.plist",
9898
"entitlements": "./entitlements.mac.plist",
9999
"extendInfo": {
100-
"NSDocumentsFolderUsageDescription": "Application requests access to the user's Documents folder."
100+
"NSDocumentsFolderUsageDescription": "Application requests access to the user's Documents folder.",
101+
"NSAudioCaptureUsageDescription": "Application requests access to record system audio while capturing the screen."
101102
},
102103
"type": "development",
103-
"notarize": false,
104104
"darkModeSupport": true,
105105
"hardenedRuntime": true,
106106
"identity": null

‎electron/lib/env-main.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import url, {fileURLToPath} from 'node:url'
2-
import {BrowserView, BrowserWindow} from 'electron'
2+
import {BrowserWindow} from 'electron'
33
import {isPackaged} from './env'
44
import path, {join} from 'node:path'
55
import {Log} from '../mapi/log/main'
@@ -16,20 +16,11 @@ process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT,
1616

1717
export const preloadDefault = path.join(MAIN_DIST, 'preload/index.cjs')
1818

19-
export const rendererLoadPath = (window: BrowserWindow | BrowserView, fileName: string) => {
19+
export const rendererLoadPath = (window: BrowserWindow, fileName: string) => {
2020
if (!isPackaged && process.env.VITE_DEV_SERVER_URL) {
21-
const x = new url.URL(rendererDistPath(fileName))
22-
if (window instanceof BrowserView) {
23-
window.webContents.loadURL(x.toString())
24-
} else {
25-
window.loadURL(x.toString())
26-
}
21+
window.loadURL(new url.URL(rendererDistPath(fileName)).toString())
2722
} else {
28-
if (window instanceof BrowserView) {
29-
window.webContents.loadFile(rendererDistPath(fileName))
30-
} else {
31-
window.loadFile(rendererDistPath(fileName))
32-
}
23+
window.loadFile(rendererDistPath(fileName))
3324
}
3425
}
3526

‎electron/mapi/app/main.ts‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {app, BrowserWindow, clipboard, ipcMain, nativeImage, nativeTheme, screen, shell} from 'electron'
1+
import {app, BrowserWindow, clipboard, ClipboardItem, ipcMain, nativeImage, nativeTheme, screen, shell} from 'electron'
22
import {execSync} from 'node:child_process'
33
import {existsSync} from 'node:fs'
44
import {resolve} from 'node:path'
@@ -191,24 +191,35 @@ ipcMain.handle(
191191
)
192192

193193
const getClipboardText = () => {
194-
return clipboard.readText('clipboard')
194+
return clipboard.readText()
195195
}
196196

197197
ipcMain.handle('app:getClipboardText', (event) => {
198198
return getClipboardText()
199199
})
200200

201201
const setClipboardText = (text: string) => {
202-
clipboard.writeText(text, 'clipboard')
202+
return clipboard.writeText(text)
203203
}
204204

205205
ipcMain.handle('app:setClipboardText', (event, text: string) => {
206-
setClipboardText(text)
206+
return setClipboardText(text)
207207
})
208208

209-
const getClipboardImage = () => {
210-
const image = clipboard.readImage('clipboard')
211-
return image.isEmpty() ? '' : image.toDataURL()
209+
const getClipboardImage = async () => {
210+
const items = await clipboard.read()
211+
for (const item of items) {
212+
const type = item.types.find((t) => t.startsWith('image/'))
213+
if (!type) {
214+
continue
215+
}
216+
const blob = (await item.getType(type)) as Blob
217+
const image = nativeImage.createFromBuffer(Buffer.from(await blob.arrayBuffer()))
218+
if (!image.isEmpty()) {
219+
return image.toDataURL()
220+
}
221+
}
222+
return ''
212223
}
213224

214225
ipcMain.handle('app:getClipboardImage', (event) => {
@@ -217,11 +228,12 @@ ipcMain.handle('app:getClipboardImage', (event) => {
217228

218229
const setClipboardImage = (image: string) => {
219230
const img = nativeImage.createFromDataURL(image)
220-
clipboard.writeImage(img, 'clipboard')
231+
const png = new Uint8Array(img.toPNG())
232+
return clipboard.write([new ClipboardItem({'image/png': new Blob([png], {type: 'image/png'})})])
221233
}
222234

223235
ipcMain.handle('app:setClipboardImage', (event, image: string) => {
224-
setClipboardImage(image)
236+
return setClipboardImage(image)
225237
})
226238

227239
const isDarkMode = () => {

0 commit comments

Comments
 (0)