Browse Source

添加请求头,侧边目录点击

zq-newmaster
zq 1 month ago
parent
commit
4469cbb5d6
  1. 40
      src/components/SetLeftMenu.vue
  2. 6
      src/utils/request.js

40
src/components/SetLeftMenu.vue

@ -3,22 +3,22 @@
<ul> <ul>
<li v-for="(item, index) in menuList" :key="item.path"> <li v-for="(item, index) in menuList" :key="item.path">
<div :class="[$route.path == item.path ? 'active' : '', 'flex', $route.path == item.path ? curIndex = index : '']" <div :class="[$route.path == item.path ? 'active' : '', 'flex', $route.path == item.path ? curIndex = index : '']"
@click="gotoPath(item.path)"> @click="gotoPath(item.path,index)">
<img v-if="$route.path == item.path" :src="item.imgActive" alt=""> <img v-if="$route.path == item.path" :src="item.imgActive" alt="">
<img v-else :src="item.img" alt=""> <img v-else :src="item.img" alt="">
{{ item.name }} {{ item.name }}
</div> </div>
<p :class="[$route.path != item.path ? 'not-point' : '', 'flex', activeFloor == item1.desc ? 'curActive' : '']" <p :class="['flex', activeFloor == item1.desc ? 'curActive' : '']"
v-for="(item1) in item.list" @click="setActiveCur(item1.desc)" :key="item1.name">{{ item1.name }}</p> v-for="(item1) in item.list" @click="setActiveCur(item1.desc,item)" :key="item1.name">{{ item1.name }}</p>
</li> </li>
</ul> </ul>
</aside> </aside>
</template> </template>
<script> <script>
// import {setHighActive} from '@/utils/common'; // :class="[$route.path != item.path ? 'not-point' : '', 'flex', activeFloor == item1.desc ? 'curActive' : '']"
import { mapState } from 'vuex';
import store from '../store';
export default { export default {
name: 'Sidebar', name: 'Sidebar',
props: { props: {
@ -32,8 +32,6 @@ export default {
// curIndex:{ // curIndex:{
// type:Number // type:Number
// } // }
}, },
data() { data() {
return { return {
@ -129,7 +127,7 @@ export default {
} }
}, },
mounted() { mounted() {
console.log(this.curIndex,'this.curIndex'); // console.log(this.curIndex,'this.curIndex');
this.activeFloor = this.menuList[this.curIndex]['list'][0]['desc']; this.activeFloor = this.menuList[this.curIndex]['list'][0]['desc'];
this.calculateFloorOffsets(); this.calculateFloorOffsets();
this.$nextTick(() => { this.$nextTick(() => {
@ -140,6 +138,9 @@ export default {
created() { created() {
// console.log(this.$parent.$refs.scrollContainer,'this.$refs.sc--rollContainer--'); // console.log(this.$parent.$refs.scrollContainer,'this.$refs.sc--rollContainer--');
}, },
computed: {
...mapState(['pageTitle']) // VuexshowSidebar
},
beforeDestroy() { beforeDestroy() {
this.$parent.$refs.scrollContainer.removeEventListener('scroll', this.handleScroll); this.$parent.$refs.scrollContainer.removeEventListener('scroll', this.handleScroll);
}, },
@ -168,19 +169,34 @@ export default {
}); });
this.activeFloor = activeFloor; // this.activeFloor = activeFloor; //
}, },
setActiveCur(dom) { setActiveCur(dom,item) {
if(this.$route.path != item.path){
this.$router.push(item.path)
store.commit('SET_PAGETITLE', item.name);
}
setTimeout(()=>{
this.activeFloor = dom; this.activeFloor = dom;
this.setHighActive(dom) this.setHighActive(dom)
},500)
}, },
gotoPath(path) { gotoPath(path,index) {
if(this.$route.path != path){
this.curIndex = index
this.scrollLock = false;
this.handleScroll()
//
const dom = document.getElementById('main-content')
dom.scrollTop = 0
this.$router.push(path) this.$router.push(path)
}
}, },
activeArea(type) { activeArea(type) {
console.log(type); console.log(type);
}, },
setHighActive(dom) { setHighActive(dom) {
this.scrollLock = true this.scrollLock = true;
const ele = document.getElementById(dom) const ele = document.getElementById(dom)
if(!ele)return
ele.classList.add('ceshi') ele.classList.add('ceshi')
ele.scrollIntoView({ behavior: 'smooth', block: 'start' }) ele.scrollIntoView({ behavior: 'smooth', block: 'start' })
setTimeout(() => { setTimeout(() => {

6
src/utils/request.js

@ -74,6 +74,9 @@ const request = (method, url, data = {}, config = {}) => {
method: "get", method: "get",
url, url,
params: data, params: data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
...config, ...config,
}); });
} else { } else {
@ -82,6 +85,9 @@ const request = (method, url, data = {}, config = {}) => {
method: lowerCaseMethod, method: lowerCaseMethod,
url, url,
data, data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
...config, ...config,
}); });
} }

Loading…
Cancel
Save