From a1a8017ce1f330a28bc4ca5d90ff1edbd5041231 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 26 Sep 2025 20:13:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AD=98=E6=A1=A3=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client-modules/src/render/index.tsx | 4 ++-- .../client-modules/src/render/shared.ts | 7 ++++-- .../client-modules/src/render/ui/save.tsx | 22 ++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages-user/client-modules/src/render/index.tsx b/packages-user/client-modules/src/render/index.tsx index 5d26e15..86153ff 100644 --- a/packages-user/client-modules/src/render/index.tsx +++ b/packages-user/client-modules/src/render/index.tsx @@ -1,6 +1,6 @@ import { createApp, Font } from '@motajs/render'; import { defineComponent } from 'vue'; -import { MAIN_HEIGHT, MAIN_WIDTH } from './shared'; +import { DEFAULT_FONT, MAIN_HEIGHT, MAIN_WIDTH } from './shared'; import { hook, loading } from '@user/data-base'; import { createLoopMap } from './loopMap'; import { createElements } from './elements'; @@ -45,7 +45,7 @@ export function createRender() { sceneController.open(GameTitleUI, {}); }); - Font.setDefaults(new Font('normal', 18)); + Font.setDefaults(DEFAULT_FONT); } export * from './components'; diff --git a/packages-user/client-modules/src/render/shared.ts b/packages-user/client-modules/src/render/shared.ts index cda67b3..e6fe4bc 100644 --- a/packages-user/client-modules/src/render/shared.ts +++ b/packages-user/client-modules/src/render/shared.ts @@ -1,4 +1,5 @@ import { ElementLocator } from '@motajs/render-core'; +import { Font } from '@motajs/render-style'; // 本文件为 UI 配置文件,你可以修改下面的每个常量来控制 UI 的显示参数,每个常量都有注释说明 @@ -60,15 +61,17 @@ export const CENTER_LOC: ElementLocator = [ /** 弹框的宽度,使用在内置 UI 与组件中,包括确认框、选择框、等待框等 */ export const POP_BOX_WIDTH = MAP_WIDTH / 2; +/** 默认字体 */ +export const DEFAULT_FONT = new Font('normal', 18); //#region 存档界面 /** 存档缩略图尺寸 */ -export const SAVE_ITEM_SIZE = 150; +export const SAVE_ITEM_SIZE = MAP_BLOCK_WIDTH * 10; /** 单个存档上方显示第几号存档的高度 */ export const SAVE_ITEM_TOP = 24; /** 单个存档下方显示这个存档信息的高度 */ -export const SAVE_ITEM_DOWN = 16; +export const SAVE_ITEM_DOWN = 24; /** 单个存档高度,包括存档下方的信息 */ export const SAVE_ITEM_HEIGHT = SAVE_ITEM_SIZE + SAVE_ITEM_TOP + SAVE_ITEM_DOWN; /** 存档间距 */ diff --git a/packages-user/client-modules/src/render/ui/save.tsx b/packages-user/client-modules/src/render/ui/save.tsx index 08851b3..e3f6468 100644 --- a/packages-user/client-modules/src/render/ui/save.tsx +++ b/packages-user/client-modules/src/render/ui/save.tsx @@ -69,8 +69,8 @@ const saveBtnProps = { } satisfies SetupComponentOptions; export const SaveItem = defineComponent(props => { - const font = new Font('normal', 18); - const statusFont = new Font('normal', 14); + const font = Font.defaults({ size: 18 }); + const statusFont = Font.defaults({ size: 14 }); const w = computed(() => props.loc[2] ?? 200); const h = computed(() => props.loc[3] ?? 200); @@ -93,6 +93,11 @@ export const SaveItem = defineComponent(props => { return `${hp}/${atk}/${def}`; } }); + const timeText = computed(() => { + if (!props.data) return ''; + const date = new Date(props.data.data.time); + return date.toLocaleString(); + }); const strokeStyle = computed(() => { if (props.selected) return props.inDelete ? 'red' : 'gold'; @@ -115,8 +120,8 @@ export const SaveItem = defineComponent(props => { (props => { text={statusText.value} fillStyle="yellow" font={statusFont} - loc={[w.value / 2, h.value - SAVE_ITEM_DOWN + 2]} + loc={[w.value / 2, h.value - SAVE_ITEM_DOWN]} + anc={[0.5, 0]} + /> +