Browse Source

master

master
邓宏 3 years ago
parent
commit
5d9b7d3133
  1. 2
      src/layout/components/appMain.vue
  2. 13
      src/layout/components/sidebar/sidebarItem.vue
  3. 12
      src/store/modules/data.js
  4. 13
      src/views/About.vue
  5. 14
      src/views/Home.vue

2
src/layout/components/appMain.vue

@ -15,7 +15,7 @@ export default defineComponent({
name:"appMain",
setup() {
var _data={
cacheViews:[]
cacheViews:['home','about']
}
return _data;

13
src/layout/components/sidebar/sidebarItem.vue

@ -21,7 +21,7 @@
</template>
</template>
<script>
import { defineComponent, shallowRef } from 'vue'
import { defineComponent, inject, onMounted, shallowRef } from 'vue'
import path from "path"
import item from './item.vue'
@ -39,6 +39,8 @@ export default defineComponent({
},
},
setup(props,ctx) {
var {commit}=inject('store')
var _data={
onlyOneChild:shallowRef({}),
hasOneShowingChild(children=[],parent){
@ -62,6 +64,15 @@ export default defineComponent({
},
}
onMounted(async ()=>{
commit('data/setMenu',{
key:props.basePath,
item:{
name:(await props.item?.component?.())?.default.name,
parentPath:props.item?.meta?.parentPath,
}
})
})
return _data;
},
})

12
src/store/modules/data.js

@ -0,0 +1,12 @@
export default {
namespaced: true,
state:{
menu:{},
},
mutations:{
setMenu(state,val){
state.menu[val.key]=val.item
},
},
actions:{}
}

13
src/views/About.vue

@ -3,3 +3,16 @@
<h1>This is an about page</h1>
</div>
</template>
<script>
import { defineComponent } from 'vue'
export default defineComponent({
name:"about",
created(){
console.log('-----------about--------created----------')
},
setup() {
console.log("-------about----------------------------")
},
})
</script>

14
src/views/Home.vue

@ -6,8 +6,16 @@
</template>
<script>
import { defineComponent } from 'vue'
export default {
name: 'Home',
}
export default defineComponent({
name:"home",
created(){
console.log('-----------home--------created----------')
},
setup() {
console.log("---------home------------------------")
},
})
</script>

Loading…
Cancel
Save