2022-01-30 13:34:10 +08:00
|
|
|
<template lang="pug">
|
2022-02-07 23:56:33 +08:00
|
|
|
Drawer
|
|
|
|
.thread
|
|
|
|
.header
|
|
|
|
h1.title {{ thread.title }}
|
|
|
|
.info
|
|
|
|
span.user.fas.fa-user-secret {{ thread.user.name }}
|
|
|
|
span.date.far.fa-calendar-alt {{ rwdate(thread.createdAt) }}
|
|
|
|
span.view.far.fa-eye {{ thread.views }}
|
|
|
|
.tags
|
|
|
|
span.tag test
|
|
|
|
span.tag demo
|
|
|
|
.content.circumscription
|
|
|
|
.thread-main(v-html="markdown(thread.data)")
|
|
|
|
button.magic
|
|
|
|
i.fas.fa-magic
|
|
|
|
//button.editor(
|
|
|
|
// v-if="account.online && (account.uid === thread.uid || account.gid === 1)",
|
|
|
|
// @click="edit_mode = !edit_mode"
|
|
|
|
//)
|
|
|
|
// i.fas.fa-magic
|
|
|
|
// | Editor
|
2022-02-24 16:45:45 +08:00
|
|
|
PostList(:data.sync="postlist")
|
2022-02-07 23:56:33 +08:00
|
|
|
.post-create(v-if="account.online")
|
|
|
|
img.avatar(:src="account.avatar")
|
|
|
|
.content
|
|
|
|
textarea(v-model="post.data", rows="12")
|
|
|
|
button.submit(@click="createpost") 发表
|
2022-01-30 13:34:10 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-07 22:27:54 +08:00
|
|
|
import { marked } from "marked";
|
2022-01-30 13:34:10 +08:00
|
|
|
export default {
|
|
|
|
asyncData({ $axios, params }) {
|
|
|
|
return $axios.get(`/api/thread/${params.id}`).then((res) => {
|
|
|
|
return {
|
|
|
|
thread: res.data,
|
|
|
|
postlist: [],
|
|
|
|
post: {
|
|
|
|
data: "",
|
|
|
|
attach: "thread",
|
|
|
|
aid: params.id,
|
|
|
|
},
|
2022-02-07 22:27:54 +08:00
|
|
|
edit_mode: false,
|
2022-01-30 13:34:10 +08:00
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
account() {
|
|
|
|
return this.$store.state.account;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2022-01-30 17:37:25 +08:00
|
|
|
rwdate(utc) {
|
|
|
|
let t = new Date(utc);
|
|
|
|
return t.getMonth() + 1 + "月 " + t.getDate() + ", " + t.getFullYear();
|
|
|
|
},
|
2022-02-07 22:27:54 +08:00
|
|
|
markdown(data) {
|
|
|
|
return marked.parse(data);
|
|
|
|
},
|
2022-01-30 13:34:10 +08:00
|
|
|
loadpostlist() {
|
|
|
|
this.$axios
|
|
|
|
.get(`/api/post?attach=thread&aid=${this.post.aid}`)
|
|
|
|
.then((res) => {
|
|
|
|
this.postlist = res.data;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
createpost() {
|
|
|
|
console.log(this.post);
|
|
|
|
this.$axios.post("/api/post", this.post).then((res) => {
|
2022-02-08 03:37:22 +08:00
|
|
|
if (res.status === 200) {
|
|
|
|
this.postlist.push(res.data);
|
|
|
|
this.post.data = "";
|
|
|
|
}
|
2022-01-30 13:34:10 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadpostlist();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="sass">
|
2022-02-07 22:27:54 +08:00
|
|
|
.thread-main
|
|
|
|
margin: 0 0 4rem 0
|
|
|
|
padding: 2rem
|
2022-01-30 13:34:10 +08:00
|
|
|
.thread
|
|
|
|
>.header
|
|
|
|
height: 240px
|
|
|
|
background-color: rgba(0, 0, 0, .5)
|
|
|
|
margin: 0
|
|
|
|
padding: 4rem
|
|
|
|
text-align: center
|
|
|
|
color: #ffffff
|
|
|
|
span
|
|
|
|
margin: 0 .5rem
|
2022-02-01 07:54:49 +08:00
|
|
|
span::before
|
|
|
|
margin: 0 .5rem
|
2022-01-30 13:34:10 +08:00
|
|
|
>.content
|
|
|
|
background: #ffffff
|
|
|
|
min-height: 800px
|
|
|
|
padding: 1rem 2rem
|
|
|
|
position: relative
|
|
|
|
top: -5rem
|
|
|
|
border-radius: .5rem
|
|
|
|
box-sizing: border-box
|
2022-02-07 22:27:54 +08:00
|
|
|
>.editor
|
|
|
|
position: absolute
|
|
|
|
top: 1rem
|
|
|
|
right: 1rem
|
2022-01-30 13:34:10 +08:00
|
|
|
.post-create
|
|
|
|
display: flex
|
|
|
|
//background: #c8d22d
|
|
|
|
>.avatar
|
|
|
|
width: 48px
|
|
|
|
height: 48px
|
|
|
|
border-radius: 50%
|
|
|
|
background: rgba(0, 0, 0, .5)
|
|
|
|
>.content
|
|
|
|
flex: 1
|
|
|
|
padding-left: 1rem
|
|
|
|
textarea
|
|
|
|
display: block
|
|
|
|
width: 100%
|
|
|
|
max-width: 64rem
|
|
|
|
border: 1px solid #e5e5e5
|
|
|
|
border-radius: .5rem
|
|
|
|
padding: 1rem
|
|
|
|
box-sizing: border-box
|
|
|
|
button
|
|
|
|
border: none
|
|
|
|
border-radius: .25rem
|
|
|
|
padding: .5rem 1rem
|
|
|
|
margin: 1rem 0
|
|
|
|
color: #ffffff
|
|
|
|
background-color: #cc1414
|
|
|
|
font-weight: 600
|
|
|
|
min-width: 6rem
|
2022-01-31 02:34:36 +08:00
|
|
|
cursor: pointer
|
2022-01-30 13:34:10 +08:00
|
|
|
</style>
|