mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 05:07:46 +00:00
feat: 新增获取面板列表handler供开发者调用
This commit is contained in:
parent
5d14c419f7
commit
8d36a3ec84
2 changed files with 28 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ import {
|
|||
getPanelOrigin,
|
||||
updatePanelData,
|
||||
formatPanelData,
|
||||
getPanelListOrigin,
|
||||
} from '../lib/avatar.js';
|
||||
import settings from '../lib/settings.js';
|
||||
import _ from 'lodash';
|
||||
|
|
@ -32,6 +33,7 @@ export class Panel extends ZZZPlugin {
|
|||
},
|
||||
],
|
||||
handler: [{ key: 'zzz.tool.panel', fn: 'getCharPanelTool' }],
|
||||
handler: [{ key: 'zzz.tool.panelList', fn: 'getCharPanelListTool' }],
|
||||
});
|
||||
}
|
||||
async handleRule() {
|
||||
|
|
@ -98,6 +100,19 @@ export class Panel extends ZZZPlugin {
|
|||
};
|
||||
await this.render('panel/list.html', finalData);
|
||||
}
|
||||
|
||||
async getCharPanelListTool(uid, origin = false) {
|
||||
if (!uid) {
|
||||
return false;
|
||||
}
|
||||
if (origin) {
|
||||
const result = getPanelListOrigin(uid);
|
||||
return result;
|
||||
}
|
||||
const result = getPanelList(uid);
|
||||
return result;
|
||||
}
|
||||
|
||||
async getCharPanel() {
|
||||
const uid = await this.getUID();
|
||||
const reg = new RegExp(`${rulePrefix}(.+)面板$`);
|
||||
|
|
@ -122,6 +137,8 @@ export class Panel extends ZZZPlugin {
|
|||
|
||||
async getCharPanelTool(e, _data = {}) {
|
||||
if (e) this.e = e;
|
||||
if (e?.reply) this.reply = e.reply;
|
||||
|
||||
const {
|
||||
uid = undefined,
|
||||
data = undefined,
|
||||
|
|
@ -130,11 +147,11 @@ export class Panel extends ZZZPlugin {
|
|||
} = _data;
|
||||
if (!uid) {
|
||||
await this.reply('UID为空');
|
||||
throw new Error('UID为空');
|
||||
return false;
|
||||
}
|
||||
if (!data) {
|
||||
await this.reply('数据为空');
|
||||
throw new Error('数据为空');
|
||||
return false;
|
||||
}
|
||||
if (needSave) {
|
||||
updatePanelData(uid, [data]);
|
||||
|
|
|
|||
|
|
@ -118,6 +118,15 @@ export const getPanelList = uid => {
|
|||
return data.map(item => new ZZZAvatarInfo(item));
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取面板数据(原始数据)
|
||||
* @param {string} uid
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const getPanelListOrigin = uid => {
|
||||
return getPanelData(uid);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取某个角色的面板数据
|
||||
* @param {string} uid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue