From b637d3b5f364221f2fd99e0f32b93d5d9340b270 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 9 Oct 2026 15:57:03 +0800 Subject: [PATCH] feat(09-01): dedup controller/background and fix load/title props base (D-10) - Move render/ui/controller.tsx -> src/ui/controller.tsx keeping only mainUIController + createMainController; import MainBackgroundUI from ./background - Move MainBackground/MainBackgroundUI/MainBackgroundProps ownership to src/ui/background.tsx; drop ../render import; add DefaultProps (render-vue) + IUIDefaultPropsBase (system) - Fix load.tsx/title.tsx props base: IUIDefaultPropsBase -> IUIPropsBase (own ./types); drop unused system import in title.tsx - Rewrite render capability imports from ../render barrel to ../render/use leaf (avoid render/index.tsx <-> ui cycle) - Complete barrel: + ./controller ./background ./func (7 same-dir exports) - Delete old render/ui/controller.tsx --- .../src/render/ui/controller.tsx | 34 ------------------- .../client-modules/src/ui/background.tsx | 7 ++-- .../client-modules/src/ui/controller.tsx | 8 +++++ packages-user/client-modules/src/ui/index.ts | 3 ++ packages-user/client-modules/src/ui/load.tsx | 6 ++-- packages-user/client-modules/src/ui/title.tsx | 12 +++---- 6 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 packages-user/client-modules/src/render/ui/controller.tsx create mode 100644 packages-user/client-modules/src/ui/controller.tsx diff --git a/packages-user/client-modules/src/render/ui/controller.tsx b/packages-user/client-modules/src/render/ui/controller.tsx deleted file mode 100644 index dcb1ef9..0000000 --- a/packages-user/client-modules/src/render/ui/controller.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { DefaultProps } from '@motajs/render-vue'; -import { - GameUI, - SetupComponentOptions, - IUIDefaultPropsBase, - UIController -} from '@motajs/system'; -import { defineComponent } from 'vue'; -import { MAIN_HEIGHT, MAIN_WIDTH } from '../../shared'; - -export const mainUIController = new UIController('main-ui'); - -export interface MainBackgroundProps - extends DefaultProps, IUIDefaultPropsBase {} - -const mainBackgroundProps = { - props: ['controller', 'instance'] -} satisfies SetupComponentOptions; - -export const MainBackground = defineComponent(() => { - return () => ( - - ); -}, mainBackgroundProps); - -export const MainBackgroundUI = new GameUI('main-background', MainBackground); - -export function createMainController() { - mainUIController.setBackground(MainBackgroundUI, {}); -} diff --git a/packages-user/client-modules/src/ui/background.tsx b/packages-user/client-modules/src/ui/background.tsx index 6691df4..c7defe8 100644 --- a/packages-user/client-modules/src/ui/background.tsx +++ b/packages-user/client-modules/src/ui/background.tsx @@ -1,8 +1,11 @@ -import { GameUI, SetupComponentOptions } from '@motajs/system'; +import { GameUI, SetupComponentOptions, IUIDefaultPropsBase } from '@motajs/system'; +import { DefaultProps } from '@motajs/render-vue'; import { defineComponent } from 'vue'; -import { MainBackgroundProps } from '../render'; import { MAIN_WIDTH, MAIN_HEIGHT } from '../shared'; +export interface MainBackgroundProps + extends DefaultProps, IUIDefaultPropsBase {} + const mainBackgroundProps = { props: ['controller', 'instance'] } satisfies SetupComponentOptions; diff --git a/packages-user/client-modules/src/ui/controller.tsx b/packages-user/client-modules/src/ui/controller.tsx new file mode 100644 index 0000000..cdd8919 --- /dev/null +++ b/packages-user/client-modules/src/ui/controller.tsx @@ -0,0 +1,8 @@ +import { UIController } from '@motajs/system'; +import { MainBackgroundUI } from './background'; + +export const mainUIController = new UIController('main-ui'); + +export function createMainController() { + mainUIController.setBackground(MainBackgroundUI, {}); +} diff --git a/packages-user/client-modules/src/ui/index.ts b/packages-user/client-modules/src/ui/index.ts index cde7421..fab3a94 100644 --- a/packages-user/client-modules/src/ui/index.ts +++ b/packages-user/client-modules/src/ui/index.ts @@ -2,3 +2,6 @@ export * from './types'; export * from './save'; export * from './statistics'; export * from './viewmap'; +export * from './controller'; +export * from './background'; +export * from './func'; diff --git a/packages-user/client-modules/src/ui/load.tsx b/packages-user/client-modules/src/ui/load.tsx index ea3d0e0..d5980c0 100644 --- a/packages-user/client-modules/src/ui/load.tsx +++ b/packages-user/client-modules/src/ui/load.tsx @@ -15,14 +15,14 @@ import { MAIN_WIDTH } from '../shared'; import { ElementLocator, Font, MotaOffscreenCanvas2D } from '@motajs/render'; -import { transitioned } from '../render'; +import { transitioned } from '../render/use'; import { cosh, CurveMode, linear } from '@motajs/animate'; import { clamp } from 'lodash-es'; import { sleep } from '@motajs/common'; import { GameTitleUI } from './title'; -import { IUIDefaultPropsBase } from './types'; +import { IUIPropsBase } from './types'; -export interface ILoadProps extends IUIDefaultPropsBase, DefaultProps {} +export interface ILoadProps extends IUIPropsBase, DefaultProps {} const loadSceneProps = { props: ['controller', 'instance', 'state'] diff --git a/packages-user/client-modules/src/ui/title.tsx b/packages-user/client-modules/src/ui/title.tsx index 0ba5483..1f48279 100644 --- a/packages-user/client-modules/src/ui/title.tsx +++ b/packages-user/client-modules/src/ui/title.tsx @@ -1,9 +1,5 @@ import { DefaultProps } from '@motajs/render-vue'; -import { - GameUI, - SetupComponentOptions, - IUIDefaultPropsBase -} from '@motajs/system'; +import { GameUI, SetupComponentOptions } from '@motajs/system'; import { defineComponent, nextTick, onMounted, ref } from 'vue'; import { BUTTONS_HEIGHT, @@ -27,7 +23,7 @@ import { transitioned, transitionedColor, useKey -} from '../render'; +} from '../render/use'; import { ExitFullscreen, Fullscreen, SoundVolume } from '@user/client-base'; import { mainSetting, triggerFullscreen } from '@motajs/legacy-ui'; import { saveLoad } from './save'; @@ -35,7 +31,7 @@ import { MainSceneUI } from './main'; import { adjustCover } from '@user/client-base'; import { cosh, CurveMode, linear } from '@motajs/animate'; import { sleep } from '@motajs/common'; -import { IUIDefaultPropsBase } from './types'; +import { IUIPropsBase } from './types'; const enum TitleButton { StartGame, @@ -57,7 +53,7 @@ interface ButtonOption { colorTrans: ITransitionedController; } -export interface GameTitleProps extends DefaultProps, IUIDefaultPropsBase {} +export interface GameTitleProps extends DefaultProps, IUIPropsBase {} const gameTitleProps = { props: ['controller', 'instance', 'state']