Skip to content

Commit

Permalink
perf: 复制宏自动感谢
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaviilee committed Nov 25, 2023
1 parent a312457 commit 709f36b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
"dependencies": {
"@jx3box/jx3box-comment-ui": "^1.7.16",
"@jx3box/jx3box-common": "^8.0.5",
"@jx3box/jx3box-common-ui": "^7.9.10",
"@jx3box/jx3box-data": "^3.5.4",
"@jx3box/jx3box-common": "^8.0.8",
"@jx3box/jx3box-common-ui": "^7.9.11",
"@jx3box/jx3box-data": "^3.5.5",
"@jx3box/jx3box-dict": "^2.2.0",
"@jx3box/jx3box-editor": "^2.0.1",
"@jx3box/jx3box-editor": "^2.0.3",
"@jx3box/jx3box-macro": "^1.0.1",
"@jx3box/jx3box-talent": "^1.2.7",
"@jx3box/jx3box-talent2": "^1.5.7",
Expand Down
49 changes: 48 additions & 1 deletion src/components/macro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
>
<i class="el-icon-video-play"></i> 云端同步刷新
</a>
<el-checkbox v-model="auto_thx" size="mini" class="u-auto-thx" border :true-label="1" :false-label="0" @change="onAuthThxChange">自动感谢</el-checkbox>
</div>
<div class="u-count">
字数:
Expand All @@ -62,6 +63,7 @@ import dict from "@jx3box/jx3box-dict/output/skill.json";
import User from "@jx3box/jx3box-common/js/user";
import { copy } from "@/utils/clipboard";
import { reportNow } from "@jx3box/jx3box-common/js/reporter";
import { POST } from "@jx3box/jx3box-comment-ui/src/service";
export default {
name: "macro",
props: ["ctx", "lang", "name", "id"],
Expand All @@ -74,6 +76,8 @@ export default {
status: true, //默认简体
dict,
isSuperAdmin: User.isSuperAdmin(),
auto_thx: 0,
};
},
watch: {
Expand Down Expand Up @@ -115,6 +119,9 @@ export default {
prefix: function () {
return this.client == "std" ? "www" : "origin";
},
baseAPI() {
return `/api/comment/post/article/${this.id}`
}
},
methods: {
copy: function (text, type="") {
Expand All @@ -124,7 +131,11 @@ export default {
data: {
href: `${this.prefix}:/macro/${this.id}`
}
})
});
if (this.auto_thx) {
this.autoReply();
}
})
},
translate(data) {
Expand Down Expand Up @@ -159,11 +170,41 @@ export default {
run: function () {
this.status = !this.status;
},
onAuthThxChange() {
localStorage.setItem("auto_thx", this.auto_thx);
},
autoReply: function (){
POST(`${this.baseAPI}/comment`, null, {
attachmentList: [],
content: "抱走,谢谢楼主,么么哒#嘴"
}).then((responseJSON) => {
if (responseJSON && ~~responseJSON.code > 0) {
this.$notify({
title: "评论失败",
message: responseJSON.msg || "",
type: "error",
duration: 3000,
position: "bottom-right",
});
return;
}
this.$notify({
title: "",
message: "评论成功!",
type: "success",
duration: 3000,
position: "bottom-right",
});
})
.catch(() => {});
}
},
created: function () {
this.data = this.ctx;
this.code = this.parse(this.ctx);
this.callTranslator();
this.auto_thx = ~~localStorage.getItem("auto_thx") || 0;
},
components: {},
};
Expand All @@ -184,6 +225,12 @@ export default {
color: @color-link;
}
}
.u-macro-panel {
.flex;
}
.u-auto-thx {
margin-left: 10px;
}
}
@media screen and (max-width: @phone) {
.m-macro-inner .u-count {
Expand Down
2 changes: 1 addition & 1 deletion src/layout/SingleLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Header></Header>
<Breadcrumb name="云端宏" slug="macro" root="/macro" :publishEnable="true" :adminEnable="true" :feedbackEnable="true" :crumbEnable="true">
<template #op-prepend>
<AdminDirectMessage :user-id="user_id" :sourceId="String(post.ID)" :sourceType="post.post_type"></AdminDirectMessage>
<AdminDirectMessage v-if="post && post.ID" :user-id="user_id" :sourceId="String(post.ID)" :sourceType="post.post_type"></AdminDirectMessage>
</template>
<template #title>
<span>{{ title }}</span>
Expand Down

0 comments on commit 709f36b

Please sign in to comment.