完善 DiscWorker 打包路径与产品命名,底部展示前后端版本,生产环境隐藏默认菜单。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
24kycj
2026-08-06 11:28:15 +08:00
parent 1d0d39995e
commit f28b5dc50a
9 changed files with 182 additions and 84 deletions
+36
View File
@@ -0,0 +1,36 @@
import platform from '@/platform'
const pkg = require('../../../../package.json')
export function getFrontendVersion() {
return String((pkg && pkg.version) || '0.0.0').replace(/^v/i, '')
}
export function formatAppVersionLine(front, back) {
const f = String(front || '').replace(/^v/i, '') || '—'
const b = String(back || '').replace(/^v/i, '').trim() || '—'
return `DiscWorker V${f} 基于DiscProducer 核心V${b}`
}
export function loadBackendVersion() {
if (!(platform.hasNativeFs && platform.hasNativeFs())) {
return Promise.resolve('')
}
const root = platform.getAppRoot()
const candidates = [
platform.pathJoin(root, 'CardsoonServer', 'VERSION'),
platform.pathJoin(root, 'cardsoonServer', 'VERSION')
]
const tryRead = (i) => {
if (i >= candidates.length) return Promise.resolve('')
return platform.readFile(candidates[i], 'utf8')
.then((text) => String(text || '').trim().split(/\r?\n/)[0] || '')
.catch(() => tryRead(i + 1))
}
return tryRead(0)
}
export function loadAppVersionLine() {
const front = getFrontendVersion()
return loadBackendVersion().then((back) => formatAppVersionLine(front, back))
}