Skip to content

Commit 657775e

Browse files
committed
chore(release): 发布 1.1.7-rc.202604131019
1 parent 0fd9a64 commit 657775e

21 files changed

Lines changed: 499 additions & 90 deletions

backlog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ mixtape应该增加一个loop功能,可以loop一段
2727

2828
要加一个菜单,一键将其他格式转为mp3
2929

30-
其实可以记录下用户加入过筛选库的歌手的名字,后续再碰到可以高亮,还可以加一个窗口来展示给用户看,用户可以自己编辑或删除
30+
双轨横推还没有控制音量的东西

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frkb",
3-
"version": "1.1.7-rc.202604130913",
3+
"version": "1.1.7-rc.202604131019",
44
"description": "Rapid Audio Organization Tool",
55
"license": "GPL-2.0-or-later",
66
"main": "./out/main/index.js",

scripts/find-long-files.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function parseArgs(argv) {
3030
root: '.',
3131
gt: 1200,
3232
ext: ['.ts', '.tsx', '.js', '.jsx', '.vue', '.css', '.scss', '.json', '.md'],
33-
exclude: ['node_modules', 'dist', 'out', '.git', '.vitepress','vendor'],
33+
exclude: ['node_modules', 'dist', 'out', '.git', '.vitepress','vendor','.codex_tmp'],
3434
json: false
3535
}
3636
for (let i = 2; i < argv.length; i++) {

src/main/layoutConfig.ts

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,20 @@ import fs = require('fs-extra')
22
import type { ILayoutConfig } from 'src/types/globals'
33
import { log } from './log'
44
import url from './url'
5-
6-
type MainWindowSizeMigration = {
7-
version: number
8-
minWidth: number
9-
minHeight: number
10-
}
11-
12-
const MAIN_WINDOW_SIZE_MIGRATIONS: MainWindowSizeMigration[] = [
13-
{
14-
version: 1,
15-
minWidth: 1200,
16-
minHeight: 720
17-
}
18-
]
19-
20-
const latestMainWindowSizeMigration = MAIN_WINDOW_SIZE_MIGRATIONS[
21-
MAIN_WINDOW_SIZE_MIGRATIONS.length - 1
22-
] ?? {
23-
version: 0,
24-
minWidth: 900,
25-
minHeight: 600
26-
}
27-
28-
export const MAIN_WINDOW_DEFAULT_WIDTH = latestMainWindowSizeMigration.minWidth
29-
export const MAIN_WINDOW_DEFAULT_HEIGHT = latestMainWindowSizeMigration.minHeight
30-
export const MAIN_WINDOW_MIN_WIDTH = latestMainWindowSizeMigration.minWidth
31-
export const MAIN_WINDOW_MIN_HEIGHT = latestMainWindowSizeMigration.minHeight
32-
33-
export const defaultLayoutConfig: ILayoutConfig = {
34-
libraryAreaWidth: 175,
35-
isMaxMainWin: false,
36-
mainWindowWidth: MAIN_WINDOW_DEFAULT_WIDTH,
37-
mainWindowHeight: MAIN_WINDOW_DEFAULT_HEIGHT,
38-
mainWindowSizeMigrationVersion: latestMainWindowSizeMigration.version
39-
}
5+
import {
6+
MAIN_WINDOW_MIN_HEIGHT,
7+
MAIN_WINDOW_MIN_WIDTH,
8+
MAIN_WINDOW_SIZE_MIGRATIONS,
9+
defaultLayoutConfig
10+
} from './layoutConfigDefaults'
11+
12+
export {
13+
MAIN_WINDOW_DEFAULT_HEIGHT,
14+
MAIN_WINDOW_DEFAULT_WIDTH,
15+
MAIN_WINDOW_MIN_HEIGHT,
16+
MAIN_WINDOW_MIN_WIDTH,
17+
defaultLayoutConfig
18+
} from './layoutConfigDefaults'
4019

4120
const isRecord = (value: unknown): value is Record<string, unknown> =>
4221
typeof value === 'object' && value !== null && !Array.isArray(value)

src/main/layoutConfigDefaults.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { ILayoutConfig } from 'src/types/globals'
2+
3+
type MainWindowSizeMigration = {
4+
version: number
5+
minWidth: number
6+
minHeight: number
7+
}
8+
9+
export const MAIN_WINDOW_SIZE_MIGRATIONS: MainWindowSizeMigration[] = [
10+
{
11+
version: 1,
12+
minWidth: 1200,
13+
minHeight: 720
14+
}
15+
]
16+
17+
const latestMainWindowSizeMigration = MAIN_WINDOW_SIZE_MIGRATIONS[
18+
MAIN_WINDOW_SIZE_MIGRATIONS.length - 1
19+
] ?? {
20+
version: 0,
21+
minWidth: 900,
22+
minHeight: 600
23+
}
24+
25+
export const MAIN_WINDOW_DEFAULT_WIDTH = latestMainWindowSizeMigration.minWidth
26+
export const MAIN_WINDOW_DEFAULT_HEIGHT = latestMainWindowSizeMigration.minHeight
27+
export const MAIN_WINDOW_MIN_WIDTH = latestMainWindowSizeMigration.minWidth
28+
export const MAIN_WINDOW_MIN_HEIGHT = latestMainWindowSizeMigration.minHeight
29+
30+
export const defaultLayoutConfig: ILayoutConfig = {
31+
libraryAreaWidth: 175,
32+
isMaxMainWin: false,
33+
mainWindowWidth: MAIN_WINDOW_DEFAULT_WIDTH,
34+
mainWindowHeight: MAIN_WINDOW_DEFAULT_HEIGHT,
35+
mainWindowSizeMigrationVersion: latestMainWindowSizeMigration.version
36+
}

src/main/log.ts

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,74 @@
1-
import url from './url'
21
import path = require('path')
3-
import { app } from 'electron'
42
import fs = require('fs-extra')
5-
export import log = require('electron-log')
3+
4+
type ElectronAppLike = {
5+
isPackaged?: boolean
6+
getVersion?: () => string
7+
getPath?: (name: string) => string
8+
}
9+
10+
type LogTransportFileLike = {
11+
level?: string
12+
format?: string
13+
maxSize?: number
14+
resolvePathFn?: () => string
15+
}
16+
17+
type LoggerLike = {
18+
debug: (...args: unknown[]) => void
19+
info: (...args: unknown[]) => void
20+
warn: (...args: unknown[]) => void
21+
error: (...args: unknown[]) => void
22+
transports: {
23+
file: LogTransportFileLike
24+
}
25+
}
26+
27+
const safeRequire = (id: string): unknown => {
28+
try {
29+
const dynamicRequire = Function('return require')() as NodeRequire
30+
return dynamicRequire(id)
31+
} catch {
32+
return null
33+
}
34+
}
35+
36+
const electronModule =
37+
(safeRequire('electron') as {
38+
app?: ElectronAppLike
39+
} | null) || null
40+
const electronApp = electronModule?.app || null
41+
42+
const createConsoleLogger = (): LoggerLike => ({
43+
debug: (...args: unknown[]) => console.debug(...args),
44+
info: (...args: unknown[]) => console.info(...args),
45+
warn: (...args: unknown[]) => console.warn(...args),
46+
error: (...args: unknown[]) => console.error(...args),
47+
transports: {
48+
file: {}
49+
}
50+
})
51+
52+
const loadedElectronLog =
53+
(safeRequire('electron-log') as Partial<LoggerLike> | null | undefined) || null
54+
55+
export const log: LoggerLike =
56+
loadedElectronLog &&
57+
typeof loadedElectronLog.debug === 'function' &&
58+
typeof loadedElectronLog.info === 'function' &&
59+
typeof loadedElectronLog.warn === 'function' &&
60+
typeof loadedElectronLog.error === 'function'
61+
? ({
62+
...loadedElectronLog,
63+
transports: {
64+
file: loadedElectronLog.transports?.file || {}
65+
}
66+
} as LoggerLike)
67+
: createConsoleLogger()
668

769
const isPackagedRuntime = (() => {
870
try {
9-
return !!(app && typeof app.isPackaged === 'boolean' && app.isPackaged)
71+
return !!(electronApp && typeof electronApp.isPackaged === 'boolean' && electronApp.isPackaged)
1072
} catch {
1173
return false
1274
}
@@ -18,35 +80,40 @@ const isDevRuntime = (() => {
1880
return !isPackagedRuntime
1981
})()
2082

21-
log.transports.file.level = 'debug' // 设置日志级别
83+
const resolveUserDataDir = () => {
84+
if (!isPackagedRuntime) return __dirname
85+
try {
86+
const resolved = electronApp?.getPath?.('userData')
87+
return typeof resolved === 'string' && resolved.trim() ? resolved : __dirname
88+
} catch {
89+
return __dirname
90+
}
91+
}
92+
2293
const appVersion = (() => {
2394
try {
24-
return app.getVersion()
25-
} catch (_e) {
95+
const resolved = electronApp?.getVersion?.()
96+
return typeof resolved === 'string' && resolved.trim() ? resolved : 'unknown'
97+
} catch {
2698
return 'unknown'
2799
}
28100
})()
29-
log.transports.file.format = `{y}-{m}-{d} {h}:{i}:{s}.{ms} [v${appVersion}] {text}` // 自定义日志格式,带版本号
30-
log.transports.file.maxSize = 20 * 1024 * 1024 // 提高上限,避免长时间追踪时日志过快轮转
31101

32-
// dev 模式下日志保存在项目根目录,生产模式下保存在用户数据目录
102+
log.transports.file.level = 'debug'
103+
log.transports.file.format = `{y}-{m}-{d} {h}:{i}:{s}.{ms} [v${appVersion}] {text}`
104+
log.transports.file.maxSize = 20 * 1024 * 1024
33105
log.transports.file.resolvePathFn = () => {
34106
if (isDevRuntime) {
35-
// dev 模式:保存到项目根目录
36107
return path.join(process.cwd(), 'log.txt')
37-
} else {
38-
// 生产模式:保存到用户数据目录
39-
return path.join(url.userDataDir, 'log.txt')
40108
}
109+
return path.join(resolveUserDataDir(), 'log.txt')
41110
}
42111

43-
// 导出获取日志路径的函数,供其他模块使用
44112
export function getLogPath(): string {
45113
if (isDevRuntime) {
46114
return path.join(process.cwd(), 'log.txt')
47-
} else {
48-
return path.join(url.userDataDir, 'log.txt')
49115
}
116+
return path.join(resolveUserDataDir(), 'log.txt')
50117
}
51118

52119
export function clearLogFileSync(): void {
@@ -68,7 +135,6 @@ type ErrorLike = {
68135
message?: unknown
69136
}
70137

71-
// 预期内错误规则集中定义,后续可在此追加
72138
const expectedErrorRules: ExpectedErrorRule[] = [
73139
{ code: 'ENOSPC' },
74140
{ messageIncludes: /no space left on device/i }
@@ -84,10 +150,11 @@ export function isExpectedError(error: unknown): boolean {
84150
if (rule.messageIncludes && rule.messageIncludes.test(message)) return true
85151
}
86152
return false
87-
} catch (_e) {
153+
} catch {
88154
return false
89155
}
90156
}
157+
91158
process.on('uncaughtException', (error) => {
92159
if (isExpectedError(error)) return
93160
log.error(error)

0 commit comments

Comments
 (0)