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

Merged
xhgit merged 1 commits from xhgit/brand-logo into main 2026-11-14 08:30:06 +08:00
10 changed files with 18 additions and 13 deletions

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'),
+2
View File
@@ -1,5 +1,7 @@
# XHChat
<img src="web/public/brand/xhchat.png" alt="XHChat 标志" width="92" height="92">
面向 Windows 与 Web 的即时通讯项目,目标是提供端到端加密通信、群组和实时音视频。Windows 客户端内置独立的 Chromium 浏览器。
[![Stars](https://git.xhmcl.com/xhgit/XHChat/badges/stars.svg)](https://git.xhmcl.com/xhgit/XHChat/stars)
+1 -1
View File
@@ -27,7 +27,7 @@ server {
proxy_set_header Host $http_host;
}
add_header Content-Security-Policy "default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; connect-src 'self'; img-src blob:; media-src blob:; form-action 'self'; base-uri 'none'; frame-ancestors 'none'" always;
add_header Content-Security-Policy "default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; connect-src 'self'; img-src 'self' blob:; media-src blob:; form-action 'self'; base-uri 'none'; frame-ancestors 'none'" always;
add_header Referrer-Policy no-referrer always;
add_header X-Content-Type-Options nosniff always;
add_header Permissions-Policy "camera=(), microphone=(self), geolocation=()" always;
+2
View File
@@ -21,6 +21,7 @@ test('Web 注册,Windows 登录,Web 撤销 Windows 设备', { timeout: 45000
try {
const web = await browser.newPage({ viewport: { width: 390, height: 844 } })
await web.goto(base)
await web.waitForFunction(() => document.querySelector('.brand img')?.naturalWidth === 512)
await web.getByRole('button', { name: '注册', exact: true }).click()
const username = 'qa_' + randomBytes(6).toString('hex')
const password = randomBytes(24).toString('base64url')
@@ -52,6 +53,7 @@ test('Web 注册,Windows 登录,Web 撤销 Windows 设备', { timeout: 45000
env: { ...process.env, XHCHAT_SERVER_URL: base },
})
const windows = await desktop.firstWindow()
await windows.waitForFunction(() => document.querySelector('.brand img')?.naturalWidth === 512)
await form(windows, username, password)
await windows.locator('button.primary').click()
await windows.getByText('实时连接已建立').waitFor()
+1
View File
@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#f1f5f3">
<link rel="icon" type="image/x-icon" href="/brand/xhchat.ico">
<title>XHChat</title>
</head>
<body>
Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

+3 -6
View File
@@ -31,13 +31,10 @@ small, .muted { color: var(--muted); }
.auth-shell { display: grid; grid-template-columns: 1fr 1.1fr; min-height: 100vh; }
.auth-brand { position: relative; overflow: hidden; display: grid; align-content: space-between; padding: clamp(26px, 6vw, 80px); background: #12372d; color: #ecf8ee; min-height: 100%; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 23px; font-weight: 700; }
.mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #ceef9a; color: #12372d; font: 800 22px/1 system-ui, sans-serif; text-decoration: none; }
.mark { display: block; width: 40px; height: 40px; }
.mark img { display: block; width: 100%; height: 100%; }
.platform { color: #bad5c5; }
.brand-art { width: min(100%, 430px); aspect-ratio: 1; position: relative; margin: 36px auto; }
.brand-art span { position: absolute; inset: 5% 11% 11% 5%; border: 1px solid #7aab94; border-radius: 45% 45% 10% 45%; }
.brand-art span:nth-child(2) { inset: 16% 4% 0% 16%; }
.brand-art span:nth-child(3) { inset: 24% 23% 24% 23%; background: #ceef9a; border-color: #ceef9a; border-radius: 50% 50% 50% 10%; }
.brand-art span:nth-child(4) { inset: 45% 38% 45% 38%; background: #12372d; border: 0; border-radius: 20px; }
.brand-art { display: block; width: min(70%, 300px); aspect-ratio: 1; margin: 36px auto; }
.auth-content { display: grid; align-items: center; justify-items: center; background: var(--surface); padding: 32px clamp(22px, 6vw, 72px); }
.auth-form { display: grid; gap: 19px; width: min(100%, 390px); }
.tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
+2 -2
View File
@@ -33,8 +33,8 @@ async function submit() {
<template>
<main class="auth-shell">
<aside class="auth-brand">
<div class="brand"><span class="mark" aria-hidden="true">X</span>XHChat</div>
<div class="brand-art" aria-hidden="true"><span></span><span></span><span></span><span></span></div>
<div class="brand"><img class="mark" src="/brand/xhchat.png" alt="">XHChat</div>
<img class="brand-art" src="/brand/xhchat.png" alt="">
<p class="platform">{{ platform === 'windows' ? 'Windows 客户端' : 'Web 客户端' }}</p>
</aside>
<section class="auth-content">
+1 -1
View File
@@ -23,7 +23,7 @@ async function act(action: () => Promise<void>) {
<template>
<main v-if="session.identity" class="workspace">
<nav class="rail" aria-label="主导航">
<RouterLink class="mark" to="/devices" aria-label="XHChat">X</RouterLink>
<RouterLink class="mark" to="/devices" aria-label="XHChat"><img src="/brand/xhchat.png" alt=""></RouterLink>
<RouterLink class="rail-link" to="/chat" title="消息" aria-label="消息">◇</RouterLink>
<RouterLink class="rail-link" to="/contacts" title="联系人" aria-label="联系人">人</RouterLink>
<RouterLink class="rail-link" to="/devices" title="设备管理" aria-label="设备管理">▣</RouterLink>