Skip to content

Commit

Permalink
feat:(Version 0.1.2) Implement Archive Backup Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
limitcool committed Jan 27, 2024
1 parent 60971cc commit 3005d6e
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
palworld-admin
backups
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# PalWorld-Admin

`PalWorld-Admin` 是一个用于管理 `PalWorld` 游戏配置文件和进行存档备份的可视化工具
`PalWorld-Admin` 是一个用于管理 `PalWorld` 游戏配置文件和进行存档备份的跨平台可视化工具

## 功能特性

- **配置文件管理:** 可以轻松查看和编辑 `PalWorld` 游戏的配置文件。
- **存档备份(开发中):** 此功能正在开发中,敬请期待。
- **存档备份:** 定时备份存档,默认单位为秒级。
- **存档恢复(开发中):**通过前端恢复指定存档。
- **前端界面:** 一个直观、用户友好的前端界面,提供更好的使用体验。
- **简单的管理员密码保护:** 使用管理员密码来保护工具的访问权限。

Expand All @@ -25,20 +26,28 @@ chmod u+x

在使用 `PalWorld-Admin` 之前,请根据您的需求修改配置文件。

### 配置项

- **adminpassword:** 管理员密码,用于保护工具的访问权限。请将 `initcool-https://blog.nmslwsnd.com` 替换为您自己的安全密码。
- **palworldconfigfilepath:** `PalWorld` 游戏配置文件的路径。默认为 `/root/palworld/data/Config/LinuxServer/PalWorldSettings.ini`,您可以根据实际情况修改。
- **port:** 工具的访问端口。默认为 `8080`,您可以根据需要更改。
```yaml
PalSavedPath: "C:\\Users\\Andorid\\AppData\\Local\\Pal\\Saved" # palworld游戏目录
AdminPassword: "initcool-https://blog.nmslwsnd.com" # 管理员面板密码
Port: 8080 # http服务监听端口
SaveConfig:
BackupInterval: 60 # 每60秒备份一次存档
MaxRetentionDays: 7 # 存档最大保留时间,默认为7天
BackupDirectory: backups/ # 存档保存目录
```
### 修改配置文件方法
- **POSIX (Linux/BSD):** 配置文件路径为 `~/.palworld-admin/config.yaml`。
- **Windows:** 配置文件路径为 `%LOCALAPPDATA%/palworld-admin/config.yaml`。

## 路线图

- **存档恢复功能(预计下个版本):** 计划在下一个版本中添加存档恢复功能。

## 反馈与支持

我们欢迎您提供宝贵的反馈意见,帮助我们不断改进工具。您可以加入我们的 QQ 群699024161
我们欢迎您提供宝贵的反馈意见,帮助我们不断改进工具。您可以加入我们的 `QQ 群`:`699024161`

![QQ群:699024161](https://github.com/limitcool/palworld-admin/blob/main/images/qqgroup.jpg?raw=true)

42 changes: 25 additions & 17 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,43 @@ import (
"os"

"github.com/charmbracelet/log"

"github.com/spf13/viper"
"gopkg.in/yaml.v3"
)

type SaveConfig struct {
BackupInterval int `yaml:"BackupInterval"` // Interval between backups in minutes
MaxRetentionDays int `yaml:"MaxRetentionDays"` // Maximum retention period for backups in days
BackupDirectory string `yaml:"BackupDirectory"` // Directory to retain game saves
}
type Config struct {
PalWorldConfigFilePath string
AdminPassword string
Port int
PalSavedPath string `yaml:"PalSavedPath"`
AdminPassword string `yaml:"AdminPassword"`
Port int `yaml:"Port"`
SaveConfig SaveConfig `yaml:"SaveConfig"`
}

// 初始化并生成默认配置
func InitDefaultConfig(configPath string, configFile string) {
defaultConfig := Config{
PalWorldConfigFilePath: "/root/palworld/data/Config/LinuxServer/PalWorldSettings.ini",
AdminPassword: "initcool-https://blog.nmslwsnd.com",
Port: 8080,
PalSavedPath: "",
AdminPassword: "initcool-https://blog.nmslwsnd.com",
Port: 8080,
SaveConfig: SaveConfig{
BackupInterval: 60,
MaxRetentionDays: 7,
BackupDirectory: "backups/",
},
}

if err := os.MkdirAll(configPath, 0755); err != nil {
log.Error(err)
}
viper.SetConfigType("yaml")
viper.SetConfigFile(configFile)
// 将默认配置写入配置文件
viper.Set("PalWorldConfigFilePath", defaultConfig.PalWorldConfigFilePath)
viper.Set("AdminPassword", defaultConfig.AdminPassword)
viper.Set("Port", 8080)
err := viper.WriteConfig()
data, err := yaml.Marshal(&defaultConfig)
if err != nil {
// 处理错误
log.Error("Error writing default config:", err)
log.Error(err)
}
err = os.WriteFile(configFile, data, 0755)
if err != nil {
log.Error(err)
}
}
2 changes: 1 addition & 1 deletion global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ var AppDir = util.AppDataDir("palworld-admin", false)
// var ConfigPath = filepath.Join(AppDir, "config")
var ConfigFile = filepath.Join(AppDir, "config.yaml")

const VERSION = "0.1.1"
const VERSION = "0.1.2"
40 changes: 25 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,25 @@ go 1.21.5
require (
github.com/charmbracelet/log v0.3.1
github.com/gin-gonic/gin v1.9.1
github.com/limitcool/lib v0.0.0-20240106173155-d7dff6287ae7
github.com/limitcool/starter v0.0.0-20230608072233-5873b40252c9
github.com/spf13/cast v1.6.0
github.com/spf13/viper v1.18.2
gopkg.in/ini.v1 v1.67.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/bodgit/plumbing v1.2.0 // indirect
github.com/bodgit/sevenzip v1.3.0 // indirect
github.com/bodgit/windows v1.0.0 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/charmbracelet/lipgloss v0.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dchest/blake256 v1.0.0 // indirect
github.com/decred/base58 v1.0.0 // indirect
github.com/decred/dcrd/chaincfg v1.5.1 // indirect
github.com/decred/dcrd/chaincfg/chainhash v1.0.1 // indirect
github.com/decred/dcrd/chaincfg/v2 v2.0.2 // indirect
github.com/decred/dcrd/dcrec v1.0.0 // indirect
github.com/decred/dcrd/dcrec/edwards v1.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1 v1.0.2 // indirect
github.com/decred/dcrd/dcrutil v1.4.1 // indirect
github.com/decred/dcrd/dcrutil/v2 v2.0.0 // indirect
github.com/decred/dcrd/wire v1.2.0 // indirect
github.com/connesc/cipherio v0.2.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
Expand All @@ -36,21 +32,31 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mholt/archiver/v4 v4.0.0-alpha.8 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
github.com/otiai10/copy v1.14.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
Expand All @@ -59,18 +65,22 @@ require (
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
go.mongodb.org/mongo-driver v1.13.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
Loading

0 comments on commit 3005d6e

Please sign in to comment.