Skip to content

Commit 7b3f388

Browse files
committedDec 23, 2022
更新:弃用markdown预览
1 parent 05381d5 commit 7b3f388

File tree

30 files changed

+303
-624
lines changed

30 files changed

+303
-624
lines changed
 

‎app/CodeFec/Install.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,12 @@ public function step_3()
205205
public function step_4()
206206
{
207207
// V2.0 对topic表的更改
208-
$topics = DB::table('topic')->where('post_id', '=', null)->get(['id', 'content', 'markdown', 'user_agent', 'user_ip', 'user_id', 'created_at', 'updated_at']);
208+
$topics = DB::table('topic')->where('post_id', '=', null)->get(['id', 'content', 'user_agent', 'user_ip', 'user_id', 'created_at', 'updated_at']);
209209
foreach ($topics as $data) {
210210
$post = Post::query()->create([
211211
'topic_id' => $data->id,
212212
'user_id' => $data->user_id,
213213
'content' => $data->content,
214-
'markdown' => $data->markdown,
215214
'user_agent' => $data->user_agent,
216215
'user_ip' => $data->user_ip,
217216
'created_at' => $data->created_at,
@@ -221,13 +220,12 @@ public function step_4()
221220
}
222221

223222
// v2.0对topic_comment表的更改
224-
$comments = Db::table('topic_comment')->where('post_id', '=', null)->get(['id', 'user_id', 'content', 'markdown', 'user_agent', 'user_ip', 'created_at', 'updated_at']);
223+
$comments = Db::table('topic_comment')->where('post_id', '=', null)->get(['id', 'user_id', 'content', 'user_agent', 'user_ip', 'created_at', 'updated_at']);
225224
foreach ($comments as $data) {
226225
$post = Post::query()->create([
227226
'comment_id' => $data->id,
228227
'user_id' => $data->user_id,
229228
'content' => $data->content,
230-
'markdown' => $data->markdown,
231229
'user_agent' => $data->user_agent,
232230
'user_ip' => $data->user_ip,
233231
'created_at' => $data->created_at,

‎app/Plugins/Comment/resources/views/ShortCode/comment.blade.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ class="cursor-pointer text-muted hvr-icon-bounce" data-bs-toggle="tooltip" data-
6161
</svg>
6262
<span comment-show="comment-topic-likes">{{ $value->likes }}</span>
6363
</a>
64-
{{-- markdown --}}
65-
@if(get_options('comment_ban_markdown_preview')!=="true")
66-
<a style="text-decoration:none;" data-bs-toggle="tooltip" data-bs-placement="top" href="/comment/topic/{{ $value->id }}.md"
67-
data-bs-original-title="{{__("app.preview markdown")}}" class="hvr-icon-grow-rotate">
68-
<span class="switch-icon-a text-muted">
69-
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-markdown hvr-icon" width="24"
70-
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
71-
stroke-linecap="round" stroke-linejoin="round">
72-
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
73-
<rect x="3" y="5" width="18" height="14" rx="2"></rect>
74-
<path d="M7 15v-6l2 2l2 -2v6"></path>
75-
<path d="M14 13l2 2l2 -2m-2 2v-6"></path>
76-
</svg>
77-
</span>
78-
</a>
79-
@endif
8064

8165
{{-- 收藏--}}
8266
@if(auth()->check())

‎app/Plugins/Comment/resources/views/Widget/show-topic.blade.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,6 @@ class="cursor-pointer text-muted hvr-icon-bounce"
122122
</svg>
123123
<span comment-show="comment-topic-likes">{{ $value->likes }}</span>
124124
</a>
125-
{{-- markdown --}}
126-
@if(get_options('comment_ban_markdown_preview')!=="true")
127-
<a style="text-decoration:none;" data-bs-toggle="tooltip"
128-
data-bs-placement="top" href="/comment/topic/{{ $value->id }}.md"
129-
data-bs-original-title="{{__("app.preview markdown")}}"
130-
class="hvr-icon-grow-rotate">
131-
<span class="switch-icon-a text-muted">
132-
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-markdown hvr-icon"
133-
width="24"
134-
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
135-
stroke-linecap="round" stroke-linejoin="round">
136-
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
137-
<rect x="3" y="5" width="18" height="14" rx="2"></rect>
138-
<path d="M7 15v-6l2 2l2 -2v6"></path>
139-
<path d="M14 13l2 2l2 -2m-2 2v-6"></path>
140-
</svg>
141-
</span>
142-
</a>
143-
@endif
144125
{{-- 回复--}}
145126
<a style="text-decoration:none;" comment-click="comment-reply-topic"
146127
comment-id="{{ $value->id }}"

‎app/Plugins/Comment/resources/views/setting.blade.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545
<small>默认开启</small>
4646
</div>
4747

48-
<div class="mb-3">
49-
<label class="form-check form-switch">
50-
<input class="form-check-input" type="checkbox" v-model="data.comment_ban_markdown_preview">
51-
<span class="form-check-label">禁用markdown预览</span>
52-
</label>
53-
</div>
5448
<div class="mb-3">
5549
<label class="form-check form-switch">
5650
<input class="form-check-input" type="checkbox" v-model="data.comment_show_desc">

‎app/Plugins/Comment/src/Controller/ApiController.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function topic_create(TopicCreate $request){
4141

4242
$post = Post::query()->create([
4343
'content' => $content,
44-
'markdown' => $request->input('markdown'),
4544
'user_agent' => get_user_agent(),
4645
'user_ip' => get_client_ip(),
4746
'user_id' => auth()->id()
@@ -95,7 +94,6 @@ public function topic_reply_create(TopicReply $request): bool|array
9594
$parent_id = TopicComment::query()->where("id",$comment_id)->first()->user_id;
9695
$post = Post::query()->create([
9796
'content' => $content,
98-
'markdown' => $request->input('markdown'),
9997
'user_agent' => get_user_agent(),
10098
'user_ip' => get_client_ip(),
10199
'user_id' => auth()->id()
@@ -267,7 +265,6 @@ public function topic_comment_data(): array
267265
$data = TopicComment::query()
268266
->where([["id",$comment_id],['status','publish']])
269267
->first();
270-
$data['markdown'] = $data->post->markdown;
271268
return Json_Api(200,true,$data);
272269
}
273270

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

294291
// 解析艾特
295292
$content = $this->topic_create_at($content);
296-
$markdown = $request->input("markdown");
297293
$post_id = TopicComment::query()->find($id)->post_id;
298294
Post::query()->where("id",$post_id)->update([
299295
'content' => $content,
300-
'markdown' => $markdown
301296
]);
302297
return Json_Api(200,true,["更新成功!"]);
303298
}

‎app/Plugins/Comment/src/Controller/IndexController.php

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,26 @@
77
use Hyperf\HttpServer\Annotation\Controller;
88
use Hyperf\HttpServer\Annotation\GetMapping;
99

10-
#[Controller(prefix:"/comment")]
10+
#[Controller(prefix: "/comment")]
1111
class IndexController
1212
{
13-
#[GetMapping(path:"topic/{id}.md")]
14-
public function show_topic_comment($id){
15-
if(get_options('comment_ban_markdown_preview')==="true"){
16-
return admin_abort("页面不存在",404);
17-
}
18-
if(Report::query()->where(['type' => 'comment','_id' => $id,'status' => 'approve'])->exists()){
19-
return admin_abort('此评论已被举报并批准,无法查看',403);
13+
#[GetMapping(path: "topic/{id}/edit")]
14+
public function edit_topic_comment($id)
15+
{
16+
if (!TopicComment::query()->where("id", $id)->exists()) {
17+
return admin_abort("id为:" . $id . "的评论不存在", 404);
2018
}
21-
if(!TopicComment::query()->where("id",$id)->exists()){
22-
return admin_abort("页面不存在",404);
23-
}
24-
$data = TopicComment::query()->select("post_id")->where("id",$id)->first()->post->markdown;
25-
return response()->raw(ShortCodeR()->filter($data));
26-
}
27-
28-
#[GetMapping(path:"topic/{id}/edit")]
29-
public function edit_topic_comment($id){
30-
if(!TopicComment::query()->where("id",$id)->exists()){
31-
return admin_abort("id为:".$id."的评论不存在",404);
32-
}
33-
$data = TopicComment::query()->where("id",$id)->first();
19+
$data = TopicComment::query()->where("id", $id)->first();
3420
$quanxian = false;
35-
if(Authority()->check("admin_topic_edit") && curd()->GetUserClass(auth()->data()->class_id)['permission-value']>curd()->GetUserClass($data->user->class_id)['permission-value']){
21+
if (Authority()->check("admin_topic_edit") && curd()->GetUserClass(auth()->data()->class_id)['permission-value'] > curd()->GetUserClass($data->user->class_id)['permission-value']) {
3622
$quanxian = true;
3723
}
38-
if(Authority()->check("topic_edit") && auth()->id() === $data->user->id){
24+
if (Authority()->check("topic_edit") && auth()->id() === $data->user->id) {
3925
$quanxian = true;
4026
}
41-
if($quanxian===false){
42-
return admin_abort("无权操作!",419);
27+
if ($quanxian === false) {
28+
return admin_abort("无权操作!", 419);
4329
}
44-
return view("Comment::topic.edit",['data' => $data]);
30+
return view("Comment::topic.edit", ['data' => $data]);
4531
}
4632
}

‎app/Plugins/Comment/src/Model/TopicComment.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* @property string $topic_id
1616
* @property string $user_id
1717
* @property string $parent_id
18-
* @property string $content
19-
* @property string $markdown
18+
* @property string $content
2019
* @property string $status
2120
* @property string $shenping
2221
* @property string $optimal

‎app/Plugins/Comment/src/Request/Topic/UpdateComment.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function rules():array
1919
return [
2020
"comment_id" => "required|exists:topic_comment,id",
2121
"content" => "required|string|min:".get_options("comment_reply_min",1)."|max:".get_options("comment_reply_max",200),
22-
"markdown" => "required|string",
2322
];
2423
}
2524

@@ -28,7 +27,6 @@ public function attributes(): array
2827
return [
2928
"comment_id" => "评论ID",
3029
"content" => __("topic.comment.comment content"),
31-
"markdown" => "评论markdown内容",
3230
];
3331
}
3432
}

‎app/Plugins/Comment/src/Request/TopicCreate.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function rules():array
1919
return [
2020
"topic_id" => "required|exists:topic,id",
2121
"content" => "required|string",
22-
"markdown" => "required|string|between:".get_options("comment_create_min",1).",".get_options("comment_create_max",200),
2322
];
2423
}
2524

@@ -28,7 +27,6 @@ public function attributes(): array
2827
return [
2928
"topic_id" => "帖子ID",
3029
"html" => __("topic.comment.comment content"),
31-
"markdown" => "评论md内容"
3230
];
3331
}
3432
}

‎app/Plugins/Comment/src/Request/TopicReply.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function rules():array
1919
return [
2020
"comment_id" => "required|exists:topic_comment,id",
2121
"content" => "required|string",
22-
"markdown" => "required|string|between:".get_options("comment_reply_min",1).",".get_options("comment_reply_max",200),
2322
"parent_url" => "required",
2423
];
2524
}
@@ -29,7 +28,6 @@ public function attributes(): array
2928
return [
3029
"comment_id" => "被回复的评论ID",
3130
"content" => __("topic.comment.comment content"),
32-
"markdown" => "评论md内容",
3331
"parent_url" => "被回复的帖子链接",
3432
];
3533
}

0 commit comments

Comments
 (0)
Please sign in to comment.