xinsi_book/src/components/Navigation.vue

124 lines
2.7 KiB
Vue
Raw Normal View History

2024-09-12 01:17:30 +00:00
<template>
<div id="nav">
<div>
2024-09-13 05:22:40 +00:00
<a :href="backUrl">返回首页</a>
2024-09-12 01:17:30 +00:00
</div>
<!-- <router-link to="/book">书籍</router-link> | -->
<h3>{{this.$store.state.textBookData.textBooksName}}</h3>
<div style="display: flex; justify-content: center;align-items: center;">
<!-- <el-button v-if="this.$store.state.showNaotu"
type="primary" icon="el-icon-edit"
@click="showDialog">脑图</el-button> -->
<div v-if="true" style="display: flex; margin-right: 20px; justify-content: center;" @click="showDialog">
<el-button icon="el-icon-edit" >脑图</el-button>
<!-- <el-button type="primary" icon="el-icon-search">搜索</el-button> -->
<!-- <i class="el-icon-edit" style="margin-right: 10px"></i>
<p>脑图</p> -->
</div>
<el-switch v-model="mode"
active-text="专注模式"
@change="changeMode"
>
</el-switch>
</div>
<MindElixirDialog :visible.sync="dialogVisible" :mindData="mindData" @save="save" />
</div>
</template>
<script>
import MindElixirDialog from './MindElixirDialog.vue';
import {eventBus} from '../eventBus'
import {bookApi} from "../service/getData"
import {getStore} from '../utils/mUtils'
export default {
components:{
MindElixirDialog
},
data(){
return {
dialogVisible:false,
mode:false,
bookId:'',
userId:'',
mindData:{},
}
},
2024-09-13 05:22:40 +00:00
computed:{
backUrl(){
return this.$store.state.redirecturl?this.$store.state.redirecturl:"../"
}
},
2024-09-12 01:17:30 +00:00
async mounted() {
this.bookId = this.$route.query.bookId
console.log(this.bookId)
this.userId = getStore("userId")
var res = await bookApi.naotu.info({
"bookId": this.bookId,
"userId": this.userId,
})
console.log(res)
if (res.length>0){
console.log("bbbbbb")
this.$nextTick(()=>{
this.mindData = res[0].content
})
}
console.log("aaaaaa")
},
methods:{
showDialog() {
this.dialogVisible = true;
},
changeMode(e){
eventBus.$emit('changeMode',e)
},
save(data){
console.log(data)
data = {
bookId:this.bookId,
userId:this.userId,
content:data
}
data = JSON.stringify(data)
bookApi.naotu.update({data})
console.log(data)
},
}
}
</script>
<style scoped>
#nav {
padding: 30px;
display: flex;
align-items: center;
justify-content: space-between;
}
#nav a {
font-weight: bold;
color: #2c3e50;
}
#nav a.router-link-exact-active {
color: #42b983;
}
</style>