升级版本并改用内部账号存储
This commit is contained in:
@@ -53,7 +53,7 @@ func (a *App) ExportAccounts(accountNames []string, filename string) types.Expor
|
||||
accountFile := a.scheduler.AccountFilePath()
|
||||
lines, err := parseAccountFile(accountFile)
|
||||
if err != nil {
|
||||
return types.ExportAccountsResult{Error: "读取账号文件失败: " + err.Error()}
|
||||
return types.ExportAccountsResult{Error: "读取内部账号库失败: " + err.Error()}
|
||||
}
|
||||
|
||||
nameSet := make(map[string]bool)
|
||||
@@ -79,7 +79,10 @@ func (a *App) ExportAccounts(accountNames []string, filename string) types.Expor
|
||||
exportPath := filepath.Join(filepath.Dir(accountFile), filename)
|
||||
content := strings.Join(matchedLines, "\n") + "\n"
|
||||
|
||||
if err := os.WriteFile(exportPath, []byte(content), 0644); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(exportPath), 0700); err != nil {
|
||||
return types.ExportAccountsResult{Error: "创建导出目录失败: " + err.Error()}
|
||||
}
|
||||
if err := os.WriteFile(exportPath, []byte(content), 0600); err != nil {
|
||||
return types.ExportAccountsResult{Error: "写入文件失败: " + err.Error()}
|
||||
}
|
||||
|
||||
@@ -137,7 +140,7 @@ func (a *App) OrganizeAccounts(commodityID, commodityName string, startTime, end
|
||||
accountFile := a.scheduler.AccountFilePath()
|
||||
lines, err := parseAccountFile(accountFile)
|
||||
if err != nil {
|
||||
return types.OrganizeAccountsResult{Error: "读取账号文件失败: " + err.Error()}
|
||||
return types.OrganizeAccountsResult{Error: "读取内部账号库失败: " + err.Error()}
|
||||
}
|
||||
|
||||
missSet := make(map[string]bool)
|
||||
@@ -160,9 +163,9 @@ func (a *App) OrganizeAccounts(commodityID, commodityName string, startTime, end
|
||||
newContent := strings.Join(keepLines, "\r\n") + "\r\n"
|
||||
backupPath, err := writeFileWithBackup(accountFile, []byte(newContent))
|
||||
if err != nil {
|
||||
return types.OrganizeAccountsResult{Error: "更新账号文件失败: " + err.Error()}
|
||||
return types.OrganizeAccountsResult{Error: "更新内部账号库失败: " + err.Error()}
|
||||
}
|
||||
logger.LogEvent("整理", "success", "账号文件已安全更新,备份=%s", backupPath)
|
||||
logger.LogEvent("整理", "success", "内部账号库已安全更新,备份=%s", backupPath)
|
||||
|
||||
// 重新加载账号
|
||||
a.scheduler.LoadAccounts()
|
||||
|
||||
Reference in New Issue
Block a user