mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Complete template files
This commit is contained in:
9 files changed
+227
-10
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
// import { } from "antd";
|
||||
|
||||
import {
|
||||
BaseWebPlugin, PageLayout, Control, ControlContext, notifyErrorHandler
|
||||
} from "@clusterio/web_ui";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { PluginExampleEvent, PluginExampleRequest } from "../messages";
|
||||
|
||||
function MyTemplatePage() {
|
||||
let control = useContext(ControlContext);
|
||||
|
||||
return <PageLayout nav={[{ name: "// plugin_name //" }]}>
|
||||
<h2>// plugin_name //</h2>
|
||||
</PageLayout>;
|
||||
}
|
||||
|
||||
export class WebPlugin extends BaseWebPlugin {
|
||||
async init() {
|
||||
this.pages = [
|
||||
{
|
||||
path: "/// plugin_name //",
|
||||
sidebarName: "// plugin_name //",
|
||||
permission: "// plugin_name //.page.view",
|
||||
content: <MyTemplatePage/>,
|
||||
},
|
||||
];
|
||||
|
||||
this.control.handle(PluginExampleEvent, this.handlePluginExampleEvent.bind(this));
|
||||
this.control.handle(PluginExampleRequest, this.handlePluginExampleRequest.bind(this));
|
||||
}
|
||||
|
||||
async handlePluginExampleEvent(event: PluginExampleEvent) {
|
||||
this.logger.info(JSON.stringify(event));
|
||||
}
|
||||
|
||||
async handlePluginExampleRequest(request: PluginExampleRequest) {
|
||||
this.logger.info(JSON.stringify(request));
|
||||
return {
|
||||
myResponseString: request.myString,
|
||||
myResponseNumbers: request.myNumberArray,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user