Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81a039a
commit 0ee8608
Showing
12 changed files
with
317 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of zhuchunshu. | ||
* @link https://github.com/zhuchunshu | ||
* @document https://github.com/zhuchunshu/super-forum | ||
* @contact laravel@88.com | ||
* @license https://github.com/zhuchunshu/super-forum/blob/master/LICENSE | ||
*/ | ||
namespace App\Plugins\Core\src\Models; | ||
|
||
use App\Model\Model; | ||
|
||
/** | ||
* @property int $id | ||
* @property int $disable_comment | ||
*/ | ||
class PostsOption extends Model | ||
{ | ||
|
||
protected $fillable = ['post_id','id','disable_comment']; | ||
|
||
public $timestamps = false; | ||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'posts_options'; | ||
|
||
/** | ||
* The attributes that should be cast to native types. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = ['id' => 'integer', 'disable_comment' => 'integer']; | ||
} |
27 changes: 27 additions & 0 deletions
27
app/Plugins/Core/src/migrations/2022_12_22_174804_create_posts_options_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Hyperf\Database\Schema\Schema; | ||
use Hyperf\Database\Schema\Blueprint; | ||
use Hyperf\Database\Migrations\Migration; | ||
|
||
class CreatePostsOptionsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('posts_options', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->boolean('disable_comment')->default(false)->comment('禁用评论'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('posts_options'); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/Plugins/Core/src/migrations/2022_12_22_181239_update_posts_options_table_add_post_id.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Hyperf\Database\Schema\Schema; | ||
use Hyperf\Database\Schema\Blueprint; | ||
use Hyperf\Database\Migrations\Migration; | ||
|
||
class UpdatePostsOptionsTableAddPostId extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('posts_options', function (Blueprint $table) { | ||
$table->string('post_id'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('posts_options', function (Blueprint $table) { | ||
// | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/Plugins/Topic/resources/assets/js/editor/plugins/sfEmoji.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
Note: We have included the plugin in the same JavaScript file as the TinyMCE | ||
instance for display purposes only. Tiny recommends not maintaining the plugin | ||
with the TinyMCE instance and using the `external_plugins` option. | ||
*/ | ||
|
||
tinymce.PluginManager.add('sfEmoji', (editor, url) => { | ||
const tabs = ()=>{ | ||
return { | ||
name:"a", | ||
title:"Title", | ||
items: [ | ||
{ | ||
type: 'iframe', // component type | ||
name: 'sfPreview', // identifier | ||
sandboxed: true, | ||
transparent: true, | ||
} | ||
] | ||
} | ||
} | ||
const openDialog = () => editor.windowManager.open({ | ||
title: '表情', | ||
size: "large", | ||
body: { | ||
type: 'tabpanel', | ||
tabs:[ | ||
tabs() | ||
] | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'cancel', | ||
text: 'Close' | ||
}, | ||
], | ||
}); | ||
/* Add a button that opens a window */ | ||
editor.ui.registry.addButton('sfEmoji', { | ||
icon:'emoji', | ||
onAction: () => { | ||
/* Open window */ | ||
let _openDialog = openDialog(); | ||
axios.post("/topic/create/preview",{ | ||
_token:csrf_token, | ||
content:editor.getContent() | ||
}).then(r=>{ | ||
_openDialog.setData({ | ||
sfPreview:r.data | ||
}) | ||
}) | ||
} | ||
}); | ||
/* Adds a menu item, which can then be included in any menu via the menu/menubar configuration */ | ||
editor.ui.registry.addMenuItem('sfEmoji', { | ||
text: '表情', | ||
icon:'emoji', | ||
onAction: () => { | ||
/* Open window */ | ||
let _openDialog = openDialog(); | ||
axios.post("/topic/create/preview",{ | ||
_token:csrf_token, | ||
content:editor.getContent() | ||
}).then(r=>{ | ||
_openDialog.setData({ | ||
sfPreview:r.data | ||
}) | ||
}) | ||
} | ||
}); | ||
/* Return the metadata for the help plugin */ | ||
return { | ||
getMetadata: () => ({ | ||
name: 'sfEmoji', | ||
url: 'https://www.runpod.cn' | ||
}) | ||
}; | ||
}); |
11 changes: 11 additions & 0 deletions
11
app/Plugins/Topic/resources/views/create/options/disable_comment.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
<div class="col-12"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<label class="form-check"> | ||
<input type="checkbox" name="options[disable_comment]" class="form-check-input"/> | ||
<span class="form-check-label">关闭评论</span> | ||
</label> | ||
</div> | ||
</div> | ||
</div> |
27 changes: 0 additions & 27 deletions
27
app/Plugins/Topic/resources/views/create/options/upload.blade.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/Plugins/Topic/src/Handler/Topic/Middleware/Create/PostsOptionsMiddleware.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of zhuchunshu. | ||
* @link https://github.com/zhuchunshu | ||
* @document https://github.com/zhuchunshu/super-forum | ||
* @contact laravel@88.com | ||
* @license https://github.com/zhuchunshu/super-forum/blob/master/LICENSE | ||
*/ | ||
namespace App\Plugins\Topic\src\Handler\Topic\Middleware\Create; | ||
|
||
use App\Plugins\Core\src\Models\PostsOption; | ||
use App\Plugins\Topic\src\Handler\Topic\Middleware\MiddlewareInterface; | ||
|
||
#[\App\Plugins\Topic\src\Annotation\Topic\CreateLastMiddleware] | ||
class PostsOptionsMiddleware implements MiddlewareInterface | ||
{ | ||
public function handler($data, \Closure $next) | ||
{ | ||
$post_id = $data['post_id']; | ||
if (! PostsOption::query()->where('post_id', $post_id)->exists()) { | ||
$post_options = PostsOption::create([ | ||
'post_id' => $post_id, | ||
]); | ||
} else { | ||
$post_options = PostsOption::query()->where('post_id', $post_id)->first()->id; | ||
} | ||
$data['posts_options'] = $post_options; | ||
return $next($data); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/Plugins/Topic/src/Handler/Topic/Middleware/Create/SetDisableCommentMiddleware.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of zhuchunshu. | ||
* @link https://github.com/zhuchunshu | ||
* @document https://github.com/zhuchunshu/super-forum | ||
* @contact laravel@88.com | ||
* @license https://github.com/zhuchunshu/super-forum/blob/master/LICENSE | ||
*/ | ||
namespace App\Plugins\Topic\src\Handler\Topic\Middleware\Create; | ||
|
||
use App\Plugins\Core\src\Models\PostsOption; | ||
use App\Plugins\Topic\src\Handler\Topic\Middleware\MiddlewareInterface; | ||
|
||
#[\App\Plugins\Topic\src\Annotation\Topic\CreateLastMiddleware] | ||
class SetDisableCommentMiddleware implements MiddlewareInterface | ||
{ | ||
public function handler($data, \Closure $next) | ||
{ | ||
$disable_comment = (bool) request()->input('options.disable_comment', false); | ||
$posts_options_id = $data['posts_options']['id']; | ||
PostsOption::query()->where('id', $posts_options_id)->update([ | ||
'disable_comment' => $disable_comment, | ||
]); | ||
return $next($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.