feat: 增加 Web 管理界面,扫描整理改为页面点击触发
- main.go 改为 Web 服务入口(Gin + 内嵌前端 dist + 自动打开浏览器) - internal/service: 新增扫描整理后台任务,支持状态机与实时日志捕获 - internal/api: 新增统一响应、媒体列表/统计、扫描开始/状态接口 - internal/store: 追加 ListMedia/CountMedia/Stats 查询,MediaInfo 补 JSON tag - internal/config: application.properties 配置加载(端口/数据库/自动开浏览器) - frontend: Vue2 + ElementUI + Vite 工程,含扫描整理/统计看板/媒体库三页 - build.sh 整合前端构建,输出单一 kenaito-media-picker.exe
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// Package config 提供 Web 服务的基础配置加载(Spring Boot 风格 properties 文件)。
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/magiconair/properties"
|
||||
)
|
||||
|
||||
// Config 服务配置
|
||||
type Config struct {
|
||||
Port int // HTTP 监听端口
|
||||
Dsn string // 数据库路径(相对路径相对服务启动目录)
|
||||
AutoOpen bool // 启动后自动打开浏览器
|
||||
}
|
||||
|
||||
// appConfig 当前生效配置(供 api 层读取)
|
||||
var appConfig Config
|
||||
|
||||
// GetAppConfig 返回当前生效配置
|
||||
func GetAppConfig() Config {
|
||||
return appConfig
|
||||
}
|
||||
|
||||
// LoadAppConfig 从 application.properties 读取配置;文件缺失时使用默认值
|
||||
func LoadAppConfig() {
|
||||
appConfig = Config{Port: 8080, Dsn: "media-info.db", AutoOpen: true}
|
||||
|
||||
p, err := properties.LoadFile("application.properties", properties.UTF8)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if port := p.GetInt("server.port", 0); port > 0 {
|
||||
appConfig.Port = port
|
||||
}
|
||||
if v, ok := p.Get("database.dsn"); ok && v != "" {
|
||||
appConfig.Dsn = v
|
||||
}
|
||||
appConfig.AutoOpen = p.GetBool("server.autoOpen", true)
|
||||
}
|
||||
Reference in New Issue
Block a user