2022-02-05 12:52:28 +08:00
|
|
|
<template lang="pug">
|
|
|
|
.docs-index
|
2022-02-05 16:36:14 +08:00
|
|
|
.ceremony
|
|
|
|
.circumscription
|
|
|
|
.docs
|
|
|
|
.outline
|
|
|
|
ul
|
2022-02-06 13:11:45 +08:00
|
|
|
li
|
|
|
|
NuxtLink(to="/docs") かな
|
2022-02-05 16:36:14 +08:00
|
|
|
li(v-for="item in list", :key="item._id")
|
|
|
|
NuxtLink(:to="`/docs/${item._id}`") {{ item.name }}
|
|
|
|
i.fas.fa-sort-numeric-up-alt(
|
|
|
|
@click="settop(item, true)",
|
|
|
|
v-if="account.gid"
|
|
|
|
) {{ item.top || 0 }}
|
|
|
|
.create-doc(v-if="account.gid")
|
|
|
|
button(@click="submit()") Create
|
|
|
|
.content
|
|
|
|
Nuxt
|
2022-02-05 12:52:28 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
asyncData({ $axios }) {
|
|
|
|
return $axios.get("/api/docs").then((res) => {
|
|
|
|
return {
|
|
|
|
list: res.data,
|
|
|
|
doc: { name: "未命名文档", data: "输入内容" },
|
|
|
|
createin: false,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
2022-02-05 16:08:54 +08:00
|
|
|
computed: {
|
|
|
|
account() {
|
|
|
|
return this.$store.state.account;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.listsort();
|
|
|
|
},
|
2022-02-05 12:52:28 +08:00
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.$axios.post("/api/docs", this.doc).then((res) => {
|
2022-02-05 16:08:54 +08:00
|
|
|
if (res.status === 200) {
|
|
|
|
this.list.push(res.data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
settop(item, n) {
|
|
|
|
item.top = item.top || 0;
|
|
|
|
item.top = n ? item.top + 1 : item.top - 1;
|
|
|
|
let data = { top: item.top };
|
|
|
|
this.$axios.patch(`/api/docs/${item._id}`, data).then((res) => {
|
|
|
|
if (res.status === 200) this.listsort();
|
2022-02-05 12:52:28 +08:00
|
|
|
console.log(res.data);
|
|
|
|
});
|
|
|
|
},
|
2022-02-05 16:08:54 +08:00
|
|
|
listsort() {
|
|
|
|
this.list.sort((x, y) => {
|
|
|
|
x.top = x.top || 0;
|
|
|
|
y.top = y.top || 0;
|
|
|
|
return y.top - x.top;
|
|
|
|
});
|
|
|
|
},
|
2022-02-05 12:52:28 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="sass">
|
|
|
|
.docs-index
|
|
|
|
.docs
|
|
|
|
display: flex
|
|
|
|
width: 100%
|
|
|
|
.outline
|
|
|
|
width: 12rem
|
|
|
|
padding: 2rem
|
2022-02-05 16:36:14 +08:00
|
|
|
//background: #ccefef
|
2022-02-05 12:52:28 +08:00
|
|
|
.content
|
|
|
|
padding: 2rem
|
|
|
|
flex: 1
|
2022-02-05 16:36:14 +08:00
|
|
|
//background: #ffefef
|
2022-02-05 12:52:28 +08:00
|
|
|
|
|
|
|
input.title, textarea.data
|
|
|
|
width: 100%
|
|
|
|
background: none
|
|
|
|
border: none
|
|
|
|
padding: 1rem 2rem
|
|
|
|
box-sizing: border-box
|
|
|
|
font-size: 1rem
|
|
|
|
input.title
|
|
|
|
font-size: 1.5rem
|
|
|
|
</style>
|