diff --git a/Desktop/src/main.ts b/Desktop/src/main.ts
index 5c7e408..2143709 100644
--- a/Desktop/src/main.ts
+++ b/Desktop/src/main.ts
@@ -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'),
diff --git a/README.md b/README.md
index eca1f3a..78ffa00 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# XHChat
+
+
面向 Windows 与 Web 的即时通讯项目,目标是提供端到端加密通信、群组和实时音视频。Windows 客户端内置独立的 Chromium 浏览器。
[](https://git.xhmcl.com/xhgit/XHChat/stars)
diff --git a/deploy/nginx.conf b/deploy/nginx.conf
index 1d9ed01..1e68ac0 100644
--- a/deploy/nginx.conf
+++ b/deploy/nginx.conf
@@ -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;
diff --git a/tests/clients.test.mjs b/tests/clients.test.mjs
index 64953d9..d6df675 100644
--- a/tests/clients.test.mjs
+++ b/tests/clients.test.mjs
@@ -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()
diff --git a/web/index.html b/web/index.html
index a452028..93df117 100644
--- a/web/index.html
+++ b/web/index.html
@@ -4,6 +4,7 @@
+