feat(scan): 添加自定义扫描目录选择功能

- 在扫描页面添加目录输入框和选择按钮
- 实现文件系统浏览器,支持Windows盘符和目录浏览
- 添加扫描目录参数传递到后端服务
- 显示当前扫描目录路径信息
- 修复前端空数组访问错误
- 更新文档说明扫描功能变化
This commit is contained in:
2025-04-24 21:05:00 +08:00
parent e053b378fb
commit 14056ba7b9
13 changed files with 460 additions and 135 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
## 功能特性
- **图片 / 视频 / 音频**:扫描当前目录(递归),自动识别图片、视频与音频文件
- **图片 / 视频 / 音频**:可指定任意目录进行扫描(递归),自动识别图片、视频与音频文件;不填目录时默认扫描程序当前运行目录
- **标准分辨率归类**:720P、1080P、2K、2.5K、影院 2K、DCI 4K、8K 及带鱼屏(UltraWide 2K/3K/4K)等标准规格单独建目录
- **非标分辨率归类**:按像素区间(每 1024px 一档)自动归入 1K ~ 19K / 普通 / 原图(原画质)目录
- **方向区分**:横屏、竖屏、等比(正方形)分开整理,GIF 单独处理
@@ -87,7 +87,7 @@ npm install && npm run dev
| 页面 | 功能 |
|------|------|
| 扫描整理 | 点击【开始扫描】触发扫描归类,实时显示运行日志与进度 |
| 扫描整理 | 点击「选择目录」浏览服务器磁盘(只列目录),也可手动输入;点击【开始扫描】触发扫描归类,实时显示运行日志与进度 |
| 统计看板 | 媒体总数/总体积/重复文件、类型/方向/分辨率/编码/格式分布、体积 TOP10 |
| 媒体库 | 按类型/方向/分辨率/编码/格式/文件名筛选,分页 + 列排序 |
+115 -115
View File
@@ -1,215 +1,215 @@
<template>
<el-container class="app-wrapper">
<el-aside width="220px" class="app-aside">
<div class="app-logo">
<span class="logo-icon"></span>
<span>媒体库管理</span>
</div>
<el-menu
:default-active="$route.path"
router
background-color="transparent"
text-color="#4a5a78"
active-text-color="#1677ff"
>
<el-menu-item index="/scan">
<i class="el-icon-video-play"></i>
<span slot="title">扫描整理</span>
</el-menu-item>
<el-menu-item index="/dashboard">
<i class="el-icon-data-line"></i>
<span slot="title">统计看板</span>
</el-menu-item>
<el-menu-item index="/media">
<i class="el-icon-film"></i>
<span slot="title">媒体库</span>
</el-menu-item>
</el-menu>
<div class="aside-footer">kenaito-media-picker</div>
</el-aside>
<el-main class="app-main">
<router-view/>
</el-main>
</el-container>
<el-container class="app-wrapper">
<el-aside width="220px" class="app-aside">
<div class="app-logo">
<span class="logo-icon"></span>
<span>媒体库管理</span>
</div>
<el-menu
:default-active="$route.path"
router
background-color="transparent"
text-color="#4a5a78"
active-text-color="#1677ff"
>
<el-menu-item index="/dashboard">
<i class="el-icon-data-line"></i>
<span slot="title">统计看板</span>
</el-menu-item>
<el-menu-item index="/scan">
<i class="el-icon-video-play"></i>
<span slot="title">扫描整理</span>
</el-menu-item>
<el-menu-item index="/media">
<i class="el-icon-film"></i>
<span slot="title">媒体库</span>
</el-menu-item>
</el-menu>
<div class="aside-footer">kenaito-media-picker</div>
</el-aside>
<el-main class="app-main">
<router-view/>
</el-main>
</el-container>
</template>
<script>
export default {
name: 'App'
name: 'App'
}
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body,
#app {
height: 100%;
height: 100%;
}
body {
/* 科技风浅色背景:纯色 + 细网格线 */
background: linear-gradient(rgba(22, 119, 255, 0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(22, 119, 255, 0.05) 1px, transparent 1px),
#f2f7ff;
background-size: 26px 26px, 26px 26px, 100% 100%;
/* 科技风浅色背景:纯色 + 细网格线 */
background: linear-gradient(rgba(22, 119, 255, 0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(22, 119, 255, 0.05) 1px, transparent 1px),
#f2f7ff;
background-size: 26px 26px, 26px 26px, 100% 100%;
}
.app-wrapper {
height: 100%;
height: 100%;
}
/* ===== 侧边栏:浅色科技面板 ===== */
.app-aside {
background: rgba(255, 255, 255, 0.92);
border-right: 1px solid #e3edff;
display: flex;
flex-direction: column;
box-shadow: 2px 0 16px rgba(22, 119, 255, 0.06);
background: rgba(255, 255, 255, 0.92);
border-right: 1px solid #e3edff;
display: flex;
flex-direction: column;
box-shadow: 2px 0 16px rgba(22, 119, 255, 0.06);
}
.app-logo {
height: 64px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
font-size: 17px;
font-weight: 700;
letter-spacing: 1px;
color: #1677ff;
height: 64px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
font-size: 17px;
font-weight: 700;
letter-spacing: 1px;
color: #1677ff;
}
.logo-icon {
width: 12px;
height: 12px;
border-radius: 50%;
background: #1677ff;
box-shadow: 0 0 8px rgba(22, 119, 255, 0.6);
width: 12px;
height: 12px;
border-radius: 50%;
background: #1677ff;
box-shadow: 0 0 8px rgba(22, 119, 255, 0.6);
}
.app-aside .el-menu {
border-right: none;
padding: 8px 12px;
flex: 1;
border-right: none;
padding: 8px 12px;
flex: 1;
}
.app-aside .el-menu-item {
height: 44px;
line-height: 44px;
border-radius: 8px;
margin-bottom: 6px;
font-size: 14px;
height: 44px;
line-height: 44px;
border-radius: 8px;
margin-bottom: 6px;
font-size: 14px;
}
.app-aside .el-menu-item:hover {
background: #eef5ff;
color: #1677ff !important;
background: #eef5ff;
color: #1677ff !important;
}
.app-aside .el-menu-item.is-active {
background: #e8f1ff;
color: #1677ff !important;
font-weight: 600;
background: #e8f1ff;
color: #1677ff !important;
font-weight: 600;
}
.aside-footer {
padding: 14px;
text-align: center;
font-size: 11px;
color: #9db4d9;
letter-spacing: 0.5px;
padding: 14px;
text-align: center;
font-size: 11px;
color: #9db4d9;
letter-spacing: 0.5px;
}
/* ===== 主区域 ===== */
.app-main {
background: transparent;
padding: 20px;
overflow-y: auto;
background: transparent;
padding: 20px;
overflow-y: auto;
}
/* ===== 卡片:科技风白卡 ===== */
.page-card {
position: relative;
background: #fff;
border-radius: 12px;
padding: 20px 24px;
border: 1px solid #e6efff;
box-shadow: 0 4px 20px rgba(22, 119, 255, 0.08);
position: relative;
background: #fff;
border-radius: 12px;
padding: 20px 24px;
border: 1px solid #e6efff;
box-shadow: 0 4px 20px rgba(22, 119, 255, 0.08);
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.toolbar .title {
font-size: 16px;
font-weight: 600;
color: #1f3a6b;
font-size: 16px;
font-weight: 600;
color: #1f3a6b;
}
/* ===== ElementUI 组件科技风覆盖 ===== */
.el-button--primary {
background: #1677ff;
border: none;
background: #1677ff;
border: none;
}
.el-button--primary:hover,
.el-button--primary:focus {
background: #0f6bff;
box-shadow: 0 4px 14px rgba(22, 119, 255, 0.35);
background: #0f6bff;
box-shadow: 0 4px 14px rgba(22, 119, 255, 0.35);
}
.el-table {
border-radius: 8px;
border-radius: 8px;
}
.el-table th.el-table__cell {
background: #f0f6ff;
color: #1f3a6b;
font-weight: 600;
background: #f0f6ff;
color: #1f3a6b;
font-weight: 600;
}
.el-table--border,
.el-table--group {
border-color: #e6efff;
border-color: #e6efff;
}
.el-input__inner:focus,
.el-textarea__inner:focus,
.el-select .el-input.is-focus .el-input__inner {
border-color: #1677ff;
box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
border-color: #1677ff;
box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}
.el-dialog {
border-radius: 12px;
border-radius: 12px;
}
.el-dialog__title {
color: #1f3a6b;
font-weight: 600;
color: #1f3a6b;
font-weight: 600;
}
.el-pagination.is-background .el-pager li:not(.disabled).active {
background: #1677ff;
background: #1677ff;
}
.el-switch.is-checked .el-switch__core {
background: #1677ff;
border-color: #1677ff;
background: #1677ff;
border-color: #1677ff;
}
.pem-textarea textarea {
font-family: Menlo, Consolas, monospace;
font-size: 12px;
font-family: Menlo, Consolas, monospace;
font-size: 12px;
}
</style>
+2 -2
View File
@@ -59,12 +59,12 @@
<div class="panel">
<div class="panel-title">分辨率分布</div>
<div v-for="item in stats.resCount.slice(0, 8)" :key="item.key" class="dist-row">
<div v-for="item in (stats.resCount || []).slice(0, 8)" :key="item.key" class="dist-row">
<span class="dist-label">{{ item.key }}</span>
<el-progress :percentage="percent(item.count, resTotal)" :stroke-width="14" color="#1677ff"/>
<span class="dist-count">{{ item.count }}</span>
</div>
<div v-if="stats.resCount.length === 0" class="empty-tip">暂无带尺寸的媒体</div>
<div v-if="!stats.resCount || stats.resCount.length === 0" class="empty-tip">暂无带尺寸的媒体</div>
</div>
<div class="panel">
+175 -3
View File
@@ -6,10 +6,24 @@
<div class="scan-tip">
<i class="el-icon-warning-outline"></i>
点击开始后,程序将扫描当前运行目录并自动归类媒体文件(<b>会移动文件</b>,整理前请先备份)。
点击开始后,程序将扫描所选目录并自动归类媒体文件(<b>会移动文件</b>,整理前请先备份)。
整理期间请保持服务运行,结束后可在「媒体库」查看结果。
</div>
<div class="scan-form">
<div class="form-row">
<span class="form-label">扫描目录</span>
<el-input
v-model="scanDir"
placeholder="留空则扫描程序当前运行目录,例如 D:\media 或 /Users/me/Pictures"
clearable
size="medium"
@keyup.enter.native="handleStart">
<el-button slot="append" icon="el-icon-folder-opened" @click="openDirPicker">选择目录</el-button>
</el-input>
</div>
</div>
<div class="scan-actions">
<el-button
v-if="status.state !== 'running'"
@@ -41,9 +55,64 @@
:closable="false"
class="state-alert"/>
<el-dialog
title="选择要整理的目录"
:visible.sync="dirPickerVisible"
width="520px"
append-to-body>
<div class="dir-picker">
<div class="dir-nav">
<el-button
v-if="fsData.drives && fsData.drives.length"
size="mini"
icon="el-icon-refresh"
@click="loadFs('')">盘符</el-button>
<el-button
v-else-if="fsData.current"
size="mini"
icon="el-icon-back"
:disabled="fsData.parent === fsData.current"
@click="loadFs(fsData.parent)">上一级</el-button>
<span class="dir-path" :title="fsData.current">{{ fsData.current || '选择磁盘' }}</span>
</div>
<div v-if="fsData.drives && fsData.drives.length" class="dir-list">
<div
v-for="d in fsData.drives"
:key="d"
class="dir-item"
@click="loadFs(d)">
<i class="el-icon-folder"></i>
<span>{{ d }}</span>
</div>
</div>
<div v-else class="dir-list" v-loading="dirLoading">
<div
v-for="d in fsData.dirs"
:key="d.path"
class="dir-item"
@dblclick="loadFs(d.path)">
<i class="el-icon-folder"></i>
<span>{{ d.name }}</span>
</div>
<div v-if="!dirLoading && fsData.dirs.length === 0" class="dir-empty">此目录下没有子目录</div>
</div>
</div>
<div slot="footer">
<el-button @click="dirPickerVisible = false">取消</el-button>
<el-button
type="primary"
:disabled="!fsData.current"
@click="confirmDir">选中此目录</el-button>
</div>
</el-dialog>
<div class="log-panel">
<div class="log-header">
<span>运行日志</span>
<span class="muted" v-if="status.rootDir">扫描目录:{{ status.rootDir }}</span>
<span class="muted" v-if="status.started">开始于 {{ status.started }}</span>
</div>
<div ref="logBox" class="log-body" v-loading="status.state === 'running'">
@@ -62,14 +131,24 @@ export default {
data() {
return {
starting: false,
scanDir: localStorage.getItem('scan-dir') || '',
status: {
state: 'idle',
message: '',
started: '',
elapsed: 0,
rootDir: '',
lines: []
},
pollTimer: null
pollTimer: null,
dirPickerVisible: false,
dirLoading: false,
fsData: {
current: '',
parent: '',
drives: [],
dirs: []
}
}
},
mounted() {
@@ -99,7 +178,8 @@ export default {
async handleStart() {
this.starting = true
try {
const res = await request.post('/api/scan/start')
localStorage.setItem('scan-dir', this.scanDir)
const res = await request.post('/api/scan/start', { dir: this.scanDir.trim() })
this.status = res.data || this.status
this.startPoll()
this.$message.success('已开始扫描整理')
@@ -107,6 +187,27 @@ export default {
this.starting = false
}
},
openDirPicker() {
this.dirPickerVisible = true
this.loadFs(this.scanDir.trim())
},
async loadFs(dir) {
this.dirLoading = true
try {
const res = await request.get('/api/fs/list', { params: dir ? { dir } : {} })
this.fsData = res.data || { current: '', parent: '', drives: [], dirs: [] }
} catch (e) {
// 拦截器已提示
} finally {
this.dirLoading = false
}
},
confirmDir() {
if (!this.fsData.current) return
this.scanDir = this.fsData.current
localStorage.setItem('scan-dir', this.scanDir)
this.dirPickerVisible = false
},
startPoll() {
this.stopPoll()
this.pollTimer = setInterval(() => this.loadStatus(), 1000)
@@ -144,6 +245,77 @@ export default {
margin-right: 4px;
}
.scan-form {
margin-bottom: 20px;
}
.form-row {
display: flex;
align-items: center;
gap: 12px;
max-width: 640px;
}
.form-label {
flex-shrink: 0;
font-size: 13px;
font-weight: 600;
color: #1f3a6b;
}
.dir-picker .dir-nav {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
}
.dir-picker .dir-path {
flex: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 13px;
color: #4a5a78;
background: #f5f7fa;
border-radius: 4px;
padding: 6px 10px;
}
.dir-picker .dir-list {
height: 320px;
overflow-y: auto;
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 6px;
}
.dir-picker .dir-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 10px;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
color: #303133;
}
.dir-picker .dir-item:hover {
background: #f0f6ff;
}
.dir-picker .dir-item .el-icon-folder {
color: #faad14;
}
.dir-picker .dir-empty {
padding: 30px 0;
text-align: center;
color: #909399;
font-size: 13px;
}
.scan-actions {
margin-bottom: 20px;
}
+1 -1
View File
@@ -11,6 +11,7 @@ require (
github.com/redmask-hb/GoSimplePrint v0.0.0-20210302075413-3a3af92bcb7d
github.com/satori/go.uuid v1.2.0
golang.org/x/image v0.16.0
golang.org/x/sys v0.41.0
xorm.io/xorm v1.3.4
)
@@ -44,7 +45,6 @@ require (
golang.org/x/arch v0.22.0 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
modernc.org/libc v1.22.2 // indirect
+88
View File
@@ -0,0 +1,88 @@
// Package api 提供服务器文件系统浏览接口,供前端目录选择器使用(只列出目录,不列文件)。
package api
import (
"net/http"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"github.com/gin-gonic/gin"
)
// FsController 服务器文件系统浏览控制器
type FsController struct{}
// NewFsController 创建文件系统浏览控制器
func NewFsController() *FsController {
return &FsController{}
}
// FsListResult 目录浏览结果
type FsListResult struct {
Current string `json:"current"` // 当前目录绝对路径;盘符层为空
Parent string `json:"parent"` // 父目录;根/盘符层时等于 Current
Drives []string `json:"drives"` // Windows 盘符列表(非 Windows 为空)
Dirs []FsDir `json:"dirs"` // 子目录列表(不含文件)
}
// FsDir 子目录项
type FsDir struct {
Name string `json:"name"`
Path string `json:"path"`
}
// List GET /api/fs/list?dir= 列出指定目录的子目录(不含文件);
// dir 为空时返回 Windows 盘符列表或 Unix 根目录。
func (c *FsController) List(ctx *gin.Context) {
dir := strings.TrimSpace(ctx.Query("dir"))
if dir == "" {
if runtime.GOOS == "windows" {
Success(ctx, FsListResult{Drives: listLogicalDrives()})
return
}
dir = string(os.PathSeparator)
}
abs, err := filepath.Abs(dir)
if err != nil {
Error(ctx, http.StatusBadRequest, "路径解析失败: "+err.Error())
return
}
st, err := os.Stat(abs)
if err != nil || !st.IsDir() {
Error(ctx, http.StatusBadRequest, "目录不存在或不可访问: "+abs)
return
}
entries, err := os.ReadDir(abs)
if err != nil {
Error(ctx, http.StatusBadRequest, "读取目录失败: "+err.Error())
return
}
parent := filepath.Dir(abs)
if parent == abs {
parent = abs
}
dirs := make([]FsDir, 0, len(entries))
for _, e := range entries {
if !e.IsDir() {
continue
}
dirs = append(dirs, FsDir{Name: e.Name(), Path: filepath.Join(abs, e.Name())})
}
sort.Slice(dirs, func(i, j int) bool {
return strings.ToLower(dirs[i].Name) < strings.ToLower(dirs[j].Name)
})
Success(ctx, FsListResult{
Current: abs,
Parent: parent,
Drives: nil,
Dirs: dirs,
})
}
+8
View File
@@ -0,0 +1,8 @@
//go:build !windows
package api
// listLogicalDrives 非 Windows 平台无盘符概念,返回空
func listLogicalDrives() []string {
return nil
}
+20
View File
@@ -0,0 +1,20 @@
//go:build windows
package api
import "golang.org/x/sys/windows"
// listLogicalDrives 返回 Windows 所有逻辑盘符(如 C:\、D:\)
func listLogicalDrives() []string {
bits, err := windows.GetLogicalDrives()
if err != nil {
return nil
}
drives := make([]string, 0, 26)
for i := 0; i < 26; i++ {
if bits&(1<<uint(i)) != 0 {
drives = append(drives, string(rune('A'+i))+":\\")
}
}
return drives
}
+3
View File
@@ -28,6 +28,9 @@ func NewRouter(st *store.Store) *gin.Engine {
sc := NewScanController(service.NewScanService(st))
apiGroup.POST("/scan/start", sc.Start)
apiGroup.GET("/scan/status", sc.Status)
fc := NewFsController()
apiGroup.GET("/fs/list", fc.List)
}
return r
}
+11 -1
View File
@@ -18,9 +18,19 @@ func NewScanController(svc *service.ScanService) *ScanController {
return &ScanController{service: svc}
}
// scanStartReq 扫描启动请求;dir 为空时使用服务当前运行目录
type scanStartReq struct {
Dir string `json:"dir"`
}
// Start POST /api/scan/start 触发一次扫描整理
func (c *ScanController) Start(ctx *gin.Context) {
if err := c.service.Start(); err != nil {
var req scanStartReq
if err := ctx.ShouldBindJSON(&req); err != nil {
Error(ctx, http.StatusBadRequest, "请求参数错误:"+err.Error())
return
}
if err := c.service.Start(req.Dir); err != nil {
Error(ctx, http.StatusBadRequest, err.Error())
return
}
+32 -10
View File
@@ -34,6 +34,7 @@ type ScanStatus struct {
Message string `json:"message"` // 简要说明
Started string `json:"started"` // 开始时间
Elapsed int64 `json:"elapsed"` // 已运行秒数
RootDir string `json:"rootDir"` // 本次扫描的根目录
Lines []string `json:"lines"` // 运行日志
}
@@ -44,6 +45,7 @@ type ScanService struct {
state ScanState
msg string
started time.Time
rootDir string
lines []string
}
@@ -52,20 +54,26 @@ func NewScanService(st *store.Store) *ScanService {
return &ScanService{store: st, state: ScanIdle}
}
// Start 启动一次扫描整理;已在运行时返回错误
func (s *ScanService) Start() error {
// Start 启动一次扫描整理;已在运行时返回错误。rootDir 为空时默认扫描当前运行目录。
func (s *ScanService) Start(rootDir string) error {
s.mu.Lock()
if s.state == ScanRunning {
s.mu.Unlock()
return errors.New("扫描整理正在运行中,请等待完成")
}
rootDir = resolveRootDir(rootDir)
if st, err := os.Stat(rootDir); err != nil || !st.IsDir() {
s.mu.Unlock()
return fmt.Errorf("扫描目录不存在或不可访问: %s", rootDir)
}
s.state = ScanRunning
s.msg = ""
s.started = time.Now()
s.rootDir = rootDir
s.lines = nil
s.mu.Unlock()
go s.run()
go s.run(rootDir)
return nil
}
@@ -82,12 +90,29 @@ func (s *ScanService) Status() ScanStatus {
Message: s.msg,
Started: s.started.Format("2006-01-02 15:04:05"),
Elapsed: elapsed,
RootDir: s.rootDir,
Lines: append([]string{}, s.lines...),
}
}
// resolveRootDir 解析扫描根目录:空值回退当前工作目录,并做绝对路径归一化
func resolveRootDir(dir string) string {
if strings.TrimSpace(dir) == "" {
wd, err := os.Getwd()
if err == nil {
return wd
}
return "."
}
abs, err := filepath.Abs(strings.TrimSpace(dir))
if err != nil {
return strings.TrimSpace(dir)
}
return abs
}
// run 后台执行:捕获 stdout 日志流式写入 lines,结束后更新状态
func (s *ScanService) run() {
func (s *ScanService) run(rootDir string) {
r, w, err := os.Pipe()
if err != nil {
s.finish(ScanError, "创建日志管道失败: "+err.Error())
@@ -112,7 +137,7 @@ func (s *ScanService) run() {
}
}()
scanErr := s.runScan()
scanErr := s.runScan(rootDir)
os.Stdout = oldStdout
_ = w.Close()
@@ -144,12 +169,9 @@ func sanitizeLine(line string) string {
}
// runScan 执行完整整理流程:扫描 → 过滤 → 释放解码器 → 归类 → 移动
func (s *ScanService) runScan() error {
rootDir, err := os.Getwd()
if err != nil {
return fmt.Errorf("获取当前路径异常: %v", err)
}
func (s *ScanService) runScan(rootDir string) error {
pickerDir := filepath.Join(rootDir, filepath.Base(rootDir)+"-picker")
fmt.Printf("=== 扫描根目录: %s \n", rootDir)
fmt.Printf("=== 整理输出目录(白名单): %s \n", pickerDir)
res, err := scanner.Scan(scanner.Options{
+3 -1
View File
@@ -285,7 +285,9 @@ func (s *Store) Stats() (*MediaStats, error) {
if s == nil || s.engine == nil {
return &MediaStats{}, nil
}
st := &MediaStats{}
st := &MediaStats{
ResCount: []KV{}, // 避免空库时返回 null,前端 .slice 直接可用
}
if total, err := s.engine.Count(new(MediaInfo)); err == nil {
st.TotalFiles = total
BIN
View File
Binary file not shown.