feat(channels): implement channel connection flows with multi-platform support

- Add comprehensive Channels page with connection statistics and status display
- Implement AddChannelDialog with type-specific connection flows:
  - QR code-based connection for WhatsApp/WeChat
  - Token-based connection for Telegram/Discord/Slack
- Enhance channels store with addChannel, deleteChannel, and requestQrCode actions
- Update electron-store usage to dynamic imports for ESM compatibility
- Add channel connection instructions and documentation links
This commit is contained in:
Haze
2026-02-05 23:29:18 +08:00
Unverified
parent ebb6f515a7
commit 98a2d9bc83
5 changed files with 619 additions and 100 deletions

View File

@@ -3,7 +3,6 @@
* Handles window state persistence and multi-window management
*/
import { BrowserWindow, screen } from 'electron';
import Store from 'electron-store';
interface WindowState {
x?: number;
@@ -13,21 +12,31 @@ interface WindowState {
isMaximized: boolean;
}
const store = new Store<{ windowState: WindowState }>({
name: 'window-state',
defaults: {
windowState: {
width: 1280,
height: 800,
isMaximized: false,
},
},
});
// Lazy-load electron-store (ESM module)
let windowStateStore: any = null;
async function getStore() {
if (!windowStateStore) {
const Store = (await import('electron-store')).default;
windowStateStore = new Store<{ windowState: WindowState }>({
name: 'window-state',
defaults: {
windowState: {
width: 1280,
height: 800,
isMaximized: false,
},
},
});
}
return windowStateStore;
}
/**
* Get saved window state with bounds validation
*/
export function getWindowState(): WindowState {
export async function getWindowState(): Promise<WindowState> {
const store = await getStore();
const state = store.get('windowState');
// Validate that the window is visible on a screen
@@ -56,7 +65,8 @@ export function getWindowState(): WindowState {
/**
* Save window state
*/
export function saveWindowState(win: BrowserWindow): void {
export async function saveWindowState(win: BrowserWindow): Promise<void> {
const store = await getStore();
const isMaximized = win.isMaximized();
if (!isMaximized) {