蜂鸟Pro v2.0.1 - 基础框架版本 (待完善)
## 当前状态 - 插件界面已完成重命名 (cursorpro → hummingbird) - 双账号池 UI 已实现 (Auto/Pro 卡片) - 后端已切换到 MySQL 数据库 - 添加了 Cursor 官方用量 API 文档 ## 已知问题 (待修复) 1. 激活时检查账号导致无账号时激活失败 2. 未启用无感换号时不应获取账号 3. 账号用量模块不显示 (seamless 未启用时应隐藏) 4. 积分显示为 0 (后端未正确返回) 5. Auto/Pro 双密钥逻辑混乱,状态不同步 6. 账号添加后无自动分析功能 ## 下一版本计划 - 重构数据模型,优化账号状态管理 - 实现 Cursor API 自动分析账号 - 修复激活流程,不依赖账号 - 启用无感时才分配账号 - 完善账号用量实时显示 ## 文件说明 - docs/系统设计文档.md - 完整架构设计 - cursor 官方用量接口.md - Cursor API 文档 - 参考计费/ - Vibeviewer 开源项目参考 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
109
参考计费/Vibeviewer/VibeviewerApp.swift
Normal file
109
参考计费/Vibeviewer/VibeviewerApp.swift
Normal file
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// VibeviewerApp.swift
|
||||
// Vibeviewer
|
||||
//
|
||||
// Created by Groot chen on 2025/8/24.
|
||||
//
|
||||
|
||||
import Observation
|
||||
import SwiftUI
|
||||
import VibeviewerAPI
|
||||
import VibeviewerAppEnvironment
|
||||
import VibeviewerCore
|
||||
import VibeviewerLoginUI
|
||||
import VibeviewerMenuUI
|
||||
import VibeviewerModel
|
||||
import VibeviewerSettingsUI
|
||||
import VibeviewerStorage
|
||||
import VibeviewerShareUI
|
||||
|
||||
@main
|
||||
struct VibeviewerApp: App {
|
||||
@State private var settings: AppSettings = DefaultCursorStorageService.loadSettingsSync()
|
||||
|
||||
@State private var session: VibeviewerModel.AppSession = .init(
|
||||
credentials: DefaultCursorStorageService.loadCredentialsSync(),
|
||||
snapshot: DefaultCursorStorageService.loadDashboardSnapshotSync()
|
||||
)
|
||||
@State private var refresher: any DashboardRefreshService = NoopDashboardRefreshService()
|
||||
@State private var loginService: any LoginService = NoopLoginService()
|
||||
@State private var updateService: any UpdateService = NoopUpdateService()
|
||||
|
||||
var body: some Scene {
|
||||
MenuBarExtra {
|
||||
MenuPopoverView()
|
||||
.environment(\.cursorService, DefaultCursorService())
|
||||
.environment(\.cursorStorage, DefaultCursorStorageService())
|
||||
.environment(\.loginWindowManager, LoginWindowManager.shared)
|
||||
.environment(\.settingsWindowManager, SettingsWindowManager.shared)
|
||||
.environment(\.dashboardRefreshService, self.refresher)
|
||||
.environment(\.loginService, self.loginService)
|
||||
.environment(\.launchAtLoginService, DefaultLaunchAtLoginService())
|
||||
.environment(\.updateService, self.updateService)
|
||||
.environment(self.settings)
|
||||
.environment(self.session)
|
||||
.menuBarExtraWindowCorner()
|
||||
.onAppear {
|
||||
SettingsWindowManager.shared.appSettings = self.settings
|
||||
SettingsWindowManager.shared.appSession = self.session
|
||||
SettingsWindowManager.shared.dashboardRefreshService = self.refresher
|
||||
SettingsWindowManager.shared.updateService = self.updateService
|
||||
}
|
||||
.id(self.settings.appearance)
|
||||
.applyPreferredColorScheme(self.settings.appearance)
|
||||
} label: {
|
||||
menuBarLabel()
|
||||
}
|
||||
.menuBarExtraStyle(.window)
|
||||
.windowResizability(.contentSize)
|
||||
}
|
||||
|
||||
private func menuBarLabel() -> some View {
|
||||
HStack(spacing: 4) {
|
||||
Image(.menuBarIcon)
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.frame(width: 16, height: 16)
|
||||
.padding(.trailing, 4)
|
||||
.foregroundStyle(.primary)
|
||||
Text({
|
||||
guard let snapshot = self.session.snapshot else { return "" }
|
||||
return snapshot.displayTotalUsageCents.dollarStringFromCents
|
||||
}())
|
||||
.font(.app(.satoshiBold, size: 15))
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
.task {
|
||||
await self.setupDashboardRefreshService()
|
||||
}
|
||||
}
|
||||
|
||||
private func setupDashboardRefreshService() async {
|
||||
let api = DefaultCursorService()
|
||||
let storage = DefaultCursorStorageService()
|
||||
|
||||
let dashboardRefreshSvc = DefaultDashboardRefreshService(
|
||||
api: api,
|
||||
storage: storage,
|
||||
settings: self.settings,
|
||||
session: self.session
|
||||
)
|
||||
let screenPowerSvc = DefaultScreenPowerStateService()
|
||||
let powerAwareSvc = PowerAwareDashboardRefreshService(
|
||||
refreshService: dashboardRefreshSvc,
|
||||
screenPowerService: screenPowerSvc
|
||||
)
|
||||
self.refresher = powerAwareSvc
|
||||
|
||||
// 创建登录服务,依赖刷新服务
|
||||
self.loginService = DefaultLoginService(
|
||||
api: api,
|
||||
storage: storage,
|
||||
refresher: self.refresher,
|
||||
session: self.session
|
||||
)
|
||||
|
||||
await self.refresher.start()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user