mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
✨feat: 重构解析黑名单 && 锅巴配置文件添加解析黑名单
This commit is contained in:
parent
a93c8b7bf6
commit
ae4e134fc0
@ -239,6 +239,8 @@ export class tools extends plugin {
|
||||
this.defaultPath = this.toolsConfig.defaultPath;
|
||||
// 视频限制大小
|
||||
this.videoSizeLimit = this.toolsConfig.videoSizeLimit;
|
||||
// 获取全局禁用的解析
|
||||
this.globalBlackList = this.toolsConfig.globalBlackList;
|
||||
// 魔法接口
|
||||
this.proxyAddr = this.toolsConfig.proxyAddr;
|
||||
this.proxyPort = this.toolsConfig.proxyPort;
|
||||
@ -3125,18 +3127,15 @@ export class tools extends plugin {
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async isEnableResolve(resolveName) {
|
||||
const controller = await redisExistAndGetKey(REDIS_YUNZAI_RESOLVE_CONTROLLER);
|
||||
// 如果不存在说明用户没有启动过webui,那么直接放行
|
||||
const controller = this.globalBlackList;
|
||||
// 如果不存在,那么直接放行
|
||||
if (controller == null) {
|
||||
return true;
|
||||
}
|
||||
const foundItem = controller.find(item => item.label === resolveName);
|
||||
// 未知解析,可能是写错,放行
|
||||
if (!foundItem) {
|
||||
logger.warn(`[R插件][启用解析] 未知解析,可能存在写错`);
|
||||
return true;
|
||||
}
|
||||
return foundItem.value === 1;
|
||||
// 找到禁用列表中是否包含 `resolveName`
|
||||
const foundItem = controller.find(item => item === resolveName);
|
||||
// 如果 undefined 说明不在禁用列表就放行
|
||||
return foundItem === undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,5 @@
|
||||
globalBlackList: [] # 全局白名单解析
|
||||
|
||||
defaultPath: './data/rcmp4/' # 保存视频的位置
|
||||
videoSizeLimit: 70 # 视频大小限制(单位MB),超过大小则转换成群文件上传
|
||||
proxyAddr: '127.0.0.1' # 魔法地址
|
||||
|
@ -1,12 +1,15 @@
|
||||
import _ from "lodash";
|
||||
import path from "path";
|
||||
import { BILI_CDN_SELECT_LIST, BILI_DOWNLOAD_METHOD, BILI_RESOLUTION_LIST, YOUTUBE_GRAPHICS_LIST, NETEASECLOUD_QUALITY_LIST } from "./constants/constant.js";
|
||||
import { RESOLVE_CONTROLLER_NAME_ENUM } from "./constants/resolve.js";
|
||||
import model from "./model/config.js";
|
||||
|
||||
const pluginName = `rconsole-plugin`;
|
||||
|
||||
const _path = process.cwd() + `/plugins/${pluginName}`;
|
||||
export function supportGuoba() {
|
||||
let globalWhitelist = Object.values(RESOLVE_CONTROLLER_NAME_ENUM).map(value => ({ value }));
|
||||
const globalWhitelistComponent = globalWhitelist.length === 0 ? 'GTags' : 'Select'
|
||||
return {
|
||||
pluginInfo: {
|
||||
name: "R插件",
|
||||
@ -29,6 +32,18 @@ export function supportGuoba() {
|
||||
},
|
||||
configInfo: {
|
||||
schemas: [
|
||||
{
|
||||
field: 'tools.globalBlackList',
|
||||
label: '全局解析黑名单',
|
||||
component: globalWhitelistComponent,
|
||||
bottomHelpMessage: '添加后将全局禁用',
|
||||
componentProps: {
|
||||
allowAdd: true,
|
||||
allowDel: true,
|
||||
mode: 'multiple',
|
||||
options: globalWhitelist,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "tools.proxyAddr",
|
||||
label: "魔法地址",
|
||||
@ -428,10 +443,17 @@ export function supportGuoba() {
|
||||
},
|
||||
setConfigData(data, { Result }) {
|
||||
let config = {};
|
||||
let cfg = model.getConfig("tools");
|
||||
for (let [key, value] of Object.entries(data)) {
|
||||
// 特殊处理这个,需要全覆盖
|
||||
if (key === "tools.globalBlackList") {
|
||||
_.set(cfg, "globalBlackList", value);
|
||||
}
|
||||
_.set(config, key, value);
|
||||
}
|
||||
config = _.merge({}, model.getConfig("tools"), config.tools);
|
||||
// 合并配置项
|
||||
config = _.merge({}, cfg, config.tools);
|
||||
// 保存
|
||||
model.saveAllConfig("tools", config);
|
||||
return Result.ok({}, "保存成功~");
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user