fix(server): 赛事包导出传入项目名,修复 GET /api/export/project.zip 恒 500
This commit is contained in:
1 parent
72462792ec
commit
5ae55b8057
36 files changed
+2672
-108
No files matched your search
@@ -1,16 +1,35 @@
|
||||
'use strict'
|
||||
|
||||
const { nativeImage } = require('electron')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { app, nativeImage } = require('electron')
|
||||
|
||||
// 托盘图标以 base64 内嵌:现场部署包只有 exe 和几个文件,
|
||||
// 少一个需要跟着走的资源文件就少一处「文件丢了图标不显示」的故障点。
|
||||
// 托盘图标:优先用部署包里的 scoreboard.png(换图标不用重新打包),
|
||||
// 找不到时回落到内嵌 base64,保证任何情况下托盘都有图标。
|
||||
const ICON_PNG_BASE64 =
|
||||
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABUklEQVR42u2XwUdEURTG5z9JSholJY2SklJSf0+0iKFFtIhoES0iWkSLiBaRDKNSKU2GjCRGEkkSSZsvb3GfnHPnzTm382Y1P36b9x33fKv37stkmiiYLf1AovnimatvhPjvxdMXX7AwaPnU6ScsVS2fLH4gDUXLJwrvSNO6BcaP3pCmicvHDl/RCGsWGD14QSP0Lh/Zf4aVFN8MKzC89wQrKb4ZVmBotworKb4ZVmBw5xFWUnwzrEBu+wFWUnwzrMDA1j00UqSZkxXo36xAI0WaOVmBvo07aKRIMycr0LtehkaKNHOyAj1rt9BIkWZO79uwe/UGUinSLLLmt6Br5Rp/pVhkkYlfxOzyJZwUi6zufaBz6RxOikUmuhV1LJ4hkuKeh2aqe2F7/oQdFD1zarOgmzE9qG2hGKvJgv8L6EGt84VYTWZWoGXuOFaTNX9qk/gFLmHiXP3t+GEAAAAASUVORK5CYII='
|
||||
|
||||
// 候选顺序:exe 同级(部署包)→ 源码目录(开发态)→ resources 目录
|
||||
function resolveIconPath() {
|
||||
const candidates = [
|
||||
path.join(path.dirname(app.getPath('exe')), 'scoreboard.png'),
|
||||
path.join(__dirname, '..', 'scoreboard.png'),
|
||||
path.join(process.resourcesPath || '', 'scoreboard.png'),
|
||||
]
|
||||
return candidates.find((candidate) => candidate && fs.existsSync(candidate)) || null
|
||||
}
|
||||
|
||||
function createTrayIcon() {
|
||||
const image = nativeImage.createFromDataURL(`data:image/png;base64,${ICON_PNG_BASE64}`)
|
||||
// Windows 上托盘按 16px 显示,缩放交给系统会更模糊,这里直接给 16px
|
||||
return image.resize({ width: 16, height: 16 })
|
||||
const file = resolveIconPath()
|
||||
if (file) {
|
||||
const image = nativeImage.createFromPath(file)
|
||||
if (!image.isEmpty()) {
|
||||
// Windows 托盘按 16px 显示,缩放交给系统会更模糊,这里直接给 16px
|
||||
return image.resize({ width: 16, height: 16 })
|
||||
}
|
||||
}
|
||||
const fallback = nativeImage.createFromDataURL(`data:image/png;base64,${ICON_PNG_BASE64}`)
|
||||
return fallback.resize({ width: 16, height: 16 })
|
||||
}
|
||||
|
||||
module.exports = { createTrayIcon }
|
||||
@@ -13,7 +13,7 @@
|
||||
<!-- 窗口是无边框的,标题栏和最小化/最大化/关闭三键都在这条上自绘 -->
|
||||
<header id="titlebar" class="topbar">
|
||||
<div class="brand">
|
||||
<span class="brand-mark"></span>
|
||||
<img class="brand-mark" src="scoreboard.png" alt="" width="30" height="30" />
|
||||
<div>
|
||||
<h1>Scoreboard Console</h1>
|
||||
<p class="brand-sub">赛事积分榜 · 桌面宿主</p>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 204 KiB |
@@ -51,10 +51,11 @@ body {
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
width: 8px;
|
||||
height: 22px;
|
||||
border-radius: 4px;
|
||||
background: linear-gradient(180deg, var(--accent), #1b6bb8);
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Reference in new issue
Block a user