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 +XHChat 标志 + 面向 Windows 与 Web 的即时通讯项目,目标是提供端到端加密通信、群组和实时音视频。Windows 客户端内置独立的 Chromium 浏览器。 [![Stars](https://git.xhmcl.com/xhgit/XHChat/badges/stars.svg)](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 @@ + XHChat diff --git a/web/public/brand/xhchat.ico b/web/public/brand/xhchat.ico new file mode 100644 index 0000000..ac98b6d Binary files /dev/null and b/web/public/brand/xhchat.ico differ diff --git a/web/public/brand/xhchat.png b/web/public/brand/xhchat.png new file mode 100644 index 0000000..0e16d4c Binary files /dev/null and b/web/public/brand/xhchat.png differ diff --git a/web/src/style.css b/web/src/style.css index dcbab8b..952d5b3 100644 --- a/web/src/style.css +++ b/web/src/style.css @@ -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; } diff --git a/web/src/views/AuthView.vue b/web/src/views/AuthView.vue index 05d4108..3675bec 100644 --- a/web/src/views/AuthView.vue +++ b/web/src/views/AuthView.vue @@ -33,8 +33,8 @@ async function submit() {