feat: add download micro-app for cli
This commit is contained in:
@@ -129,18 +129,27 @@ router.get('/api/micro-app/download/:id', async (req, res) => {
|
||||
res.end(error('Key parameter is required'));
|
||||
return;
|
||||
}
|
||||
|
||||
const query = new URL(req.url || '', 'http://localhost');
|
||||
const notNeedToken = query.searchParams.get('notNeedToken') || '';
|
||||
const fileTitle = query.searchParams.get('title') || '';
|
||||
if (res.headersSent) return; // 如果响应已发送,不再处理
|
||||
let tokenUser;
|
||||
if (!DEV_SERVER) {
|
||||
if (!DEV_SERVER && !notNeedToken) {
|
||||
const auth = await checkAuth(req, res);
|
||||
tokenUser = auth.tokenUser;
|
||||
if (!tokenUser) return;
|
||||
}
|
||||
const file = await MicroAppUploadModel.findByPk(id);
|
||||
let file: MicroAppUploadModel | null = null;
|
||||
if (!DEV_SERVER) {
|
||||
file.uid !== tokenUser.id && res.end(error('No permission', 403));
|
||||
return;
|
||||
// file.uid !== tokenUser.id && res.end(error('No permission', 403));
|
||||
// return;
|
||||
}
|
||||
if (fileTitle) {
|
||||
file = await MicroAppUploadModel.findOne({
|
||||
where: { title: fileTitle },
|
||||
});
|
||||
} else if (id) {
|
||||
file = await MicroAppUploadModel.findByPk(id);
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
|
||||
Reference in New Issue
Block a user