feat(daemon-beta t26): 托盤選單顯連線身分(暱稱>email>未設定),CF 全程隱形
- directConfig/DirectConfig 加 Email、InstanceName(選配)欄,兩結構同形 - rebuildTray 選單頂加 disabled「連線中:<暱稱||email||未設定>」列; 有 cypher_url 再加一行縮短 host(fyne MenuItem 無 tooltip,取捨見註解) - connectionStatusLabel/shortCypherHost 抽純函式,3+3 案 table test - go vet + go test 全綠(collector 43 通、tray 10 通);tray go build 過
This commit is contained in:
+39
-1
@@ -44,6 +44,8 @@ type directConfig struct {
|
||||
CypherURL string `json:"cypher_url"`
|
||||
Namespace string `json:"namespace"`
|
||||
APIKey string `json:"api_key,omitempty"`
|
||||
Email string `json:"email,omitempty"` // 實例主身分(t26;人人記得自己的 email,CF 全程隱形)
|
||||
InstanceName string `json:"instance_name,omitempty"` // 暱稱(t26 選配;不取就顯示 email)
|
||||
Library string `json:"library,omitempty"`
|
||||
IngestWF string `json:"ingest_workflow,omitempty"`
|
||||
RemovedWF string `json:"removed_workflow,omitempty"`
|
||||
@@ -163,6 +165,32 @@ func collectorBinPath() string {
|
||||
|
||||
func isWindows() bool { return os.PathSeparator == '\\' }
|
||||
|
||||
// connectionStatusLabel 決定托盤選單頂列「連線中:…」顯示什麼身分(t26 leo 拍板):
|
||||
// 暱稱(InstanceName)優先於 email,兩者都空才顯示「未設定」——CF/cypher 全程不入此字串。
|
||||
func connectionStatusLabel(instanceName, email string) string {
|
||||
name := strings.TrimSpace(instanceName)
|
||||
if name == "" {
|
||||
name = strings.TrimSpace(email)
|
||||
}
|
||||
if name == "" {
|
||||
name = "未設定"
|
||||
}
|
||||
return "連線中:" + name
|
||||
}
|
||||
|
||||
// shortCypherHost 把 cypher_url 縮成純 host 給第二行 disabled 選單項看(fyne MenuItem 無 tooltip,
|
||||
// 取捨=直接多一行而非塞進同一行——選單寬度有限,host 通常已夠長)。解析失敗就原樣回傳(不隱藏錯誤設定)。
|
||||
func shortCypherHost(cypherURL string) string {
|
||||
u := strings.TrimSpace(cypherURL)
|
||||
if u == "" {
|
||||
return ""
|
||||
}
|
||||
if parsed, err := neturl.Parse(u); err == nil && parsed.Host != "" {
|
||||
return parsed.Host
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := app.NewWithID("dev.arcrun.rag.tray")
|
||||
cfg := loadConfig()
|
||||
@@ -270,7 +298,17 @@ func main() {
|
||||
if !hasTray {
|
||||
return
|
||||
}
|
||||
items := []*fyne.MenuItem{statusItem, fyne.NewMenuItemSeparator()}
|
||||
// t26:選單最頂顯示「連線中:<暱稱||email>」(CF/cypher_url 全程不現身這一行);
|
||||
// 有 cypher_url 時再加一行縮短的 host(fyne MenuItem 無 tooltip,取捨見 shortCypherHost 注解)。
|
||||
connItem := fyne.NewMenuItem(connectionStatusLabel(cfg.InstanceName, cfg.Email), nil)
|
||||
connItem.Disabled = true
|
||||
items := []*fyne.MenuItem{connItem}
|
||||
if host := shortCypherHost(cfg.CypherURL); host != "" {
|
||||
hostItem := fyne.NewMenuItem("→ "+host, nil)
|
||||
hostItem.Disabled = true
|
||||
items = append(items, hostItem)
|
||||
}
|
||||
items = append(items, statusItem, fyne.NewMenuItemSeparator())
|
||||
for _, f := range cfg.Folders() {
|
||||
folder := f // capture
|
||||
it := fyne.NewMenuItem("📁 "+filepath.Base(folder), func() {
|
||||
|
||||
Reference in New Issue
Block a user