mirror of https://gitee.com/answerdev/answer.git
feat: Add front-end plug-in demo
This commit is contained in:
parent
740e7a0fa0
commit
f75cdaaa4b
|
@ -35,3 +35,4 @@ package-lock.json
|
|||
/* !/src/plugins
|
||||
/src/plugins/*
|
||||
!/src/plugins/builtin
|
||||
!/src/plugins/Demo
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
plugin:
|
||||
ui_plugin_demo:
|
||||
ui:
|
||||
msg: UI Plugin Demo
|
|
@ -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,
|
||||
});
|
|
@ -0,0 +1,4 @@
|
|||
plugin:
|
||||
ui_plugin_demo:
|
||||
ui:
|
||||
msg: UI 插件示例
|
|
@ -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),
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
slug_name: ui_plugin_demo
|
||||
version: 0.0.1
|
||||
author: Answer.dev
|
||||
|
|
@ -1 +1,3 @@
|
|||
export default null;
|
||||
|
||||
export { default as Demo } from './Demo';
|
||||
|
|
Loading…
Reference in New Issue