-
Notifications
You must be signed in to change notification settings - Fork 351
refactor: MenuBarの定義を分散 #2596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
refactor: MenuBarの定義を分散 #2596
Changes from 31 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
781f0f2
chore: MenuBarの定義を分散
sevenc-nanashi 2a585ef
chore: エンジンをelectron限定にする
sevenc-nanashi 4bdfe1c
fix: regexp -> regex
sevenc-nanashi 9febf74
update: スナップショットを更新
sevenc-nanashi 3e9fd4d
(スナップショットを更新)
github-actions[bot] b057712
fix: パターンを修正
sevenc-nanashi 8341c18
#2596 の変更提案プルリクエスト (#6)
Hiroshiba f4c987b
chore: storeを引数で渡す
sevenc-nanashi c855472
refactor: 2次元配列にする
sevenc-nanashi 4080f50
merge: upstream/main -> refactor/menu
sevenc-nanashi 6d87525
refactor: 設計を大きく変える
sevenc-nanashi e710b59
chore: disableOnReloadingLocked -> disableWhileReloadingLock
sevenc-nanashi 42a4e7d
test: テストを追加
sevenc-nanashi e5fdb72
fix: 動いてなかったのを修正
sevenc-nanashi 21ed598
test: スナップショットを更新
sevenc-nanashi 05aaedf
(スナップショットを更新)
github-actions[bot] 4c63ae2
revert: 誤爆
sevenc-nanashi 5063d47
chore: MenuBarRoots -> MenuBarCategories
sevenc-nanashi 08f89bc
chore: menuItemIndex -> menuItemStructure
sevenc-nanashi ea9830c
chore: removeNonValue -> removeNullableAndBoolean
sevenc-nanashi 79933cc
style: pnpm run fmt
sevenc-nanashi 2b442e0
merge: upstream/main -> refactor/menu
sevenc-nanashi 9fa76ce
chore: MenuBarCategories -> MenuBarCategory
sevenc-nanashi c5bbd40
chore: 不要なsatisfiesを消す
sevenc-nanashi 6fd9e39
chore: 三項演算子をやめる
sevenc-nanashi 1b47920
Update src/components/Sing/menuBarData.ts
Hiroshiba eda1d65
Merge: main -> refactor/menu
sevenc-nanashi 29dbe9e
style: nr fmt
sevenc-nanashi ffee58c
chore: domain下からcomponents/Menu下に移動
sevenc-nanashi 6da79d6
refactor: ループを回す向きを改善
sevenc-nanashi aed06aa
chore: Menu/menuBarData -> Menu/MenuBar/menuBarData
sevenc-nanashi 984f348
refactor: リファクタ
sevenc-nanashi 434f231
refactor: 関数名を変更
sevenc-nanashi fd8071b
refactor: 引数名を変更
sevenc-nanashi 56beb02
chore: TODOを追加
sevenc-nanashi b335446
refactor: useCommonMenuBarDataを移動
sevenc-nanashi 1a620e8
refactor: 命名をする
sevenc-nanashi 28d4468
chore: TODOを追加
sevenc-nanashi d1e3f9f
chore: コメントを変える
sevenc-nanashi b8d1292
refactor(menu): メニュー項目の結合処理をリファクタリング (#8)
Hiroshiba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { IpcIHData } from "@/type/ipc"; | ||
|
|
||
| export type IpcRendererInvoke = { | ||
| [K in keyof IpcIHData]: ( | ||
| ...args: IpcIHData[K]["args"] | ||
| ) => Promise<IpcIHData[K]["return"]>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import { computed } from "vue"; | ||
| import { useEngineIcons } from "@/composables/useEngineIcons"; | ||
| import { | ||
| MaybeComputedMenuBarContent, | ||
| MenuBarContent, | ||
| } from "@/components/Menu/MenuBar/menuBarData"; | ||
| import { MenuItemData } from "@/components/Menu/type"; | ||
| import { Store } from "@/store"; | ||
| import { removeNullableAndBoolean } from "@/helpers/arrayHelper"; | ||
|
|
||
| export const useElectronMenuBarData = ( | ||
| store: Store, | ||
| ): MaybeComputedMenuBarContent => { | ||
| const engineIds = computed(() => store.state.engineIds); | ||
| const engineInfos = computed(() => store.state.engineInfos); | ||
| const engineManifests = computed(() => store.state.engineManifests); | ||
| const engineIcons = useEngineIcons(engineManifests); | ||
| const enableMultiEngine = computed(() => store.state.enableMultiEngine); | ||
|
|
||
| // 「エンジン」メニューのエンジン毎の項目 | ||
| const engineSubMenuData = computed<MenuBarContent["engine"]>(() => { | ||
| let singleEngineSubMenuData: MenuItemData[]; | ||
| if (Object.values(engineInfos.value).length === 1) { | ||
| singleEngineSubMenuData = [ | ||
| { | ||
| type: "button", | ||
| label: "再起動", | ||
| onClick: () => { | ||
| void store.actions.RESTART_ENGINES({ | ||
| engineIds: [engineIds.value[0]], | ||
| }); | ||
| }, | ||
| disableWhenUiLocked: false, | ||
| }, | ||
| ]; | ||
| } else { | ||
| singleEngineSubMenuData = store.getters.GET_SORTED_ENGINE_INFOS.map( | ||
| (engineInfo): MenuItemData => ({ | ||
| type: "root", | ||
| label: engineInfo.name, | ||
| icon: | ||
| engineManifests.value[engineInfo.uuid] && | ||
| engineIcons.value[engineInfo.uuid], | ||
| disableWhenUiLocked: false, | ||
| subMenu: removeNullableAndBoolean([ | ||
| engineInfo.path != "" && { | ||
| type: "button", | ||
| label: "フォルダを開く", | ||
| onClick: () => { | ||
| void store.actions.OPEN_ENGINE_DIRECTORY({ | ||
| engineId: engineInfo.uuid, | ||
| }); | ||
| }, | ||
| disableWhenUiLocked: false, | ||
| }, | ||
| { | ||
| type: "button", | ||
| label: "再起動", | ||
| onClick: () => { | ||
| void store.actions.RESTART_ENGINES({ | ||
| engineIds: [engineInfo.uuid], | ||
| }); | ||
| }, | ||
| disableWhenUiLocked: false, | ||
| }, | ||
| ]), | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| const allEnginesSubMenuData = enableMultiEngine.value | ||
| ? removeNullableAndBoolean<MenuItemData>([ | ||
| { | ||
| type: "button", | ||
| label: "全てのエンジンを再起動", | ||
| onClick: () => { | ||
| void store.actions.RESTART_ENGINES({ | ||
| engineIds: engineIds.value, | ||
| }); | ||
| }, | ||
| disableWhenUiLocked: false, | ||
| }, | ||
| { | ||
| type: "button", | ||
| label: "エンジンの管理", | ||
| onClick: () => { | ||
| void store.actions.SET_DIALOG_OPEN({ | ||
| isEngineManageDialogOpen: true, | ||
| }); | ||
| }, | ||
| disableWhenUiLocked: false, | ||
| }, | ||
| store.state.isMultiEngineOffMode && { | ||
| type: "button", | ||
| label: "マルチエンジンをオンにして再読み込み", | ||
| onClick() { | ||
| void store.actions.RELOAD_APP({ | ||
| isMultiEngineOffMode: false, | ||
| }); | ||
| }, | ||
| disableWhenUiLocked: false, | ||
| disableWhileReloadingLock: true, | ||
| }, | ||
| ]) | ||
| : []; | ||
|
|
||
| return { | ||
| singleEngine: singleEngineSubMenuData, | ||
| allEngines: allEnginesSubMenuData, | ||
| }; | ||
| }); | ||
|
|
||
| return { | ||
| engine: engineSubMenuData, | ||
| }; | ||
| }; |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このsubMenuData、それぞれ渡さなくてもまとめて渡しちゃえるようになったかも?
まあ別のプルリクエストでさらにファクタリングとかでもよさそう!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これ忘れそうなんでTODO書いておくかissueを作るというメモを何処かに書いても良いかも。
(TODOコメントがあったものがマージされたとき、issueを作るの忘れてませんかと言ってくれるボットみたいながいてくれると便利かも?)