feat: 网盘设置加「默认账号」列, 同类型最多2个主账号
- 数据库 migration: cloud_configs 加 is_primary 字段 - 后端: togglePrimary API (PUT /admin/cloud-configs/:id/primary) - 后端: getAndValidateCredential 优先选 is_primary 账号 - 前端: CloudConfig.vue 转存启用后加「默认账号」开关列 - 前端: api/index.ts 加 setPrimary 方法
This commit is contained in:
@@ -4,7 +4,7 @@ import fs from "fs";
|
||||
import { execSync } from 'child_process';
|
||||
import { adminLimiter, loginLimiter } from '../middleware/rate-limit';
|
||||
import { getSaveRecords } from '../cloud/cloud.service';
|
||||
import { getCloudConfigs, getCloudConfigById, saveCloudConfig, deleteCloudConfig, getCloudConfigByType, testCloudConnection, testCloudConnectionWithCookie } from '../cloud/credential.service';
|
||||
import { getCloudConfigs, getCloudConfigById, saveCloudConfig, deleteCloudConfig, getCloudConfigByType, testCloudConnection, testCloudConnectionWithCookie, togglePrimary } from '../cloud/credential.service';
|
||||
// Note: check-in routes were removed (sign-in feature removed)
|
||||
import { getAllCloudTypes } from '../cloud/cloud-types.service';
|
||||
import { login, authMiddleware, verifyToken, changePassword } from '../admin/auth.service';
|
||||
@@ -199,6 +199,20 @@ router.delete('/admin/cloud-configs/:id', (req: Request, res: Response) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* PUT /api/admin/cloud-configs/:id/primary — toggle primary status (max 2 per type)
|
||||
*/
|
||||
router.put('/admin/cloud-configs/:id/primary', (req: Request, res: Response) => {
|
||||
try {
|
||||
const id = parseInt(req.params.id as string);
|
||||
const { primary } = req.body;
|
||||
const config = togglePrimary(id, !!primary);
|
||||
res.json(config);
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ error: err.message || 'Failed to toggle primary status' });
|
||||
}
|
||||
});
|
||||
|
||||
/** POST /api/admin/cloud-configs/:type/test — test cloud connection (by type or id) */
|
||||
router.post('/admin/cloud-configs/:type/test', async (req: Request, res: Response) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user