b2970e4c-45a2-423e-b84d-257.../Sources/FundPlugin.swift
徐翔宇 e5a72bcf42 v0.2.0: initial 看盘侠 — Fund & Gold plugin for MioIsland
Real-time OTC fund and gold tracker for the macOS notch. Three tabs:
- 持仓: live intraday estimates from 天天基金, hero card with
  total value / today P&L / cumulative P&L, per-row 当日 + 累计.
- 黄金: SHFE 沪金 realtime + daily K-line + 伦敦金 reference.
- 添加: search 26k+ public funds via 东方财富 suggest API.

No API keys, no Python, no servers. All data comes from public
endpoints (天天基金, 东方财富, 新浪财经).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 20:20:15 +08:00

53 lines
1.4 KiB
Swift

//
// FundPlugin.swift
// Mio Island plugin:
//
// Principal class. Module = FundPlugin, Class = FundPlugin
// NSPrincipalClass = "FundPlugin.FundPlugin".
//
import AppKit
import SwiftUI
final class FundPlugin: NSObject, MioPlugin {
var id: String { "fund" }
var name: String { "看盘侠" }
var icon: String { "chart.line.uptrend.xyaxis" }
var version: String { "0.2.0" }
func activate() {
FundDebugLog.write("plugin activate")
// Kick off the refresh loops as soon as the plugin enables.
// The store is a singleton so the loops survive panel show/hide.
Task { @MainActor in
FundStore.shared.start()
await FundStore.shared.refreshNow()
}
}
func deactivate() {
FundDebugLog.write("plugin deactivate")
Task { @MainActor in
FundStore.shared.stop()
}
}
func makeView() -> NSView {
let view = NSHostingView(rootView: ExpandedView())
view.autoresizingMask = [.width, .height]
return view
}
@objc func viewForSlot(_ slot: String, context: [String: Any]) -> NSView? {
switch slot {
case "header":
let v = NSHostingView(rootView: HeaderSlotView())
v.frame = NSRect(x: 0, y: 0, width: 20, height: 20)
v.setFrameSize(NSSize(width: 20, height: 20))
return v
default:
return nil
}
}
}