From ca3e64f3b92e57fc621c657fa3c699b69d49f590 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 22 Mar 2023 22:44:42 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20MenuItem=EC=97=90=20funcCall=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80=ED=9B=84=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/DTO/MenuItem.php | 3 + hwe/sammo/GlobalMenu.php | 5 +- hwe/ts/PageFront.vue | 16 ++++ hwe/ts/components/GlobalMenu.vue | 101 ++++++++++++++--------- hwe/ts/components/GlobalMenuDropdown.vue | 87 +++++++++++++++---- hwe/ts/defs/API/Global.ts | 1 + 6 files changed, 158 insertions(+), 55 deletions(-) diff --git a/hwe/sammo/DTO/MenuItem.php b/hwe/sammo/DTO/MenuItem.php index 1c3f1231..1e13c3c7 100644 --- a/hwe/sammo/DTO/MenuItem.php +++ b/hwe/sammo/DTO/MenuItem.php @@ -12,6 +12,9 @@ class MenuItem extends DTO{ public readonly string $name, public readonly string $url, + #[NullIsUndefined] + public ?string $funcCall = null, + #[NullIsUndefined] public ?string $icon = null, #[NullIsUndefined] diff --git a/hwe/sammo/GlobalMenu.php b/hwe/sammo/GlobalMenu.php index 33087809..049d3fbb 100644 --- a/hwe/sammo/GlobalMenu.php +++ b/hwe/sammo/GlobalMenu.php @@ -3,6 +3,7 @@ namespace sammo; use sammo\DTO\MenuItem; +use sammo\DTO\MenuLine; use sammo\DTO\MenuMulti; use sammo\DTO\MenuSplit; @@ -11,7 +12,7 @@ use sammo\DTO\MenuSplit; class GlobalMenu { /** @var (MenuItem|MenuMulti|MenuSplit)[] */ - const version = 1; + const version = 2; static ?array $menu = null; public static function getMenu(): array{ if(static::$menu !== null){ @@ -23,6 +24,7 @@ class GlobalMenu { new MenuItem('세력일람', 'a_kingdomList.php', newTab: true), new MenuItem('장수일람', 'a_genList.php', newTab: true), new MenuItem('명장일람', 'a_bestGeneral.php', newTab: true), + new MenuLine(), new MenuItem('명예의전당', 'a_hallOfFame.php', newTab: true), new MenuItem('왕조일람', 'a_emperior.php', newTab: true), ]), @@ -32,6 +34,7 @@ class GlobalMenu { [ new MenuItem('건의/제안', '/board/request', newTab: true), new MenuItem('팁/강좌', '/board/tip', newTab: true), + new MenuLine(), new MenuItem('패치 내역', '/board/patch', newTab: true), ] ), diff --git a/hwe/ts/PageFront.vue b/hwe/ts/PageFront.vue index b812e89e..ac933189 100644 --- a/hwe/ts/PageFront.vue +++ b/hwe/ts/PageFront.vue @@ -10,6 +10,7 @@ :globalInfo="globalInfo" :modelValue="globalMenu" variant="sammo-base2" + @reqCall="reqMenuCall" /> { gameConstStore.value = store; }); +const menuCallList: Recordunknown> = { + showVersion:()=>{ + console.log('TODO version 출력'); + }, +} + +function reqMenuCall(key:string){ + if(!(key in menuCallList)){ + console.error(`메뉴 호출 실패: ${key}`); + return; + } + const func = menuCallList[key]; + void func(); +} + const showSecret = computed(() => { if (!frontInfo.value) { return false; diff --git a/hwe/ts/components/GlobalMenu.vue b/hwe/ts/components/GlobalMenu.vue index 73accb02..c83ee3ca 100644 --- a/hwe/ts/components/GlobalMenu.vue +++ b/hwe/ts/components/GlobalMenu.vue @@ -7,54 +7,71 @@ :variant="variant" :href="item.url" :target="item.newTab ? '_blank' : undefined" + @click="menuClick($event, item)" >{{ item.name }} - + diff --git a/hwe/ts/components/GlobalMenuDropdown.vue b/hwe/ts/components/GlobalMenuDropdown.vue index db789f2d..048742c8 100644 --- a/hwe/ts/components/GlobalMenuDropdown.vue +++ b/hwe/ts/components/GlobalMenuDropdown.vue @@ -2,7 +2,12 @@