diff --git a/src/components/editor/aside/graph/AsideGraph.vue b/src/components/editor/aside/graph/AsideGraph.vue index e5817660b..c122f477a 100644 --- a/src/components/editor/aside/graph/AsideGraph.vue +++ b/src/components/editor/aside/graph/AsideGraph.vue @@ -7,8 +7,8 @@
diff --git a/src/components/editor/main/EditorBaseHeader.vue b/src/components/editor/main/EditorBaseHeader.vue index 957087f89..88058c04a 100644 --- a/src/components/editor/main/EditorBaseHeader.vue +++ b/src/components/editor/main/EditorBaseHeader.vue @@ -33,10 +33,36 @@ /> - +
+ + + + + + + + + + + - + import { usePage } from '@/use/page' import { useStore } from 'vuex' + import { useEvent } from '@/use/event' const store = useStore() - const onFinder = () => { + const onFinder = (e: MouseEvent) => { + useEvent().stopAll(e) + store.commit( 'absolute/switchShortcutFinder', !store.state.absolute.shortcuts.finder ) } - const onSwitcher = () => { + const onSwitcher = (e: MouseEvent) => { + useEvent().stopAll(e) + store.commit( 'absolute/switchShortcutSwitcher', !store.state.absolute.shortcuts.switcher ) } + + const onUpPage = (e: MouseEvent) => { + useEvent().stopAll(e) + + store.commit('project/switchPage', { + page: store.state.context, + direction: 'up', + }) + } + + const onDownPage = (e: MouseEvent) => { + useEvent().stopAll(e) + + store.commit('project/switchPage', { + page: store.state.context, + direction: 'down', + }) + } diff --git a/src/store/module/project.ts b/src/store/module/project.ts index 6be269025..0aba3f0bd 100644 --- a/src/store/module/project.ts +++ b/src/store/module/project.ts @@ -108,6 +108,34 @@ export default { state.pages.splice(index, 1, page) }, + switchPage(state: ProjectState, obj: Record) { + const page = state.pages.filter( + (page: ContextState) => obj.page.id === page.id + )[0] + + if (!page) return + + const index = state.pages.indexOf(page) + + if (index === -1) return + + let sIndex + obj.direction === 'up' ? (sIndex = index - 1) : (sIndex = index + 1) + + console.log(sIndex) + + if ( + (sIndex < 0 && obj.direction === 'up') || + (sIndex >= state.pages.length && obj.direction === 'down') + ) + return + + const target = state.pages[sIndex] + + const temp = state.pages[index] + state.pages[index] = target + state.pages[sIndex] = temp + }, }, actions: {}, getters: {}, diff --git a/src/use/event.ts b/src/use/event.ts new file mode 100644 index 000000000..c406214f7 --- /dev/null +++ b/src/use/event.ts @@ -0,0 +1,8 @@ +export const useEvent = () => { + const stopAll = async (e: MouseEvent) => { + e.preventDefault() + e.stopPropagation() + } + + return { stopAll } +}