feat: add discover plugin basic web page

pull/100/head
moonrailgun 2 years ago
parent b42d9fd025
commit e507aaee9d

@ -33,8 +33,10 @@ class DiscoverService extends TcService {
.find({
active: true,
})
.sort({ order: 'desc' })
.limit(size)
.skip(size * (page - 1));
.skip(size * (page - 1))
.exec();
const list = await this.transformDocuments(ctx, {}, docs);

@ -1,9 +1,11 @@
{
"label": "Discover",
"label.zh-CN": "发现群组",
"name": "com.msgbyte.discover",
"url": "{BACKEND}/plugins/com.msgbyte.discover/index.js",
"version": "0.0.0",
"author": "moonrailgun",
"description": "Add Discover panel which can help user found groups",
"description.zh-CN": "增加一个发现面板,用于探索公开的群组",
"requireRestart": true
}

@ -0,0 +1,14 @@
import React from 'react';
import { useAsync } from '@capital/common';
import { request } from '../request';
export const DiscoverPanel: React.FC = React.memo(() => {
const { value: list } = useAsync(async () => {
const { data } = await request.get('all');
return data.list ?? [];
}, []);
return <div>DiscoverPanel: {JSON.stringify(list)}</div>;
});
DiscoverPanel.displayName = 'DiscoverPanel';

@ -1 +1,16 @@
import { regCustomPanel, Loadable } from '@capital/common';
import { Translate } from './translate';
console.log('Plugin Discover is loaded');
const DiscoverPanel = Loadable(() =>
import('./DiscoverPanel').then((m) => m.DiscoverPanel)
);
regCustomPanel({
position: 'navbar-group',
icon: 'mdi:compass',
name: 'plugin:com.msgbyte.discover/entry',
label: Translate.discover,
render: DiscoverPanel,
});

@ -0,0 +1,3 @@
import { createPluginRequest } from '@capital/common';
export const request = createPluginRequest('com.msgbyte.discover');

@ -0,0 +1,8 @@
import { localTrans } from '@capital/common';
export const Translate = {
discover: localTrans({
'zh-CN': '探索',
'en-US': 'Discover',
}),
};
Loading…
Cancel
Save