forked from ishareme/vue3-front-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(menu): add pc menu and mobile menu
- Loading branch information
Showing
14 changed files
with
513 additions
and
129 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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,78 @@ | ||
<template> | ||
<div> | ||
<teleport to="body"> | ||
<transition name="fade" mode=""> | ||
<div | ||
v-show="isVisable" | ||
class="w-screen h-screen bg-zinc-900/80 z-40 fixed top-0 left-0" | ||
@click="onMaskClick" | ||
> | ||
蒙版 | ||
</div> | ||
</transition> | ||
|
||
<transition name="popup-down-up"> | ||
<div | ||
v-show="isVisable" | ||
v-bind="$attrs" | ||
class="w-screen bg-white z-50 fixed bottom-0 left-0" | ||
> | ||
<slot></slot> | ||
</div> | ||
</transition> | ||
</teleport> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { watch } from 'vue'; | ||
import { useScrollLock, useVModel } from '@vueuse/core'; | ||
const props = defineProps({ | ||
modelValue: { | ||
type: Boolean, | ||
required: true, | ||
default: false, | ||
}, | ||
}); | ||
defineEmits(['update:modelValue']); | ||
// 通过 useVModel 获取到响应式数据 isVisable,当 isVisable 改变时,会自动触发 update:modelValue | ||
const isVisable = useVModel(props); | ||
const onMaskClick = () => { | ||
isVisable.value = false; | ||
}; | ||
//滚动锁定 | ||
const isLocked = useScrollLock(document.body); | ||
watch( | ||
isVisable, | ||
(value) => { | ||
isLocked.value = value; | ||
}, | ||
{ | ||
immediate: true, | ||
} | ||
); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.fade-enter-active, | ||
.fade-leave-active { | ||
transition: all 0.3s; | ||
} | ||
.fade-enter-from, | ||
.fade-leave-to { | ||
opacity: 0; | ||
} | ||
.popup-down-up-enter-active, | ||
.popup-down-up-leave-active { | ||
transition: all 0.3s; | ||
} | ||
.popup-down-up-enter-from, | ||
.popup-down-up-leave-to { | ||
transform: translateY(100%); | ||
} | ||
</style> |
This file contains 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 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 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,3 @@ | ||
export default { | ||
categorys: (state) => state.category.categorys, | ||
}; |
This file contains 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,22 @@ | ||
import { createStore } from 'vuex'; | ||
import getters from './getters'; | ||
import category from './modules/category'; | ||
// 强制缓存 | ||
import createPersistedstate from 'vuex-persistedstate'; | ||
|
||
const store = createStore({ | ||
modules: { | ||
category, | ||
}, | ||
getters, | ||
plugins: [ | ||
createPersistedstate({ | ||
// 指定保存的 localstorage 中的key | ||
key: 'APP_KEYS', | ||
// 需要保存的模块 | ||
paths: ['category'], | ||
}), | ||
], | ||
}); | ||
|
||
export default store; |
Oops, something went wrong.