Skip to content

Commit

Permalink
perf: update homework
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaviilee committed May 28, 2024
1 parent 5463843 commit 0943f7a
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jx3box/jx3box-comment-ui",
"version": "1.9.0",
"version": "1.9.1",
"scripts": {
"dev": "env DEV_SERVER=true vue-cli-service serve",
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Comment id="68185" category="post" order="desc" />
<Comment id="80317" category="post" order="desc" />
<!-- <Comment :id="30015" category="post" order="desc" /> -->
</template>

Expand Down
14 changes: 12 additions & 2 deletions src/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
:user-href="item.userId | profileLink"
:username="item.displayName"
:homework="homework"
:post-type="postType"
@deleteComment="deleteComment"
@setTopComment="setTopComment"
@setStarComment="setStarComment"
Expand Down Expand Up @@ -93,6 +94,7 @@
</el-main>

<homework v-model="showHomeWork" v-if="homework" :postType="postType" :postId="postData.postId" :client="postData.client" :userId="postData.userId"></homework>
<boxcoin-records v-model="showBoxCoin" v-if="homework" :postType="postType" :postId="postData.postId" :client="postData.client"></boxcoin-records>
</el-container>
</template>

Expand All @@ -104,6 +106,7 @@ import CommentAndReply from "./components/comment-and-reply.vue";
import { GET, POST, DELETE, PUT } from "./service";
import { getOrderMode, setOrderMode } from "./options";
import Homework from "@jx3box/jx3box-common-ui/src/interact/Homework.vue";
import boxcoinRecords from "./components/boxcoin-records.vue";
import {bus} from "./utils";
export default {
name: "Comment",
Expand Down Expand Up @@ -137,7 +140,8 @@ export default {
CommentAvatar,
CommentAndReply,
CommentInputForm,
Homework
Homework,
boxcoinRecords
},
data: function () {
return {
Expand All @@ -164,7 +168,8 @@ export default {
postId: 0,
userId: 0,
client: location.href.includes("origin") ? "origin" : "std",
}
},
showBoxCoin: false,
};
},
computed: {
Expand Down Expand Up @@ -340,6 +345,11 @@ export default {
this.postData.userId = data.userId;
this.showHomeWork = true;
})
bus.on("boxcoin-click", data => {
this.postData.postId = data.id;
this.showBoxCoin = true;
})
},
};
</script>
Expand Down
Binary file added src/assets/img/like4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/components/boxcoin-records.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<el-dialog :visible="modelValue" @close="onClose" title="打赏记录" width="1002px">
<boxcoin-records :postType="postType" :postId="postId" :postClient="client" mode="normal"></boxcoin-records>
</el-dialog>
</template>

<script>
import boxcoin_records from '@jx3box/jx3box-common-ui/src/interact/boxcoin_records.vue';
import "@jx3box/jx3box-common-ui/assets/css/thx.less";
export default {
name: "BoxcoinRecords",
components: {
'boxcoin-records': boxcoin_records,
},
props: {
postType: String,
postId: String,
client: String,
modelValue: Boolean,
},
model: {
prop: "modelValue",
event: "update:modelValue"
},
methods: {
onClose() {
this.$emit('update:modelValue', false);
}
}
}
</script>

<style lang="less">
// @import "@jx3box/jx3box-common-ui/assets/css/thx.less";
</style>
60 changes: 58 additions & 2 deletions src/components/comment-and-reply.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
:href="userHref"
>{{ username || "人字榜800线无名小侠" }}</el-link
>
<span class="u-boxcoin" v-if="total" @click="onBoxcoinClick">
<img class="u-boxcoin-img" src="../assets/img/like4.png" alt="">
卷面分:<span class="u-boxcoin-num">{{ total }}</span><i class="el-icon-coin"></i>
</span>
<span class="u-mark u-top" v-if="item.is_top"
><i class="el-icon-download"></i>置顶</span
>
Expand Down Expand Up @@ -60,10 +64,10 @@
<script>
import ContentOfCommentAndReply from "./comment-and-reply-subcomponents-content.vue";
import ReplyList from "./comment-and-reply-subcomponents-reply-list.vue";
import { POST, DELETE, GET } from "../service";
import { POST, DELETE, GET, getHistorySummary } from "../service";
import {bus} from "../utils"
export default {
props: ["item", "baseApi", "power", "user-href", "username", "homework"],
props: ["item", "baseApi", "power", "user-href", "username", "homework", "postType"],
components: {
ContentOfCommentAndReply,
ReplyList
Expand All @@ -76,6 +80,11 @@ export default {
pageSize: 10,
pageTotal: 1,
total: 0
},
summary: {
fromManager: 0,
fromUser: 0
}
};
},
Expand All @@ -90,6 +99,22 @@ export default {
created() {
this.replyList = this.item.reply || [];
},
watch: {
item: {
deep: true,
immediate: true,
handler(val) {
if (val?.id) {
this.loadHomeworkBoxcoin()
}
}
}
},
computed: {
total() {
return this.summary.fromManager + this.summary.fromUser;
}
},
methods: {
deleteComment() {
this.$emit("deleteComment", this.item.id);
Expand Down Expand Up @@ -162,6 +187,15 @@ export default {
},
onHomework() {
bus.emit("homework-click", this.item);
},
onBoxcoinClick() {
bus.emit("boxcoin-click", this.item);
},
loadHomeworkBoxcoin() {
if (!this.homework) return;
getHistorySummary(this.postType, this.item.id).then(res => {
this.summary = res.data.data;
})
}
}
};
Expand Down Expand Up @@ -200,4 +234,26 @@ export default {
background-color:#ff99cc;
}
}
.c-comment-cmt__author {
.pr;
.u-boxcoin {
.pa;
right: 10px;
top: 0;
.fz(14px);
.flex;
align-items: center;
gap: 5px;
.pointer;
}
.u-boxcoin-img {
.size(14px);
}
.u-boxcoin-num{
color: #f0b400;
}
}
</style>
6 changes: 5 additions & 1 deletion src/service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//import { Notification } from 'element-ui';
import { __Links, __next } from "@jx3box/jx3box-common/data/jx3box.json"
import { Notification } from "element-ui"
import { $pay } from "@jx3box/jx3box-common/js/https"


export const GET = function (url, queryParams) {
Expand All @@ -12,7 +13,6 @@ export const GET = function (url, queryParams) {
},
}
return __fetch(url, queryParams, options)

}

var postRecord = {}
Expand Down Expand Up @@ -151,4 +151,8 @@ function __fetch(url, queryParams, options) {
return resp.text()
}
})
}

export const getHistorySummary = (postType, postId) => {
return $pay().get(`/api/inspire/article/${postType}/${postId}/history/summary`)
}
6 changes: 6 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ module.exports = {
request.setHeader("origin", "");
}
},
"/api": {
target: process.env["DEV_SERVER"] == "true" ? "http://localhost:8000" : "https://pay.jx3box.com",
onProxyReq: function (request) {
request.setHeader("origin", "");
}
}
}
},
chainWebpack: config => {
Expand Down

0 comments on commit 0943f7a

Please sign in to comment.