mirror of
https://github.com/motajs/template.git
synced 2026-11-20 19:54:36 +08:00
1.5 KiB
1.5 KiB
UI 通用模板
写 UI 时从这段模板开始。
import { defineComponent } from 'vue';
import { GameUI, SetupComponentOptions } from '@motajs/system';
import { DefaultProps } from '@motajs/render-vue';
import { IGameUIPropsBase } from '@user/client-base';
import { FULL_LOC } from '@/client';
// 这里填写自定义的 UI 参数
interface MyPanelProps extends IGameUIPropsBase, DefaultProps {}
const myPanelProps = {
props: ['controller', 'instance', 'state']
} satisfies SetupComponentOptions<MyPanelProps>;
const MyPanel = defineComponent<MyPanelProps>(props => {
return () => (
<container loc={FULL_LOC}>{/* 在这里编写自己的 UI 内容 */}</container>
);
}, myPanelProps);
export const MyPanelUI = new GameUI('my-panel', MyPanel);
模板用法
- 复制到
src/client/ui/下新建的.tsx文件(例如my-panel.tsx)。 - 把
MyPanel、myPanelProps、MyPanelUI换成自己的名字。 - 在
<container>里写 UI 内容。 - 在
src/client/ui/index.ts中导出MyPanelUI。