mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-28 15:25:27 +08:00
fix: improve desktop chat performance
This commit is contained in:
BIN
electron/assets/logo-windows.ico
Normal file
BIN
electron/assets/logo-windows.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -682,10 +682,18 @@ export class DesktopWindowManager {
|
||||
}
|
||||
|
||||
configurePermissions() {
|
||||
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
const isAllowedPermission = (webContents, permission) => {
|
||||
const sourceUrl = webContents.getURL();
|
||||
const allowedPermissions = new Set(['clipboard-read', 'media']);
|
||||
callback(isAllowedPermissionOrigin(sourceUrl, this.getCloudState().controlPlaneUrl) && allowedPermissions.has(permission));
|
||||
const allowedPermissions = new Set(['clipboard-read', 'media', 'notifications']);
|
||||
return isAllowedPermissionOrigin(sourceUrl, this.getCloudState().controlPlaneUrl) && allowedPermissions.has(permission);
|
||||
};
|
||||
|
||||
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
callback(isAllowedPermission(webContents, permission));
|
||||
});
|
||||
session.defaultSession.setPermissionCheckHandler((webContents, permission) => {
|
||||
if (!webContents) return false;
|
||||
return isAllowedPermission(webContents, permission);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { TabsController } from './tabs.js';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const APP_NAME = 'CloudCLI';
|
||||
const APP_USER_MODEL_ID = 'ai.cloudcli.desktop';
|
||||
const CALLBACK_PROTOCOL = 'cloudcli';
|
||||
const CALLBACK_URL = `${CALLBACK_PROTOCOL}://auth/callback`;
|
||||
const CLOUDCLI_CONTROL_PLANE_URL = process.env.CLOUDCLI_CONTROL_PLANE_URL || 'https://cloudcli.ai';
|
||||
@@ -20,6 +21,10 @@ const AUTH_CALLBACK_TTL_MS = 10 * 60 * 1000;
|
||||
|
||||
const tabs = new TabsController();
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
app.setAppUserModelId(APP_USER_MODEL_ID);
|
||||
}
|
||||
|
||||
let activeTarget = { kind: 'launcher', name: APP_NAME, url: null };
|
||||
let desktopWindow = null;
|
||||
let localServer = null;
|
||||
|
||||
57
electron/scripts/generate-windows-icon.js
Normal file
57
electron/scripts/generate-windows-icon.js
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
const assetsDir = 'electron/assets';
|
||||
const sourcePath = 'public/logo-512.png';
|
||||
const icoPath = path.join(assetsDir, 'logo-windows.ico');
|
||||
const sizes = [16, 24, 32, 48, 64, 128, 256];
|
||||
|
||||
function writeDirectoryEntry(buffer, image, offset) {
|
||||
buffer.writeUInt8(image.size === 256 ? 0 : image.size, offset);
|
||||
buffer.writeUInt8(image.size === 256 ? 0 : image.size, offset + 1);
|
||||
buffer.writeUInt8(0, offset + 2);
|
||||
buffer.writeUInt8(0, offset + 3);
|
||||
buffer.writeUInt16LE(1, offset + 4);
|
||||
buffer.writeUInt16LE(32, offset + 6);
|
||||
buffer.writeUInt32LE(image.buffer.length, offset + 8);
|
||||
buffer.writeUInt32LE(image.offset, offset + 12);
|
||||
}
|
||||
|
||||
async function renderPng(size) {
|
||||
return sharp(sourcePath)
|
||||
.resize(size, size, { fit: 'contain' })
|
||||
.png()
|
||||
.toBuffer();
|
||||
}
|
||||
|
||||
await fs.mkdir(assetsDir, { recursive: true });
|
||||
|
||||
const images = await Promise.all(
|
||||
sizes.map(async (size) => ({
|
||||
size,
|
||||
buffer: await renderPng(size),
|
||||
offset: 0,
|
||||
})),
|
||||
);
|
||||
|
||||
const headerSize = 6 + images.length * 16;
|
||||
let cursor = headerSize;
|
||||
for (const image of images) {
|
||||
image.offset = cursor;
|
||||
cursor += image.buffer.length;
|
||||
}
|
||||
|
||||
const ico = Buffer.alloc(cursor);
|
||||
ico.writeUInt16LE(0, 0);
|
||||
ico.writeUInt16LE(1, 2);
|
||||
ico.writeUInt16LE(images.length, 4);
|
||||
|
||||
images.forEach((image, index) => {
|
||||
writeDirectoryEntry(ico, image, 6 + index * 16);
|
||||
image.buffer.copy(ico, image.offset);
|
||||
});
|
||||
|
||||
await fs.writeFile(icoPath, ico);
|
||||
console.log(`Wrote ${icoPath}`);
|
||||
Reference in New Issue
Block a user