diff --git a/README.md b/README.md
index 1417504..86ba4f1 100644
--- a/README.md
+++ b/README.md
@@ -12,3 +12,4 @@ TODO
- [x] 保存历史
- [x] 自动接收
- [ ] 传输加密
+- [ ] 单例模式
\ No newline at end of file
diff --git a/frontend/src/components/TransferItem.vue b/frontend/src/components/TransferItem.vue
index 7b253e5..92c9f1e 100644
--- a/frontend/src/components/TransferItem.vue
+++ b/frontend/src/components/TransferItem.vue
@@ -263,35 +263,49 @@ const canAccept = computed(() => {
color="success"
icon="mdi-content-save"
@click="acceptTransfer"
- >
+ >
+ Accept
+
+ >
+
+ Save to Folder
+
+
+ >
+ Reject
+
+ >
+
+ View Content
+
+
+ >
+ Copy
+
+ >
+ Delete
+
+ >
+ Cancel
+
diff --git a/internal/config/config.go b/internal/config/config.go
index 8793378..e29ebdb 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -77,6 +77,7 @@ func Load() *Config {
}
v.SetDefault("host_name", defaultHostName)
v.SetDefault("id", uuid.New().String())
+ v.SetDefault("save_history", true)
v.SetConfigFile(configFile)
v.SetConfigType("json")
@@ -182,3 +183,16 @@ func (c *Config) GetSaveHistory() bool {
func (c *Config) GetVersion() string {
return Version
}
+
+func (c *Config) SetWindowState(state WindowState) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ c.WindowState = state
+ c.v.Set("window_state", state)
+}
+
+func (c *Config) GetWindowState() WindowState {
+ c.mu.RLock()
+ defer c.mu.RUnlock()
+ return c.WindowState
+}
diff --git a/internal/transfer/history.go b/internal/transfer/history.go
index e1e7f93..cbd8486 100644
--- a/internal/transfer/history.go
+++ b/internal/transfer/history.go
@@ -15,7 +15,7 @@ func (s *Service) SaveHistory() {
if err != nil {
return
}
- file, err := os.OpenFile(historyPath, os.O_CREATE|os.O_RDWR, os.FileMode(0644))
+ file, err := os.OpenFile(historyPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return
}
diff --git a/internal/transfer/service.go b/internal/transfer/service.go
index 6436335..e1ca57a 100644
--- a/internal/transfer/service.go
+++ b/internal/transfer/service.go
@@ -65,7 +65,7 @@ func (s *Service) Start() {
}
func (s *Service) GetTransferList() []*Transfer {
- var requests []*Transfer
+ var requests []*Transfer = make([]*Transfer, 0)
s.transferList.Range(func(key, value any) bool {
requests = append(requests, value.(*Transfer))
return true
diff --git a/main.go b/main.go
index 6755448..112a04a 100644
--- a/main.go
+++ b/main.go
@@ -81,20 +81,25 @@ func main() {
// 窗口关闭事件
window.OnWindowEvent(events.Common.WindowClosing, func(event *application.WindowEvent) {
- // 保存配置
x, y := window.Position()
width, height := window.Size()
- conf.WindowState = config.WindowState{
+ conf.SetWindowState(config.WindowState{
X: x,
Y: y,
Width: width,
Height: height,
- }
- _ = conf.Save()
+ })
+
// 保存传输历史
if conf.GetSaveHistory() {
transferService.SaveHistory()
}
+
+ // 保存配置
+ err := conf.Save()
+ if err != nil {
+ slog.Error("Failed to save config", "error", err)
+ }
})
application.RegisterEvent[FilesDroppedEvent]("files-dropped")