初始化

This commit is contained in:
2026-01-22 15:18:09 +08:00
commit 85e5d1ccb7
28 changed files with 7664 additions and 0 deletions

147
src/types/electron.d.ts vendored Normal file
View File

@@ -0,0 +1,147 @@
/**
* Electron API 类型定义
* 从 preload/index.ts 提取的类型,用于独立前端项目
*/
export type TabId = 'A' | 'B' | 'C'
export interface Account {
email: string
pwd: string
group?: string
}
export interface AutomationConfig {
aiReplyEnabled: boolean
isGreetFirst: boolean
prologueList: Record<string, string[]>
sleepTime: number
needTranslate: boolean
inviteThreshold: number
accounts: Account[]
tenantId: string
token: string
filters: {
minFans: number
maxFans: number
minCoins: number
maxCoins: number
minOnlineFans: number
maxOnlineFans: number
hostsLevelList: number[]
gold: boolean
ordinary: boolean
}
}
export interface AutomationLog {
viewId: number
level: 'info' | 'warn' | 'error'
message: string
}
export interface RotationStatus {
enabled: boolean
currentActiveGroup: string
modeStartTime: number
instanceModes: { viewId: number; email: string; group: string; mode: 'active' | 'background' }[]
}
export interface UpdateInfo {
version: string
releaseDate?: string
releaseNotes?: string
}
export interface UpdateProgress {
percent: number
bytesPerSecond: number
transferred: number
total: number
}
export interface GreetingStats {
greetingCount: number
inviteCount: number
}
export interface ElectronAPI {
// 基础视图控制
hideViews: () => Promise<{ success: boolean }>
showViews: () => Promise<{ success: boolean }>
switchTab: (tab: TabId) => Promise<{ success: boolean; currentTab?: TabId; error?: string }>
switchToView: (viewId: number) => Promise<{ success: boolean; currentViewId?: number; error?: string }>
getCurrentTab: () => Promise<TabId>
getCurrentViewId: () => Promise<number>
runAutomation: (viewId: number) => Promise<{ success: boolean; message: string }>
loadUrl: (viewId: number, url: string) => Promise<{ success: boolean; error?: string }>
getViewsInfo: () => Promise<{ id: number; url: string }[]>
// 登录
login: (credentials: { tenantName: string; username: string; password: string }) =>
Promise<{ success: boolean; user?: unknown; error?: string }>
logout: () => Promise<{ success: boolean; error?: string }>
// TikTok 自动化
startTikTokAutomation: (viewId: number, account: Account) => Promise<{ success: boolean; message?: string; error?: string }>
stopTikTokAutomation: (viewId: number) => Promise<{ success: boolean; message?: string; error?: string }>
updateAutomationConfig: (config: Partial<AutomationConfig>) => Promise<{ success: boolean }>
getAutomationConfig: () => Promise<AutomationConfig>
// 清空缓存
clearAllCache: () => Promise<void>
// 调试工具
openDevtools: (viewId: number) => Promise<{ success: boolean; error?: string }>
// 数据存储
saveAIConfig: (config: Record<string, unknown>) => Promise<{ success: boolean }>
loadAIConfig: () => Promise<Record<string, unknown>>
loadAnchorData: () => Promise<unknown[]>
saveAnchorData: (data: unknown[]) => Promise<{ success: boolean }>
saveRunConfig: (config: Record<string, unknown>) => Promise<{ success: boolean }>
loadRunConfig: () => Promise<Record<string, unknown> | null>
// 翻译
translate: (text: string, targetLang: string) => Promise<{ success: boolean; result: string; error?: string }>
// 轮换状态
getRotationStatus: () => Promise<RotationStatus>
// 打招呼统计
getGreetingStats: () => Promise<GreetingStats>
// 获取打招呼内容
fetchPrologue: () => Promise<{ success: boolean; data?: string[]; error?: string }>
// 健康检查
checkHealth: () => Promise<{ success: boolean; code?: number; message?: string; error?: string }>
// 更新相关
checkForUpdates: () => Promise<boolean>
downloadUpdate: () => Promise<void>
installUpdate: () => void
getAppVersion: () => Promise<string>
// 事件监听
onAutomationLog: (callback: (log: AutomationLog) => void) => () => void
onRotationStatusChanged: (callback: (status: RotationStatus) => void) => () => void
onRequestSaveConfig: (callback: () => void) => () => void
onRequestClearLogin: (callback: () => void) => () => void
onUpdateChecking: (callback: () => void) => () => void
onUpdateAvailable: (callback: (info: UpdateInfo) => void) => () => void
onUpdateNotAvailable: (callback: () => void) => () => void
onUpdateProgress: (callback: (progress: UpdateProgress) => void) => () => void
onUpdateDownloaded: (callback: (info: { version: string }) => void) => () => void
onUpdateError: (callback: (error: { message: string }) => void) => () => void
onGreetingStatsChanged: (callback: (stats: GreetingStats) => void) => () => void
}
// 声明全局类型
declare global {
interface Window {
electronAPI?: ElectronAPI
}
}
export { }