tachybase_todo/packages/plugins/@nocobase/plugin-mobile-client/src/client/index.tsx
Zeke Zhang 51de34251a
refactor(SchemaInitializers): unify naming style (#3604)
* refactor(SchemaSettings): unify naming style

* refactor(SchemaInitializers): unify naming stle

* refactor: replace CreateFormBlockInitializers to blockInitializers:createForm

* refactor: replace to blockInitializers:customizeCreateForm

* refactor: replace block intializers name

* refactor: replace action initializers name

* refactor: replace field initializers name

* style: fix hover style for column action (T-3297)

* refactor: revert some codes

* chore: update comment

* chore: replace iframeBlockSchemaSettings to blockSettings:iframe

* chore: delete pro-packages

* feat: add CompatibleSchemaInitializer

* test: add unit tests

* chore: add @internal for CompatibleSchemaInitializer

* chore: block

* chore: field

* chore: ations

* fix: build

* chore: typo

* fix: fix unit tests

* test: fix e2e

* chore: remove igone

* refactor: page:addBlock

* refactor: popup:addNew:addBlock

* fix: fix max call stack

* refactor: popup:addRecord:addBlock

* refactor: remove blockInitializers:recordForm

* refactor: popup:tableSelector:addBlock

* refactor: popup:view:addBlock

* refactor: popup:bulkEdit:addBlock & charts:addBlock

* refactor: mobilePage:addBlock

* refactor: popup:snapshot:addBlock

* refactor: popup:workflowManual:configureUserInterface:addBlock

* fix: avoid crashing

* chore: optimize

* refactor: popup:common:addBlock

* refactor: workflowManual:popup:configureUserInterface:addBlock

* refactor: details:configureFields

* refactor: form:configureFields

* refactor: table:configureColumns

* refactor: filterForm:configureFields

* refactor: associationFilterInitializer

* refactor: assignFieldValuesForm:configureFields

* refactor: bulkEditForm:configureFields

* refactor: auditLogsTable:configureColumns

* refactor: chartFilterForm:configureFields

* refactor: kanban:configureItemFields

* refactor: workflowManual:customForm:configureFields

* refactor: detailsWithPaging:configureActions

* refactor: details:configureActions

* refactor: createForm:configureActions

* refactor: editForm:configureActions

* refactor: gridCard:configureActions

* refactor: gridCard:configureItemActions

* refactor: list:configureActions

* refactor: list:configureItemActions

* refactor: table:configureItemActions

* refactor: table:configureActions

* refactor: filterForm:configureActions

* refactor: subTable:configureActions

* refactor: bulkEditForm:configureActions

* refactor: auditLogsTable:configureItemActions

* refactor: auditLogsTable:configureActions

* refactor: calendar:configureActions

* refactor: chartFilterForm:configureActions

* refactor: gantt:configureActions

* refactor: kanban:configureActions

* refactor: map:configureActions

* refactor: workflowManual:form:configureActions

* feat: use 'createForm:configureActions' in page

* feat: use 'details:configureActions' in Calendar

* feat: register deleteEvent initializer in calendar plugin

* fix: fix delete event action

* test: fix e2e

* test: fix e2e

* chore: only run workflow's e2e

* Revert "chore: only run workflow's e2e"

This reverts commit 9e5b4af41e40e8d616007a5ab97291fb2370d88a.

* fix: use isInitializersSame to fix some case
2024-03-14 14:13:11 +08:00

73 lines
2.2 KiB
TypeScript

import { createRouterManager, Plugin, RouterManager, RouteSchemaComponent } from '@nocobase/client';
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { MobileClientProvider } from './MobileClientProvider';
import MApplication from './router/Application';
import { mBlockInitializers, mBlockInitializers_deprecated } from './core/schema';
import { AppConfiguration, InterfaceConfiguration } from './configuration';
import { NAMESPACE } from './locale';
export class MobileClientPlugin extends Plugin {
public mobileRouter: RouterManager;
async load() {
this.setMobileRouter();
this.addRoutes();
this.addSettings();
this.app.use(MobileClientProvider);
this.app.schemaInitializerManager.add(mBlockInitializers_deprecated);
this.app.schemaInitializerManager.add(mBlockInitializers);
}
addSettings() {
this.app.pluginSettingsManager.add(NAMESPACE, {
title: `{{t("Mobile Client-side", { ns: "${NAMESPACE}" })}}`,
icon: 'MobileOutlined',
Component: () => <Outlet />,
});
this.app.pluginSettingsManager.add(`${NAMESPACE}.interface`, {
title: `{{t("Interface Configuration", { ns: "${NAMESPACE}" })}}`,
Component: InterfaceConfiguration,
sort: 1,
});
this.app.pluginSettingsManager.add(`${NAMESPACE}.app`, {
title: `{{t("App Configuration", { ns: "${NAMESPACE}" })}}`,
Component: AppConfiguration,
sort: 2,
});
}
setMobileRouter() {
const router = createRouterManager({ type: 'hash' }, this.app);
router.add('root', {
path: '/',
element: <Navigate replace to="/mobile" />,
});
router.add('mobile', {
path: '/mobile',
element: <MApplication />,
});
router.add('mobile.page', {
path: '/mobile/:name',
element: <RouteSchemaComponent />,
});
this.mobileRouter = router;
}
getMobileRouterComponent() {
return this.mobileRouter.getRouterComponent();
}
addRoutes() {
this.app.router.add('mobile', {
path: '/mobile',
element: <MApplication />,
});
this.app.router.add('mobile.page', {
path: '/mobile/:name',
Component: 'RouteSchemaComponent',
});
}
}
export default MobileClientPlugin;