From 53f36433d7b22c5f0d124dcfcfd304b54a7e584e Mon Sep 17 00:00:00 2001 From: satori Date: Thu, 24 Feb 2022 16:45:45 +0800 Subject: [PATCH] DEBUG --- components/Model/BoxNone.vue | 65 ++++++++++++++++++++++++++++++++++++ components/PostList.vue | 41 ++++++++++++++++++++--- layouts/default.vue | 22 ++++++------ pages/account/index.vue | 11 +++++- pages/thread.vue | 32 +++++++++++++++++- pages/thread/_id.vue | 2 +- pages/thread/index.vue | 2 +- pages/user/_id.vue | 18 ++++++++-- 8 files changed, 170 insertions(+), 23 deletions(-) create mode 100644 components/Model/BoxNone.vue diff --git a/components/Model/BoxNone.vue b/components/Model/BoxNone.vue new file mode 100644 index 0000000..f421068 --- /dev/null +++ b/components/Model/BoxNone.vue @@ -0,0 +1,65 @@ + + + diff --git a/components/PostList.vue b/components/PostList.vue index 34ff125..f16b259 100644 --- a/components/PostList.vue +++ b/components/PostList.vue @@ -10,9 +10,18 @@ span {{ rwdate(item.updatedAt) }} 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)") + i.fas.fa-eraser( + v-if="account.gid === 1 || account.uid === item.uid", + @click="remove(item._id)" + ) + i.fas.fa-marker( + v-if="account.gid === 1 || account.uid === item.uid", + @click="remove(item._id)" + ) + i.fas.fa-heart( + :class="{ like: item.like }", + @click="like(item._id, item.like)" + ) .post-none(v-else) 没有评论~ @@ -87,9 +96,21 @@ export default { markdown(data) { return marked.parse(data); }, - like(_id) { + like(_id, en) { + if (en) { + return this.$axios + .delete("/api/like?attach=post&aid=" + _id) + .then((res) => { + if (res.status === 200) { + this.data.forEach((item) => { + if (item._id === _id) { + item.like = false; + } + }); + } + }); + } 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) => { @@ -100,6 +121,16 @@ export default { } }); }, + remove(_id) { + this.$axios.delete("/api/post/" + _id).then((res) => { + if (res.status === 200) { + this.$emit( + "update:data", + this.data.filter((item) => item._id !== _id) + ); + } + }); + }, }, }; diff --git a/layouts/default.vue b/layouts/default.vue index 82df552..1b83fd4 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -4,7 +4,7 @@ .circumscription .logo Kana nav.navbar - NuxtLink.navbar-item(to="/") 论坛 + NuxtLink.navbar-item(:to="{ path: '/' }") 论坛 NuxtLink.navbar-item(to="/docs") 文档 NuxtLink.navbar-item(to="/chat") 聊天室 //NuxtLink.navbar-item(to="/admin") admin @@ -114,14 +114,14 @@ footer.footer .github font-size: 2rem -.admin - position: relative -.admin::before - position: absolute - top: 0 - right: 0 - content: '演示' - width: 4rem - height: 2rem - background: #ff1414 +//.admin +// position: relative +//.admin::before +// position: absolute +// top: 0 +// right: 0 +// content: '演示' +// width: 4rem +// height: 2rem +// background: #ff1414 diff --git a/pages/account/index.vue b/pages/account/index.vue index 3b67c58..f10322f 100644 --- a/pages/account/index.vue +++ b/pages/account/index.vue @@ -7,6 +7,7 @@ .name {{ account.name }} input#img_add(type="file", accept="image/*", @change="upload($event)") // multiple="multiple", + input#bg(type="file", accept="image/*", @change="upload_bg($event)") .content.main-width p account NuxtLink.button(to="/account/setting") 账户设置 @@ -23,7 +24,15 @@ export default { upload(event) { let data = new FormData(); let option = { headers: { "Content-Type": "multipart/form-data" } }; - data.append("img", event.target.files[0]); + data.append("avatar", event.target.files[0]); + this.$axios.post("/api/account", data, option).then((res) => { + console.log(res.data); + }); + }, + upload_bg(event) { + let data = new FormData(); + let option = { headers: { "Content-Type": "multipart/form-data" } }; + data.append("background", event.target.files[0]); this.$axios.post("/api/account", data, option).then((res) => { console.log(res.data); }); diff --git a/pages/thread.vue b/pages/thread.vue index 02e2bb0..afe9b5d 100644 --- a/pages/thread.vue +++ b/pages/thread.vue @@ -1,4 +1,34 @@ + + diff --git a/pages/thread/_id.vue b/pages/thread/_id.vue index 98345f3..2e0b77a 100644 --- a/pages/thread/_id.vue +++ b/pages/thread/_id.vue @@ -20,7 +20,7 @@ Drawer //) // i.fas.fa-magic // | Editor - PostList(:data="postlist") + PostList(:data.sync="postlist") .post-create(v-if="account.online") img.avatar(:src="account.avatar") .content diff --git a/pages/thread/index.vue b/pages/thread/index.vue index af1f059..cbf8891 100644 --- a/pages/thread/index.vue +++ b/pages/thread/index.vue @@ -1,3 +1,3 @@ \ No newline at end of file + diff --git a/pages/user/_id.vue b/pages/user/_id.vue index aaba2db..f3d4777 100644 --- a/pages/user/_id.vue +++ b/pages/user/_id.vue @@ -4,10 +4,12 @@ img.avatar(:src="user.avatar") h1 span.name {{ user.name }} - span.admin(v-if="user.gid === 1") Admin + span.admin(v-if="user.gid === 1") + i.fas.fa-user-shield .content - p USER - p {{ user }} + ModelBoxNone + p 没有公开的资源.. + //p {{ user }}