Skip to content

Commit

Permalink
更新:优化评论
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Mar 28, 2022
1 parent 0ef0930 commit 98957eb
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 43 deletions.
1 change: 1 addition & 0 deletions app/Plugins/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class Comment
{
public function handler(){
$this->helpers();
$this->setting();
}

Expand Down
29 changes: 13 additions & 16 deletions app/Plugins/Comment/resources/assets/js/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3490,16 +3490,14 @@ if (document.getElementById("topic-comment-model")) {
} else {
_this.vditor.clearCache();

data.result.forEach(function (value) {
izitoast__WEBPACK_IMPORTED_MODULE_2___default().success({
title: "Success",
message: value,
position: "topRight",
timeout: 1000
});
izitoast__WEBPACK_IMPORTED_MODULE_2___default().success({
title: "Success",
message: data.result.msg,
position: "topRight",
timeout: 1000
});
setTimeout(function () {
location.reload();
location.href = data.result.url;
}, 1000);
}
})["catch"](function (e) {
Expand Down Expand Up @@ -3727,16 +3725,15 @@ $(function () {
});
});
} else {
data.result.forEach(function (value) {
izitoast__WEBPACK_IMPORTED_MODULE_2___default().success({
title: "Success",
message: value,
position: "topRight"
});
izitoast__WEBPACK_IMPORTED_MODULE_2___default().success({
title: "Success",
message: data.result.msg,
position: "topRight",
timeout: 1000
});
setTimeout(function () {
location.reload();
}, 1500);
location.href = data.result.url;
}, 1000);
}
})["catch"](function (e) {
console.error(e);
Expand Down
33 changes: 15 additions & 18 deletions app/Plugins/Comment/resources/package/js/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,14 @@ if(document.getElementById("topic-comment-model")){
})
}else{
this.vditor.clearCache()
data.result.forEach(function(value){
iziToast.success({
title:"Success",
message:value,
position:"topRight",
timeout:1000
})
iziToast.success({
title:"Success",
message:data.result.msg,
position:"topRight",
timeout:1000
})
setTimeout(function(){
location.reload()
setTimeout(()=>{
location.href=data.result.url;
},1000);
}
}).catch(e=>{
Expand Down Expand Up @@ -379,16 +377,15 @@ $(function(){
})
})
}else{
data.result.forEach(function(value){
iziToast.success({
title:"Success",
message:value,
position:"topRight"
})
iziToast.success({
title:"Success",
message:data.result.msg,
position:"topRight",
timeout:1000
})
setTimeout(function(){
location.reload()
},1500)
setTimeout(()=>{
location.href=data.result.url;
},1000);
}
}).catch(e=>{
console.error(e)
Expand Down
14 changes: 14 additions & 0 deletions app/Plugins/Comment/resources/views/Widget/show-topic.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class="cursor-pointer text-muted hvr-icon-up" data-bs-toggle="tooltip" data-bs-p
</svg>
</a>


{{-- 删除评论--}}
@if(auth()->check())

Expand Down Expand Up @@ -154,6 +155,19 @@ class="cursor-pointer text-muted hvr-icon-pulse" data-bs-toggle="tooltip" data-b
</svg>
</a>
@endif
{{-- 引用评论--}}
<a style="text-decoration:none;" comment-click="quote-comment" comment-id="{{ $value->id }}"
class="cursor-pointer text-muted hvr-icon-up" data-bs-toggle="tooltip" data-bs-placement="bottom" title="引用">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-blockquote" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M6 15h15"></path>
<path d="M21 19h-15"></path>
<path d="M15 11h6"></path>
<path d="M21 7h-6"></path>
<path d="M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"></path>
<path d="M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"></path>
</svg>
</a>
</div>
<div class="col-md-12" comment-dom="comment-{{$value->id}}" comment-status="off">
<div class="hr-text" style="margin-bottom:15px;margin-top:15px;display: none">回复</div>
Expand Down
4 changes: 2 additions & 2 deletions app/Plugins/Comment/src/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function topic_create(TopicCreate $request){
}
cache()->set("comment_create_time_" . auth()->id(), time()+get_options("comment_create_time", 60),get_options("comment_create_time", 60));

return Json_Api(200,true,['发表成功!']);
return Json_Api(200,true,['msg'=>'发表成功!','url' => "/".$data->topic_id.".html/".$data->id."?page=".get_topic_comment_page($data->id)]);
}

// 回复评论
Expand Down Expand Up @@ -102,7 +102,7 @@ public function topic_reply_create(TopicReply $request): bool|array
}
cache()->set("comment_create_time_" . auth()->id(), time()+get_options("comment_create_time", 60),get_options("comment_create_time", 60));

return Json_Api(200,true,['回复成功!']);
return Json_Api(200,true,['msg'=>'回复成功!','url' => "/".$data->topic_id.".html/".$data->id."?page=".get_topic_comment_page($data->id)]);
}

// 删除帖子评论
Expand Down
4 changes: 2 additions & 2 deletions app/Plugins/Core/resources/views/topic/right.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{{-- 作者信息--}}
<div class="col-md-10">
<div class="col-md-12">
<div class="border-0 card">
<div class="card-body">
<div class="row">
Expand Down Expand Up @@ -32,7 +32,7 @@
</div>

