From 72657692ee51d0c6ec24f01469bb3f3512d7b11b Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 4 Mar 2023 17:10:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20GlobalMenu=20API=20-=20GlobalMenu=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=EC=9A=A9=20DTO(MenuItem,=20MenuMulti,=20Menu?= =?UTF-8?q?Split)=20-=20d=5Fsetting=EC=97=90=20GlobalMenu=EB=A5=BC=20?= =?UTF-8?q?=EC=A7=81=EC=A0=91=20=EC=9E=91=EC=84=B1=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=A0=9C=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/d_setting/GlobalMenu.orig.php | 53 ++++++++++++++++++++++++++ hwe/sammo/API/Global/GetGlobalMenu.php | 47 +++++++++++++++++++++++ hwe/sammo/DTO/MenuItem.php | 26 +++++++++++++ hwe/sammo/DTO/MenuMulti.php | 19 +++++++++ hwe/sammo/DTO/MenuSplit.php | 20 ++++++++++ hwe/sammo/GlobalMenu.php | 53 ++++++++++++++++++++++++++ hwe/ts/SammoAPI.ts | 2 + hwe/ts/defs/API/Global.ts | 26 +++++++++++++ 8 files changed, 246 insertions(+) create mode 100644 hwe/d_setting/GlobalMenu.orig.php create mode 100644 hwe/sammo/API/Global/GetGlobalMenu.php create mode 100644 hwe/sammo/DTO/MenuItem.php create mode 100644 hwe/sammo/DTO/MenuMulti.php create mode 100644 hwe/sammo/DTO/MenuSplit.php create mode 100644 hwe/sammo/GlobalMenu.php diff --git a/hwe/d_setting/GlobalMenu.orig.php b/hwe/d_setting/GlobalMenu.orig.php new file mode 100644 index 00000000..53c203dd --- /dev/null +++ b/hwe/d_setting/GlobalMenu.orig.php @@ -0,0 +1,53 @@ + true, + 'menu' => array_map(function (DTO $dto) { + return $dto->toArray(); + }, GlobalMenu::getMenu()), + ]; + } + public function tryCache(): ?APICacheResult + { + $version = GlobalMenu::version; + return new APICacheResult( + null, + "v{$version}", + 60 * 60 * 6, + true + ); + } +} diff --git a/hwe/sammo/DTO/MenuItem.php b/hwe/sammo/DTO/MenuItem.php new file mode 100644 index 00000000..1c3f1231 --- /dev/null +++ b/hwe/sammo/DTO/MenuItem.php @@ -0,0 +1,26 @@ +type = 'item'; + } +} \ No newline at end of file diff --git a/hwe/sammo/DTO/MenuMulti.php b/hwe/sammo/DTO/MenuMulti.php new file mode 100644 index 00000000..e3275e9a --- /dev/null +++ b/hwe/sammo/DTO/MenuMulti.php @@ -0,0 +1,19 @@ +type = 'multi'; + } +} \ No newline at end of file diff --git a/hwe/sammo/DTO/MenuSplit.php b/hwe/sammo/DTO/MenuSplit.php new file mode 100644 index 00000000..a01df416 --- /dev/null +++ b/hwe/sammo/DTO/MenuSplit.php @@ -0,0 +1,20 @@ +type = 'split'; + } +} \ No newline at end of file diff --git a/hwe/sammo/GlobalMenu.php b/hwe/sammo/GlobalMenu.php new file mode 100644 index 00000000..11c2fa02 --- /dev/null +++ b/hwe/sammo/GlobalMenu.php @@ -0,0 +1,53 @@ +, + GetGlobalMenu: GET as APICallT, }, InheritAction: { BuyHiddenBuff: PUT as APICallT<{ diff --git a/hwe/ts/defs/API/Global.ts b/hwe/ts/defs/API/Global.ts index 4ad0618a..fbc0ff69 100644 --- a/hwe/ts/defs/API/Global.ts +++ b/hwe/ts/defs/API/Global.ts @@ -218,3 +218,29 @@ export type GetFrontInfoResponse = { >; }; }; + +export type MenuItem = { + type: 'item'; + name: string; + url: string; + icon?: string; + newTab?: boolean; + condHightlightVar?: string; + condShowVar?: string; +} + +export type MenuSplit = { + type: 'split'; + main: MenuItem; + subMenu: MenuItem[]; +} + +export type MenuMulti = { + type: 'multi'; + subMenu: MenuItem[]; +} + +export type GetMenuResponse = { + result: true; + menu: (MenuItem | MenuSplit | MenuMulti)[]; +} \ No newline at end of file