Browse Source

获取菜单

ZaiZai 2 years ago
parent
commit
1dbe767450
3 changed files with 45 additions and 6 deletions
  1. 43 0
      src/components/btn-auth/index.vue
  2. 2 0
      src/components/index.js
  3. 0 6
      src/store/index.js

+ 43 - 0
src/components/btn-auth/index.vue

@@ -0,0 +1,43 @@
+<template>
+    <div v-if="btn_Info">
+        <slot></slot>
+    </div>
+</template>
+
+<script setup>
+import {ref,watch,onMounted} from "vue";
+import {useAppStore} from "~src/store";
+const useAppState = useAppStore()
+
+//参数
+const props = defineProps({
+    keys: {
+        type: String,
+        default: ''
+    }
+})
+
+//变量
+const btn_Info = ref(false);
+
+//监听
+watch(() => [
+    props.keys,
+], ([keys]) => {
+    getButtonsVal(keys)
+})
+
+//渲染完成
+onMounted(()=> {
+    getButtonsVal(props.keys)
+})
+
+//获取气泡数据
+const getButtonsVal = (value) => {
+    if (value) {
+        btn_Info.value = useAppState.getButtonsVal(value);
+    } else {
+        btn_Info.value = false;
+    }
+}
+</script>

+ 2 - 0
src/components/index.js

@@ -1,10 +1,12 @@
 import HcDropdown from './dropdown/index.vue'
 import HcGradientCard from './gradient-card/index.vue'
 import FormItemUpload from './upload/FormItemUpload.vue'
+import HcBtnAuth from './btn-auth/index.vue'
 
 //注册全局组件
 export const setupComponents = (App) => {
     App.component('HcDropdown', HcDropdown)
     App.component('HcGradientCard', HcGradientCard)
     App.component('FormItemUpload', FormItemUpload)
+    App.component('HcBtnAuth', HcBtnAuth)
 }

+ 0 - 6
src/store/index.js

@@ -23,7 +23,6 @@ export const useAppStore = defineStore('main', {
         menus: getStoreValue('menus') || [],
         buttons: getStoreValue('buttons') || {},
         //其他配置信息
-        bubble: getStoreValue('bubble') || false,
         isCollapse: getStoreValue('isCollapse') || false, //菜单折叠
         dragModalSortTop: [], //拖拽弹窗排序
         barMenuName: '', //当前菜单名称
@@ -45,7 +44,6 @@ export const useAppStore = defineStore('main', {
         getMenus: state => state.menus,
         getButtons: state => state.buttons,
         //其他配置信息
-        getBubble: state => state.bubble,
         getCollapse: state => state.isCollapse,
         getDragModalSortTop: state => state.dragModalSortTop,
     },
@@ -104,10 +102,6 @@ export const useAppStore = defineStore('main', {
             return this.buttons[value] || false;
         },
         //其他配置信息
-        setBubble(value) {
-            this.bubble = value
-            setStoreValue('bubble', value)
-        },
         setCollapse(value) { //菜单折叠
             this.isCollapse = value
             setStoreValue('isCollapse', value)