like 与 admin name

This commit is contained in:
satori 2022-02-08 03:37:22 +08:00
parent e8bcfe147e
commit 7db27799c0
9 changed files with 80 additions and 14 deletions

View File

@ -31,6 +31,11 @@
max-width: 1200px max-width: 1200px
margin-left: auto margin-left: auto
margin-right: auto margin-right: auto
//@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 1.5)
// background: #ff1414
// padding: 2rem
// margin: 4rem
// 汇聚 converge // 汇聚 converge
// 控制台 // 控制台

View File

@ -10,6 +10,7 @@
:class="{ show: show, hidden: !show }", :class="{ show: show, hidden: !show }",
@click.stop @click.stop
) )
.containerbox
slot slot
</template> </template>
@ -69,19 +70,28 @@ export default {
background: rgba(0, 0, 0, 0.8) background: rgba(0, 0, 0, 0.8)
.container .container
color: #333333 color: #333333
background: #ffffff
position: absolute position: absolute
left: 0 left: 0
top: 3rem top: 0 //3rem
right: 0 right: 0
bottom: 0 bottom: 0
border-radius: 2rem 2rem 0 0
overflow: auto overflow: auto
scrollbar-width: none scrollbar-width: none
-ms-overflow-style: none -ms-overflow-style: none
//padding: 2rem 4rem //padding: 2rem 4rem
//max-width: 1280px //max-width: 1280px
//margin: 0 auto //margin: 0 auto
@media (max-width: 1280px)
//background: #ff1414
width: 980px
//top: 0
//border-radius: 0 0 0 0
.containerbox
color: #333333
background: #ffffff
border-radius: 2rem 2rem 0 0
overflow: hidden
margin-top: 3rem
.container::-webkit-scrollbar .container::-webkit-scrollbar
display: none // Chrome Safari display: none // Chrome Safari

View File

@ -5,10 +5,14 @@
NuxtLink(:to="`/user/${item.user._id}`") NuxtLink(:to="`/user/${item.user._id}`")
img.avatar(:src="item.user.avatar") img.avatar(:src="item.user.avatar")
.content .content
.title {{ item.user.name }} .name(:class="{ adminname: item.user.gid === 1 }") {{ item.user.name }}
.info .info
span {{ rwdate(item.updatedAt) }} span {{ rwdate(item.updatedAt) }}
div(v-html="markdown(item.data)") div(v-html="markdown(item.data)")
.options
i.fas.fa-eraser(v-if="account.gid === 1 || account.uid === item.uid")
i.fas.fa-marker(v-if="account.gid === 1 || account.uid === item.uid")
i.fas.fa-heart(:class="{ like: item.like }", @click="like(item._id)")
.post-none(v-else) 没有评论~ .post-none(v-else) 没有评论~
</template> </template>
@ -39,18 +43,42 @@
overflow: hidden overflow: hidden
.content .content
padding-left: 1rem padding-left: 1rem
.title .name
font-size: 1.1rem font-size: 1.1rem
font-weight: 600 font-weight: 600
.name.adminname
color: #ff5599
.info .info
span span
margin-right: .5rem margin-right: .5rem
.options
margin-left: auto
i
cursor: pointer
padding: 0
margin: 0 .5rem
color: #888888
//display: none
i:hover
color: #cc1414
i.like
color: #cc1414
//display: inline
//li:hover
// .options
// i
// display: inline
</style> </style>
<script> <script>
import { marked } from "marked"; import { marked } from "marked";
export default { export default {
props: ["data"], props: ["data"],
computed: {
account() {
return this.$store.state.account;
},
},
methods: { methods: {
rwdate(utc) { rwdate(utc) {
let t = new Date(utc); let t = new Date(utc);
@ -59,6 +87,19 @@ export default {
markdown(data) { markdown(data) {
return marked.parse(data); return marked.parse(data);
}, },
like(_id) {
let data = { attach: "post", aid: _id };
console.log(data);
this.$axios.post("/api/like", data).then((res) => {
if (res.status === 200) {
this.data.forEach((item) => {
if (item._id === _id) {
item.like = true;
}
});
}
});
},
}, },
}; };
</script> </script>

View File

@ -38,6 +38,7 @@
background: rgba(0, 0, 0, .05) background: rgba(0, 0, 0, .05)
border-radius: 50% border-radius: 50%
overflow: hidden overflow: hidden
margin-right: .5rem
.content .content
flex: 1 flex: 1
.title .title

View File

@ -53,6 +53,7 @@ export default {
"padding:4px;border:1px solid #e9546b;" "padding:4px;border:1px solid #e9546b;"
); );
this.$store.dispatch("account/profile"); this.$store.dispatch("account/profile");
console.log(window.devicePixelRatio);
}, },
}; };
</script> </script>

View File

@ -1,3 +1,4 @@
<template lang="pug"> <template lang="pug">
.thread-wwwwwww
Nuxt Nuxt
</template> </template>

View File

@ -68,7 +68,10 @@ export default {
createpost() { createpost() {
console.log(this.post); console.log(this.post);
this.$axios.post("/api/post", this.post).then((res) => { this.$axios.post("/api/post", this.post).then((res) => {
console.log(res.data); if (res.status === 200) {
this.postlist.push(res.data);
this.post.data = "";
}
}); });
}, },
}, },

View File

@ -9,9 +9,7 @@
.tags .tags
span.tag test span.tag test
span.tag demo span.tag demo
.content.main-width .content.circumscription
p {{ thread.data }}
.content.main-width
input.title(v-model="thread.title") input.title(v-model="thread.title")
textarea.data(v-model="thread.data", rows="32") textarea.data(v-model="thread.data", rows="32")
button.submit(@click="submit") 发表 button.submit(@click="submit") 发表
@ -31,6 +29,9 @@ export default {
return console.log("尚无内容"); return console.log("尚无内容");
} }
this.$axios.post("/api/thread", this.thread).then((res) => { this.$axios.post("/api/thread", this.thread).then((res) => {
if (res.status === 200) {
return this.$router.push("/");
}
console.log(res.data); console.log(res.data);
}); });
}, },

3
pages/thread/index.vue Normal file
View File

@ -0,0 +1,3 @@
<template lang="pug">
.thread-index
</template>