¸ÄÓñ¾»ú¶ÀÁ¢ CA£¬»ָ´ CLI TLS УÑ飬±£»¤ƾ¾ÝÓëÅäÖò¢·¢±£´档 д Cursor Êý¾ݡ¢»Ự·¾¶¡¢´úÀíÉúÃüÖÜÆڡ¢ģÐÍÇëÇóÓë Skills Îļþ²Ù×÷¡£ Ϊ¶ÀÁ¢ Tab ·þÎñÔö¼ӿͻ§¶˼øȨ£¬Éý¼¶ÒÀÀµÓ빤¾ßÁ´£¬ÍêÉƷ¢²¼ԪÐÅϢͬ²½¡£ Ñé֤£ºÁ½¸ö Go ģ¿éµIJâÊÔ/vet¡¢¹ؼüģ¿é race¡¢ǰ¶˲âÊÔ/Éú²ú¹¹½¨/Éó¼ơ¢ Go ¿ɴï©¶´ɨÃèÓë macOS/Linux ¿ÉÐÐģ¿齻²æ±àÒë¾ùͨ¹ý¡£ Windows ¸ôÀëÆô¶¯ͨ¹ý£»δÍê³ɵĵã»÷ðÑ̺ÍԭÉúƽ̨Ñé֤¼ûÉó²鱨¸档
93 lines
2.1 KiB
Go
93 lines
2.1 KiB
Go
package client
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
|
||
"cursor/internal/appdata"
|
||
serverconfig "cursor/internal/backend/server/config"
|
||
|
||
"github.com/wailsapp/wails/v3/pkg/application"
|
||
)
|
||
|
||
// UserConfig 定义了当前模块中的 UserConfig 类型。
|
||
type UserConfig = serverconfig.Config
|
||
|
||
// LoadUserConfig 用于处理与 LoadUserConfig 相关的逻辑。
|
||
func (s *ProxyService) LoadUserConfig() (UserConfig, error) {
|
||
if s == nil {
|
||
return serverconfig.DefaultConfig(), nil
|
||
}
|
||
app := application.Get()
|
||
ctx := context.Background()
|
||
if app != nil {
|
||
ctx = app.Context()
|
||
}
|
||
if s.backend() != nil {
|
||
return s.backend().LoadConfig(ctx)
|
||
}
|
||
if s.store == nil {
|
||
return serverconfig.DefaultConfig(), nil
|
||
}
|
||
return s.store.Load(ctx)
|
||
}
|
||
|
||
// SaveUserConfig 用于处理与 SaveUserConfig 相关的逻辑。
|
||
func (s *ProxyService) SaveUserConfig(cfg UserConfig) error {
|
||
if s == nil {
|
||
return nil
|
||
}
|
||
if cfg.Revision == "" {
|
||
return fmt.Errorf("配置缺少 revision,请重新加载后保存")
|
||
}
|
||
app := application.Get()
|
||
ctx := context.Background()
|
||
if app != nil {
|
||
ctx = app.Context()
|
||
}
|
||
var (
|
||
normalized UserConfig
|
||
err error
|
||
)
|
||
if s.backend() != nil {
|
||
normalized, err = s.backend().SaveConfig(ctx, cfg)
|
||
} else if s.store != nil {
|
||
normalized, err = s.store.Save(ctx, cfg)
|
||
} else {
|
||
return nil
|
||
}
|
||
if err != nil {
|
||
return err
|
||
}
|
||
s.emitUserConfigChanged(normalized)
|
||
return nil
|
||
}
|
||
|
||
func (s *ProxyService) emitUserConfigChanged(cfg UserConfig) {
|
||
app := application.Get()
|
||
if app == nil {
|
||
return
|
||
}
|
||
app.Event.Emit("user-config:changed", cfg)
|
||
}
|
||
|
||
// resolveUserConfigPath 用于处理与 resolveUserConfigPath 相关的逻辑。
|
||
func resolveUserConfigPath() string {
|
||
return appdata.ConfigFilePath()
|
||
}
|
||
|
||
// resolveLogsRootPath 用于处理与 resolveLogsRootPath 相关的逻辑。
|
||
func resolveLogsRootPath() string {
|
||
return appdata.LogsRootPath()
|
||
}
|
||
|
||
// ResolveLogsRootPath 用于处理与 ResolveLogsRootPath 相关的逻辑。
|
||
func ResolveLogsRootPath() string {
|
||
return resolveLogsRootPath()
|
||
}
|
||
|
||
// ResolveSettingsRootPath 用于处理与 ResolveSettingsRootPath 相关的逻辑。
|
||
func ResolveSettingsRootPath() string {
|
||
return appdata.RootDir()
|
||
}
|