diff --git a/server/plugins/com.msgbyte.discover/services/discover.service.dev.ts b/server/plugins/com.msgbyte.discover/services/discover.service.dev.ts index 52e1548f..4e7192aa 100644 --- a/server/plugins/com.msgbyte.discover/services/discover.service.dev.ts +++ b/server/plugins/com.msgbyte.discover/services/discover.service.dev.ts @@ -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); diff --git a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/manifest.json b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/manifest.json index 6a3510da..14a4afd3 100644 --- a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/manifest.json +++ b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/manifest.json @@ -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 } diff --git a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/DiscoverPanel/index.tsx b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/DiscoverPanel/index.tsx new file mode 100644 index 00000000..1806332a --- /dev/null +++ b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/DiscoverPanel/index.tsx @@ -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
DiscoverPanel: {JSON.stringify(list)}
; +}); +DiscoverPanel.displayName = 'DiscoverPanel'; diff --git a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/index.tsx b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/index.tsx index 07705b5d..6f87e09f 100644 --- a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/index.tsx +++ b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/index.tsx @@ -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, +}); diff --git a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/request.ts b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/request.ts new file mode 100644 index 00000000..0a3dd344 --- /dev/null +++ b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/request.ts @@ -0,0 +1,3 @@ +import { createPluginRequest } from '@capital/common'; + +export const request = createPluginRequest('com.msgbyte.discover'); diff --git a/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/translate.ts b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/translate.ts new file mode 100644 index 00000000..c4d457ba --- /dev/null +++ b/server/plugins/com.msgbyte.discover/web/plugins/com.msgbyte.discover/src/translate.ts @@ -0,0 +1,8 @@ +import { localTrans } from '@capital/common'; + +export const Translate = { + discover: localTrans({ + 'zh-CN': '探索', + 'en-US': 'Discover', + }), +};