{{-- 标签信息--}}
<div class="col-md-10">
<div class="col-md-12">
<div class="border-0 card">
<div class="card-body">
<div class="row">
Expand Down
14 changes: 13 additions & 1 deletion app/Plugins/Core/resources/views/topic/show/content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,20 @@ class="hvr-icon-pulse cursor-pointer text-muted" data-bs-toggle="tooltip" data-b
<path d="M5 14h14l-4.5 -4.5l4.5 -4.5h-14v16"></path>
</svg>
</a>

@endif
{{-- 引用--}}
<a style="text-decoration:none;" core-click="quote-topic" topic-id="{{ $data->id }}"
class="hvr-icon-bounce cursor-pointer text-muted" data-bs-toggle="tooltip" data-bs-placement="bottom" title="引用">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-blockquote" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M6 15h15"></path>
<path d="M21 19h-15"></path>
<path d="M15 11h6"></path>
<path d="M21 7h-6"></path>
<path d="M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"></path>
<path d="M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"></path>
</svg>
</a>
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions app/Plugins/Core/resources/views/topic/show/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<div class="row row-cards justify-content-center">
<div class="col-md-12">
<div class="row row-cards justify-content-center">
<div class="col-md-7">
<div class="col-md-8">
@include('Core::topic.show.content')
</div>
<div class="col-md-5">
<div class="col-md-4">
<div class="row row-cards rd">
<div class="col-md-12 sticky" style="top: 105px">
@include('Core::topic.show.show-right')
Expand Down
2 changes: 1 addition & 1 deletion app/Plugins/Core/resources/views/user/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
@endif

<div class="form-footer">
<button type="submit" class="btn btn-primary w-100">立即登陆</button>
<button type="submit" class="btn btn-primary w-100">立即注册</button>
</div>
</div>
</form>
Expand Down
201 changes: 201 additions & 0 deletions app/Plugins/Topic/resources/assets/js/core.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions app/Plugins/Topic/resources/package/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios from "axios";
import iziToast from "izitoast";
import Fancybox from "@fancyapps/ui";
import swal from "sweetalert";
import copy from 'copy-to-clipboard';

$(function(){
$('div[core-data="topic"]').each(function(){
Expand Down Expand Up @@ -199,6 +200,7 @@ $(function () {
})

$(function(){
// 收藏帖子
$('a[core-click="star-topic"]').click(function(){
var th = $(this);
var topic_id = th.attr("topic-id");
Expand Down Expand Up @@ -230,6 +232,22 @@ $(function(){
})
})


$(function(){
// 引用帖子
$('a[core-click="quote-topic"]').click(function(){
const topic_id = $(this).attr("topic-id");
const shortCode="[topic="+topic_id+"][/topic]";
copy(shortCode);
iziToast.success({
title:"Success",
message:"已复制短代码!",
position:"topRight"
})
})
})


// 举报
$(function(){

Expand All @@ -255,6 +273,18 @@ $(function(){
$("#modal-report-input-title").val("【"+selected+"】"+"举报ID为:"+$(this).attr("comment-id")+"的评论")
})

// 引用评论
$('a[comment-click="quote-comment"]').click(function(){
const comment_id = $(this).attr("comment-id");
const shortCode="[topic-comment="+comment_id+"][/topic-comment]";
copy(shortCode);
iziToast.success({
title:"Success",
message:"已复制短代码!",
position:"topRight"
})
})

// select 变化事件
$("#modal-report-select").change(function(){
var selected=$(this).children('option:selected').val();
Expand Down
3 changes: 2 additions & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
"/js/admin/setting.js": "/js/admin/setting.js?id=f32f5543597519889463",
"/js/admin/index.js": "/js/admin/index.js?id=1b395b17e0695c101c7c",
"/plugins/Core/js/sign.js": "/plugins/Core/js/sign.js?id=8a09b1df2e164d2144ec",
"/plugins/Topic/js/core.js": "/plugins/Topic/js/core.js?id=7f572df83fbd38888e9a",
"/plugins/Core/js/admin.js": "/plugins/Core/js/admin.js?id=2ce2bbdea67c6079872b",
"/plugins/Tribble/js/tag.js": "/plugins/Tribble/js/tag.js?id=f2cbe9525feefaeff9f7",
"/plugins/Topic/js/topic.js": "/plugins/Topic/js/topic.js?id=f6d2525fbbd3006f4e3e",
"/plugins/Blog/js/class.js": "/plugins/Blog/js/class.js?id=f971a10df1dc1339aa62",
"/plugins/Blog/js/article.js": "/plugins/Blog/js/article.js?id=1daa79381ec003ca4dc4",
"/plugins/Comment/js/topic.js": "/plugins/Comment/js/topic.js?id=c82cddcfab27e8601430",
"/plugins/Comment/js/topic.js": "/plugins/Comment/js/topic.js?id=abf58f47af79dcec6886",
"/plugins/Comment/js/edit.js": "/plugins/Comment/js/edit.js?id=95746a28508676b90ceb",
"/plugins/Core/js/app.js": "/plugins/Core/js/app.js?id=6a858d8a3451ec36dd55",
"/plugins/Blog/css/article.css": "/plugins/Blog/css/article.css?id=81ca2c94c21f606d141a",
Expand Down

0 comments on commit 98957eb

Please sign in to comment.