优化 新启动首次加载
This commit is contained in:
1 parent
c215de731e
commit
b2c3ecc5ba
3 files changed
+85
-33
No files matched your search
@@ -41,6 +41,30 @@ router.post('/',
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* 更新偏好设置(必须在 /:id 之前,否则会被 /:id 匹配)
|
||||
* PUT /api/library/preferences
|
||||
* Body: { preferences }
|
||||
*/
|
||||
router.put('/preferences', asyncHandler(async (req, res) => {
|
||||
const result = libraryService.updatePreferences(req.body);
|
||||
res.json({ success: true, data: result });
|
||||
}));
|
||||
|
||||
/**
|
||||
* 更新主题(必须在 /:id 之前)
|
||||
* PUT /api/library/theme
|
||||
* Body: { theme }
|
||||
*/
|
||||
router.put('/theme',
|
||||
validateRequired(['theme']),
|
||||
asyncHandler(async (req, res) => {
|
||||
const { theme } = req.body;
|
||||
const result = libraryService.updateTheme(theme);
|
||||
res.json({ success: true, data: result });
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* 更新素材库
|
||||
* PUT /api/library/:id
|
||||
@@ -72,30 +96,6 @@ router.post('/:id/set-current', asyncHandler(async (req, res) => {
|
||||
res.json({ success: true, data: result });
|
||||
}));
|
||||
|
||||
/**
|
||||
* 更新偏好设置
|
||||
* PUT /api/library/preferences
|
||||
* Body: { preferences }
|
||||
*/
|
||||
router.put('/preferences', asyncHandler(async (req, res) => {
|
||||
const result = libraryService.updatePreferences(req.body);
|
||||
res.json({ success: true, data: result });
|
||||
}));
|
||||
|
||||
/**
|
||||
* 更新主题
|
||||
* PUT /api/library/theme
|
||||
* Body: { theme }
|
||||
*/
|
||||
router.put('/theme',
|
||||
validateRequired(['theme']),
|
||||
asyncHandler(async (req, res) => {
|
||||
const { theme } = req.body;
|
||||
const result = libraryService.updateTheme(theme);
|
||||
res.json({ success: true, data: result });
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取素材库统计
|
||||
* GET /api/library/:id/stats
|
||||
|
||||
@@ -13,21 +13,16 @@ const CONFIG_CACHE_TTL = 5000; // 5秒缓存
|
||||
function getConfigDir() {
|
||||
// Check if running on fnOS
|
||||
if (process.env.TRIM_PKGVAR) {
|
||||
console.log('📁 配置目录 (fnOS): ' + process.env.TRIM_PKGVAR);
|
||||
return process.env.TRIM_PKGVAR;
|
||||
}
|
||||
|
||||
// Windows
|
||||
if (process.platform === 'win32') {
|
||||
const dir = path.join(process.env.APPDATA || os.homedir(), 'FlyPic');
|
||||
console.log('📁 配置目录 (Windows): ' + dir);
|
||||
return dir;
|
||||
return path.join(process.env.APPDATA || os.homedir(), 'FlyPic');
|
||||
}
|
||||
|
||||
// Linux/Mac
|
||||
const dir = path.join(os.homedir(), '.flypic');
|
||||
console.log('📁 配置目录 (Linux/Mac): ' + dir);
|
||||
return dir;
|
||||
return path.join(os.homedir(), '.flypic');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user