Skip to content

Commit

Permalink
更新:弃用markdown预览
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Dec 23, 2022
1 parent 05381d5 commit 7b3f388
Show file tree
Hide file tree
Showing 30 changed files with 303 additions and 624 deletions.
6 changes: 2 additions & 4 deletions app/CodeFec/Install.php
Expand Up @@ -205,13 +205,12 @@ public function step_3()
public function step_4()
{
// V2.0 对topic表的更改
$topics = DB::table('topic')->where('post_id', '=', null)->get(['id', 'content', 'markdown', 'user_agent', 'user_ip', 'user_id', 'created_at', 'updated_at']);
$topics = DB::table('topic')->where('post_id', '=', null)->get(['id', 'content', 'user_agent', 'user_ip', 'user_id', 'created_at', 'updated_at']);
foreach ($topics as $data) {
$post = Post::query()->create([
'topic_id' => $data->id,
'user_id' => $data->user_id,
'content' => $data->content,
'markdown' => $data->markdown,
'user_agent' => $data->user_agent,
'user_ip' => $data->user_ip,
'created_at' => $data->created_at,
Expand All @@ -221,13 +220,12 @@ public function step_4()
}

// v2.0对topic_comment表的更改
$comments = Db::table('topic_comment')->where('post_id', '=', null)->get(['id', 'user_id', 'content', 'markdown', 'user_agent', 'user_ip', 'created_at', 'updated_at']);
$comments = Db::table('topic_comment')->where('post_id', '=', null)->get(['id', 'user_id', 'content', 'user_agent', 'user_ip', 'created_at', 'updated_at']);
foreach ($comments as $data) {
$post = Post::query()->create([
'comment_id' => $data->id,
'user_id' => $data->user_id,
'content' => $data->content,
'markdown' => $data->markdown,
'user_agent' => $data->user_agent,
'user_ip' => $data->user_ip,
'created_at' => $data->created_at,
Expand Down
16 changes: 0 additions & 16 deletions app/Plugins/Comment/resources/views/ShortCode/comment.blade.php
Expand Up @@ -61,22 +61,6 @@ class="cursor-pointer text-muted hvr-icon-bounce" data-bs-toggle="tooltip" data-
</svg>
<span comment-show="comment-topic-likes">{{ $value->likes }}</span>
</a>
{{-- markdown --}}
@if(get_options('comment_ban_markdown_preview')!=="true")
<a style="text-decoration:none;" data-bs-toggle="tooltip" data-bs-placement="top" href="/comment/topic/{{ $value->id }}.md"
data-bs-original-title="{{__("app.preview markdown")}}" class="hvr-icon-grow-rotate">
<span class="switch-icon-a text-muted">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-markdown hvr-icon" 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>
<rect x="3" y="5" width="18" height="14" rx="2"></rect>
<path d="M7 15v-6l2 2l2 -2v6"></path>
<path d="M14 13l2 2l2 -2m-2 2v-6"></path>
</svg>
</span>
</a>
@endif

{{-- 收藏--}}
@if(auth()->check())
Expand Down
19 changes: 0 additions & 19 deletions app/Plugins/Comment/resources/views/Widget/show-topic.blade.php
Expand Up @@ -122,25 +122,6 @@ class="cursor-pointer text-muted hvr-icon-bounce"
</svg>
<span comment-show="comment-topic-likes">{{ $value->likes }}</span>
</a>
{{-- markdown --}}
@if(get_options('comment_ban_markdown_preview')!=="true")
<a style="text-decoration:none;" data-bs-toggle="tooltip"
data-bs-placement="top" href="/comment/topic/{{ $value->id }}.md"
data-bs-original-title="{{__("app.preview markdown")}}"
class="hvr-icon-grow-rotate">
<span class="switch-icon-a text-muted">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-markdown hvr-icon"
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>
<rect x="3" y="5" width="18" height="14" rx="2"></rect>
<path d="M7 15v-6l2 2l2 -2v6"></path>
<path d="M14 13l2 2l2 -2m-2 2v-6"></path>
</svg>
</span>
</a>
@endif
{{-- 回复--}}
<a style="text-decoration:none;" comment-click="comment-reply-topic"
comment-id="{{ $value->id }}"
Expand Down
6 changes: 0 additions & 6 deletions app/Plugins/Comment/resources/views/setting.blade.php
Expand Up @@ -45,12 +45,6 @@
<small>默认开启</small>
</div>

<div class="mb-3">
<label class="form-check form-switch">
<input class="form-check-input" type="checkbox" v-model="data.comment_ban_markdown_preview">
<span class="form-check-label">禁用markdown预览</span>
</label>
</div>
<div class="mb-3">
<label class="form-check form-switch">
<input class="form-check-input" type="checkbox" v-model="data.comment_show_desc">
Expand Down
5 changes: 0 additions & 5 deletions app/Plugins/Comment/src/Controller/ApiController.php
Expand Up @@ -41,7 +41,6 @@ public function topic_create(TopicCreate $request){

$post = Post::query()->create([
'content' => $content,
'markdown' => $request->input('markdown'),
'user_agent' => get_user_agent(),
'user_ip' => get_client_ip(),
'user_id' => auth()->id()
Expand Down Expand Up @@ -95,7 +94,6 @@ public function topic_reply_create(TopicReply $request): bool|array
$parent_id = TopicComment::query()->where("id",$comment_id)->first()->user_id;
$post = Post::query()->create([
'content' => $content,
'markdown' => $request->input('markdown'),
'user_agent' => get_user_agent(),
'user_ip' => get_client_ip(),
'user_id' => auth()->id()
Expand Down Expand Up @@ -267,7 +265,6 @@ public function topic_comment_data(): array
$data = TopicComment::query()
->where([["id",$comment_id],['status','publish']])
->first();
$data['markdown'] = $data->post->markdown;
return Json_Api(200,true,$data);
}

Expand All @@ -293,11 +290,9 @@ public function topic_comment_update(UpdateComment $request){

// 解析艾特
$content = $this->topic_create_at($content);
$markdown = $request->input("markdown");
$post_id = TopicComment::query()->find($id)->post_id;
Post::query()->where("id",$post_id)->update([
'content' => $content,
'markdown' => $markdown
]);
return Json_Api(200,true,["更新成功!"]);
}
Expand Down
38 changes: 12 additions & 26 deletions app/Plugins/Comment/src/Controller/IndexController.php
Expand Up @@ -7,40 +7,26 @@
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;

#[Controller(prefix:"/comment")]
#[Controller(prefix: "/comment")]
class IndexController
{
#[GetMapping(path:"topic/{id}.md")]
public function show_topic_comment($id){
if(get_options('comment_ban_markdown_preview')==="true"){
return admin_abort("页面不存在",404);
}
if(Report::query()->where(['type' => 'comment','_id' => $id,'status' => 'approve'])->exists()){
return admin_abort('此评论已被举报并批准,无法查看',403);
#[GetMapping(path: "topic/{id}/edit")]
public function edit_topic_comment($id)
{
if (!TopicComment::query()->where("id", $id)->exists()) {
return admin_abort("id为:" . $id . "的评论不存在", 404);
}
if(!TopicComment::query()->where("id",$id)->exists()){
return admin_abort("页面不存在",404);
}
$data = TopicComment::query()->select("post_id")->where("id",$id)->first()->post->markdown;
return response()->raw(ShortCodeR()->filter($data));
}

#[GetMapping(path:"topic/{id}/edit")]
public function edit_topic_comment($id){
if(!TopicComment::query()->where("id",$id)->exists()){
return admin_abort("id为:".$id."的评论不存在",404);
}
$data = TopicComment::query()->where("id",$id)->first();
$data = TopicComment::query()->where("id", $id)->first();
$quanxian = false;
if(Authority()->check("admin_topic_edit") && curd()->GetUserClass(auth()->data()->class_id)['permission-value']>curd()->GetUserClass($data->user->class_id)['permission-value']){
if (Authority()->check("admin_topic_edit") && curd()->GetUserClass(auth()->data()->class_id)['permission-value'] > curd()->GetUserClass($data->user->class_id)['permission-value']) {
$quanxian = true;
}
if(Authority()->check("topic_edit") && auth()->id() === $data->user->id){
if (Authority()->check("topic_edit") && auth()->id() === $data->user->id) {
$quanxian = true;
}
if($quanxian===false){
return admin_abort("无权操作!",419);
if ($quanxian === false) {
return admin_abort("无权操作!", 419);
}
return view("Comment::topic.edit",['data' => $data]);
return view("Comment::topic.edit", ['data' => $data]);
}
}
3 changes: 1 addition & 2 deletions app/Plugins/Comment/src/Model/TopicComment.php
Expand Up @@ -15,8 +15,7 @@
* @property string $topic_id
* @property string $user_id
* @property string $parent_id
* @property string $content
* @property string $markdown
* @property string $content
* @property string $status
* @property string $shenping
* @property string $optimal
Expand Down
2 changes: 0 additions & 2 deletions app/Plugins/Comment/src/Request/Topic/UpdateComment.php
Expand Up @@ -19,7 +19,6 @@ public function rules():array
return [
"comment_id" => "required|exists:topic_comment,id",
"content" => "required|string|min:".get_options("comment_reply_min",1)."|max:".get_options("comment_reply_max",200),
"markdown" => "required|string",
];
}

Expand All @@ -28,7 +27,6 @@ public function attributes(): array
return [
"comment_id" => "评论ID",
"content" => __("topic.comment.comment content"),
"markdown" => "评论markdown内容",
];
}
}
2 changes: 0 additions & 2 deletions app/Plugins/Comment/src/Request/TopicCreate.php
Expand Up @@ -19,7 +19,6 @@ public function rules():array
return [
"topic_id" => "required|exists:topic,id",
"content" => "required|string",
"markdown" => "required|string|between:".get_options("comment_create_min",1).",".get_options("comment_create_max",200),
];
}

Expand All @@ -28,7 +27,6 @@ public function attributes(): array
return [
"topic_id" => "帖子ID",
"html" => __("topic.comment.comment content"),
"markdown" => "评论md内容"
];
}
}
2 changes: 0 additions & 2 deletions app/Plugins/Comment/src/Request/TopicReply.php
Expand Up @@ -19,7 +19,6 @@ public function rules():array
return [
"comment_id" => "required|exists:topic_comment,id",
"content" => "required|string",
"markdown" => "required|string|between:".get_options("comment_reply_min",1).",".get_options("comment_reply_max",200),
"parent_url" => "required",
];
}
Expand All @@ -29,7 +28,6 @@ public function attributes(): array
return [
"comment_id" => "被回复的评论ID",
"content" => __("topic.comment.comment content"),
"markdown" => "评论md内容",
"parent_url" => "被回复的帖子链接",
];
}
Expand Down

0 comments on commit 7b3f388

Please sign in to comment.