✨ plus&功能重构

This commit is contained in:
chaos-zhu
2024-11-09 23:14:51 +08:00
parent 1fdf8c6a09
commit 2c41928f65
47 changed files with 1755 additions and 726 deletions
+22 -2
View File
@@ -1,6 +1,8 @@
const localShellJson = require('../config/shell.json')
const path = require('path')
const decryptAndExecuteAsync = require('../utils/decrypt-file')
const { randomStr } = require('../utils/tools')
const { ScriptsDB } = require('../utils/db-class')
const localShellJson = require('../config/shell.json')
const scriptsDB = new ScriptsDB().getInstance()
let localShell = JSON.parse(JSON.stringify(localShellJson)).map((item) => {
@@ -44,10 +46,28 @@ const removeScript = async ({ res, request }) => {
res.success({ data: '移除成功' })
}
const batchRemoveScript = async ({ res, request }) => {
let { body: { ids } } = request
if (!Array.isArray(ids)) return res.fail({ msg: '参数错误' })
const numRemoved = await scriptsDB.removeAsync({ _id: { $in: ids } }, { multi: true })
res.success({ data: `批量移除成功,数量: ${ numRemoved }` })
}
const importScript = async ({ res, request }) => {
let { impScript } = (await decryptAndExecuteAsync(path.join(__dirname, 'plus.js'))) || {}
if (impScript) {
await impScript({ res, request })
} else {
return res.fail({ data: false, msg: 'Plus专属功能!' })
}
}
module.exports = {
addScript,
getScriptList,
getLocalScriptList,
updateScriptList,
removeScript
removeScript,
batchRemoveScript,
importScript
}