feat: Add front-end plug-in demo

This commit is contained in:
haitaoo 2023-06-08 15:47:01 +08:00
parent 740e7a0fa0
commit f75cdaaa4b
7 changed files with 48 additions and 0 deletions

1
ui/.gitignore vendored
View File

@ -35,3 +35,4 @@ package-lock.json
/* !/src/plugins
/src/plugins/*
!/src/plugins/builtin
!/src/plugins/Demo

View File

@ -0,0 +1,4 @@
plugin:
ui_plugin_demo:
ui:
msg: UI Plugin Demo

View File

@ -0,0 +1,9 @@
import pluginKit from '@/utils/pluginKit';
import en_US from './en_US.yaml';
import zh_CN from './zh_CN.yaml';
pluginKit.initI18nResource({
en_US,
zh_CN,
});

View File

@ -0,0 +1,4 @@
plugin:
ui_plugin_demo:
ui:
msg: UI 插件示例

View File

@ -0,0 +1,24 @@
import { memo, FC } from 'react';
import { useTranslation } from 'react-i18next';
import { Alert } from 'react-bootstrap';
import pluginKit, { PluginInfo } from '@/utils/pluginKit';
import './i18n';
import info from './info.yaml';
const pluginInfo: PluginInfo = {
slug_name: info.slug_name,
};
const Index: FC = () => {
const { t } = useTranslation(pluginKit.getTransNs(), {
keyPrefix: pluginKit.getTransKeyPrefix(pluginInfo),
});
return <Alert variant="info">{t('msg')}</Alert>;
};
export default {
info: pluginInfo,
component: memo(Index),
};

View File

@ -0,0 +1,4 @@
slug_name: ui_plugin_demo
version: 0.0.1
author: Answer.dev

View File

@ -1 +1,3 @@
export default null;
export { default as Demo } from './Demo';