メニュー型定義を分離 (TypeScriptの型支援が効かないので)
This commit is contained in:
		
							parent
							
								
									ed5805e5af
								
							
						
					
					
						commit
						0a788d1df1
					
				
					 5 changed files with 25 additions and 24 deletions
				
			
		|  | @ -9,7 +9,8 @@ | |||
| <script lang="ts" setup> | ||||
| import { onMounted, onBeforeUnmount } from 'vue'; | ||||
| import contains from '@/scripts/contains'; | ||||
| import MkMenu, { MenuItem } from './menu.vue'; | ||||
| import MkMenu from './menu.vue'; | ||||
| import { MenuItem } from './types/menu.vue'; | ||||
| import * as os from '@/os'; | ||||
| 
 | ||||
| const props = defineProps<{ | ||||
|  |  | |||
|  | @ -44,31 +44,11 @@ | |||
| </div> | ||||
| </template> | ||||
| 
 | ||||
| <script lang="ts"> | ||||
| import * as Misskey from 'misskey-js'; | ||||
| import { Ref } from 'vue'; | ||||
| 
 | ||||
| export type MenuAction = (ev: MouseEvent) => void; | ||||
| 
 | ||||
| export type MenuDivider = null; | ||||
| export type MenuNull = undefined; | ||||
| export type MenuLabel = { type: 'label', text: string }; | ||||
| export type MenuLink = { type: 'link', to: string, text: string, icon?: string, indicate?: boolean, avatar: Misskey.entities.User }; | ||||
| export type MenuA = { type: 'a', href: string, target?: string, download?: string, text: string, icon?: string, indicate?: boolean }; | ||||
| export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction }; | ||||
| export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string }; | ||||
| export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar: Misskey.entities.User; action: MenuAction }; | ||||
| 
 | ||||
| export type MenuPending = { type: 'pending' }; | ||||
| 
 | ||||
| type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; | ||||
| export type MenuItem = OuterMenuItem | Promise<OuterMenuItem>; | ||||
| export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; | ||||
| </script> | ||||
| <script lang="ts" setup> | ||||
| import { nextTick, onMounted, watch } from 'vue'; | ||||
| import { focusPrev, focusNext } from '@/scripts/focus'; | ||||
| import FormSwitch from '@/components/form/switch.vue'; | ||||
| import { MenuItem, InnerMenuItem, MenuPending, MenuAction } from '@/types/menu'; | ||||
| 
 | ||||
| const props = defineProps<{ | ||||
| 	items: MenuItem[]; | ||||
|  |  | |||
|  | @ -7,7 +7,8 @@ | |||
| <script lang="ts" setup> | ||||
| import { } from 'vue'; | ||||
| import MkModal from './modal.vue'; | ||||
| import MkMenu, { MenuItem } from './menu.vue'; | ||||
| import MkMenu from './menu.vue'; | ||||
| import { MenuItem } from '@/types/menu'; | ||||
| 
 | ||||
| defineProps<{ | ||||
| 	items: MenuItem[]; | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ import * as Misskey from 'misskey-js'; | |||
| import { apiUrl, url } from '@/config'; | ||||
| import MkPostFormDialog from '@/components/post-form-dialog.vue'; | ||||
| import MkWaitingDialog from '@/components/waiting-dialog.vue'; | ||||
| import { MenuItem } from '@/components/ui/menu.vue'; | ||||
| import { MenuItem } from '@/types/menu'; | ||||
| import { resolve } from '@/router'; | ||||
| import { $i } from '@/account'; | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										19
									
								
								packages/client/src/types/menu.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								packages/client/src/types/menu.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| import * as Misskey from 'misskey-js'; | ||||
| import { Ref } from 'vue'; | ||||
| 
 | ||||
| export type MenuAction = (ev: MouseEvent) => void; | ||||
| 
 | ||||
| export type MenuDivider = null; | ||||
| export type MenuNull = undefined; | ||||
| export type MenuLabel = { type: 'label', text: string }; | ||||
| export type MenuLink = { type: 'link', to: string, text: string, icon?: string, indicate?: boolean, avatar: Misskey.entities.User }; | ||||
| export type MenuA = { type: 'a', href: string, target?: string, download?: string, text: string, icon?: string, indicate?: boolean }; | ||||
| export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction }; | ||||
| export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string }; | ||||
| export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar: Misskey.entities.User; action: MenuAction }; | ||||
| 
 | ||||
| export type MenuPending = { type: 'pending' }; | ||||
| 
 | ||||
| type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; | ||||
| export type MenuItem = OuterMenuItem | Promise<OuterMenuItem>; | ||||
| export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue