为 XHChat 增加品牌标志与 Windows 图标

This commit is contained in:
xhgit committed 2026-11-14 08:23:21 +08:00
1 parent b1f55df263
commit 570ce704fd
10 files changed
+18 -13

No files matched your search

+6 -3
View File
@@ -36,8 +36,9 @@ async function start() {
])
const browserAsset = browserPaths.get(url.pathname)
const mlsAsset = /^\/mls\/xhchat_mls_check(?:\.js|_bg\.wasm)$/.test(url.pathname)
const brandAsset = url.pathname === '/brand/xhchat.png' || url.pathname === '/brand/xhchat.ico'
if (url.host !== 'app' || request.method !== 'GET' ||
(!root && !browserAsset && !mlsAsset && !/^\/assets\/[a-zA-Z0-9_.-]+\.(?:js|css)$/.test(url.pathname))) {
(!root && !browserAsset && !mlsAsset && !brandAsset && !/^\/assets\/[a-zA-Z0-9_.-]+\.(?:js|css)$/.test(url.pathname))) {
return new Response(null, { status: 404 })
}
try {
@@ -45,11 +46,12 @@ async function start() {
const html = root || url.pathname === '/browser'
const policy = "default-src 'none'; script-src 'self'" + (browserAsset ? '' : " 'wasm-unsafe-eval'") +
"; style-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'"
const type = html ? 'text/html; charset=utf-8' : url.pathname.endsWith('.css') ? 'text/css' :
const type = html ? 'text/html; charset=utf-8' : brandAsset ? (url.pathname.endsWith('.ico') ? 'image/x-icon' : 'image/png') :
url.pathname.endsWith('.css') ? 'text/css' :
url.pathname.endsWith('.wasm') ? 'application/wasm' : 'application/javascript'
return new Response(bytes, { headers: {
'Content-Type': type,
'Content-Security-Policy': browserAsset ? policy : policy + "; img-src blob:; media-src blob:; connect-src 'self' " + api + ' ' + websocket,
'Content-Security-Policy': browserAsset ? policy : policy + "; img-src 'self' blob:; media-src blob:; connect-src 'self' " + api + ' ' + websocket,
'X-Content-Type-Options': 'nosniff',
} })
} catch {
@@ -58,6 +60,7 @@ async function start() {
})
const win = new BrowserWindow({
icon: join(renderer, 'brand/xhchat.ico'),
title: 'XHChat', width: 1120, height: 740, minWidth: 480, minHeight: 570,
webPreferences: {
session: trusted, preload: join(__dirname, 'preload.js'),