FastMovieAI AI短剧创作平台 二开基线

- 源码: xhadmincn/FastMovieAI (Apache 2.0)
- 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION
- vendor/示例资源已gitignore
This commit is contained in:
李建琦
2026-08-26 18:37:36 +08:00
commit eae151fd57
888 changed files with 105571 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
{
"title":"文章",
"icon":"Notebook",
"path":"/app/article/admin",
"sort":4999,
"children":[
{
"title":"公告",
"icon":"BellFilled",
"path":"/app/article/admin/Announcement/index",
"component":"table"
},
{
"title":"文章列表",
"icon":"Notebook",
"path":"/app/article/admin/Index/index",
"show": false,
"component":"table"
},
{
"title":"添加文章",
"path":"/app/article/admin/Index/create",
"component":"form",
"show":false
},
{
"title":"编辑文章",
"path":"/app/article/admin/Index/update",
"component":"form",
"show":false
},
{
"title":"审核文章",
"path":"/app/article/admin/Index/examine",
"component":"form",
"show":false
},
{
"title":"更新文章状态",
"path":"/app/article/admin/Index/indexUpdateState",
"show":false
},
{
"title":"更新文章排序",
"path":"/app/article/admin/Index/indexUpdateField",
"show":false
},
{
"title":"删除文章",
"path":"/app/article/admin/Index/delete",
"show":false
},
{
"title":"缓存文章",
"path":"/app/article/admin/Index/cache",
"show":false
},
{
"title":"文章分类",
"icon":"FolderOpened",
"path":"/app/article/admin/Classify/index",
"component":"table"
},
{
"title":"添加分类",
"path":"/app/article/admin/Classify/create",
"component":"form",
"show":false
},
{
"title":"编辑分类",
"path":"/app/article/admin/Classify/update",
"component":"form",
"show":false
},
{
"title":"更新分类状态",
"path":"/app/article/admin/Classify/indexUpdateState",
"show":false
},
{
"title":"更新分类排序",
"path":"/app/article/admin/Classify/indexUpdateField",
"show":false
},
{
"title":"删除分类",
"path":"/app/article/admin/Classify/delete",
"show":false
}
]
}
@@ -0,0 +1,15 @@
<?php
namespace plugin\article\api;
use plugin\control\expose\api\Control as ApiControl;
class Control
{
use ApiControl;
public function __construct()
{
$this->path = __DIR__;
$this->plugin = 'article';
}
}
@@ -0,0 +1,14 @@
<?php
namespace plugin\article\api;
use app\expose\api\Install as ApiInstall;
class Install
{
use ApiInstall;
public function __construct()
{
$this->path = __DIR__;
}
}
@@ -0,0 +1,76 @@
/*
Navicat Premium Data Transfer
Source Server : Loong
Source Server Type : MySQL
Source Server Version : 80024 (8.0.24)
Source Host : 127.0.0.1:3306
Source Schema : cloud_xhadmin_cn
Target Server Type : MySQL
Target Server Version : 80024 (8.0.24)
File Encoding : 65001
Date: 15/05/2024 18:50:00
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for php_plugin_article
-- ----------------------------
DROP TABLE IF EXISTS `php_plugin_article`;
CREATE TABLE `php_plugin_article` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`create_time` datetime NULL DEFAULT NULL,
`update_time` datetime NULL DEFAULT NULL,
`release_time` datetime NULL DEFAULT NULL,
`alias` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文章别名',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文章标题',
`subtitle` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`keywords` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`state` tinyint(1) NULL DEFAULT 1,
`examine` tinyint(1) NULL DEFAULT NULL,
`view` int NULL DEFAULT 0,
`thumb` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '文章封面',
`class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`description` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`classify_id` int NULL DEFAULT NULL,
`sort` tinyint NULL DEFAULT 99,
`delete_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `alias`(`alias` ASC) USING BTREE,
INDEX `cid`(`classify_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '文章' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Table structure for php_plugin_article_classify
-- ----------------------------
DROP TABLE IF EXISTS `php_plugin_article_classify`;
CREATE TABLE `php_plugin_article_classify` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`create_time` datetime NULL DEFAULT NULL COMMENT '分类创建时间',
`update_time` datetime NULL DEFAULT NULL,
`title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类名称',
`alias` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '别名',
`pid` int NULL DEFAULT NULL COMMENT '父级ID',
`sort` int NULL DEFAULT 99 COMMENT '排序',
`state` tinyint(1) NULL DEFAULT 1,
PRIMARY KEY (`id`) USING BTREE,
INDEX `alias`(`alias` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '文章分类数据' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Table structure for php_plugin_article_content
-- ----------------------------
DROP TABLE IF EXISTS `php_plugin_article_content`;
CREATE TABLE `php_plugin_article_content` (
`article_id` int UNSIGNED NOT NULL,
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
PRIMARY KEY (`article_id`) USING BTREE,
UNIQUE INDEX `article`(`article_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '文章内容表' ROW_FORMAT = DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1;
@@ -0,0 +1,10 @@
<?php
namespace plugin\article\app;
use app\Basic as AppBasic;
class Basic extends AppBasic
{
public $plugin = '/app/article/';
}
@@ -0,0 +1,516 @@
<?php
namespace plugin\article\app\admin\controller;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\Examine;
use app\expose\enum\State;
use app\expose\helper\Config;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleClassify;
use plugin\article\app\model\PluginArticleContent;
use plugin\article\app\validate\Article;
use support\Request;
use think\facade\Db;
class AnnouncementController extends Basic
{
public function __construct()
{
$this->model = new PluginArticle();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder();
$builder->addAction('操作', [
'width' => '220px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'path' => $this->plugin . 'admin/Announcement/update',
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('缓存', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'admin/Announcement/cache',
'props' => [
'type' => 'warning',
'title' => '确定要重新缓存《{title}》公告吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'warning',
'size' => 'small'
]
]
]);
$builder->addTableAction('删除', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'admin/Announcement/delete',
'props' => [
'type' => 'danger',
'title' => '确定要删除《{title}》公告吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'danger',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('发布公告', [
'path' => $this->plugin . 'admin/Announcement/create',
'props' => [
'type' => 'success',
'title' => '发布公告'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder();
$formBuilder->add('title', '标题', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'placeholder' => '标题搜索',
'clearable' => true
]
]);
$formBuilder->add('state', '状态', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'options' => State::getOptions(),
'props' => [
'placeholder' => '状态搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '80px'
]
]);
$builder->add('title', '标题', [
'props' => [
'minWidth' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'title',
'label' => '标题',
'component' => 'text',
'props' => [
'type' => 'primary',
'size' => 'small'
]
],
[
'field' => 'subtitle',
'label' => '副标题',
'component' => 'text',
'props' => [
'type' => 'info',
'size' => 'small'
]
]
]
]
]
]);
$builder->add('alias', '别名', [
'props' => [
'width' => '200px'
]
]);
$builder->add('view', '浏览量', [
'props' => [
'width' => '100px'
]
]);
$builder->add('source', '来源', [
'props' => [
'width' => '100px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => $this->plugin . 'admin/Announcement/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '160px'
]
]);
$builder->add('sort', '排序', [
'component' => [
'name' => 'input-number',
'api' => $this->plugin . 'admin/Announcement/indexUpdateField',
'props' => [
'min' => 0,
'size' => 'small'
]
],
'props' => [
'width' => '180px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
],
[
'field' => 'release_time',
'label' => '发布'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$title = $request->get('title');
if ($title) {
$where[] = ['a.title', 'like', "%{$title}%"];
}
$where[] = ['a.alias', '=', 'announcement'];
$state = $request->get('state');
if ($state) {
$where[] = ['a.state', '=', $state];
}
$where[] = ['a.examine', '=', Examine::PASS['value']];
$list = PluginArticle::alias('a')->where($where)
->join('plugin_article_classify c', 'c.id = a.classify_id', 'LEFT')
->field('a.*,c.title as classify_title')
->order('a.id desc')->paginate($limit)->each(function ($item) {});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('create')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = new PluginArticle;
$PluginArticle->pid = $D['pid'];
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->keywords = $D['keywords'];
$PluginArticle->description = $D['description'];
$PluginArticle->alias = 'announcement';
$PluginArticle->view = $D['view'];
$PluginArticle->sort = $D['sort'];
$PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->examine = Examine::PASS['value'];
if ($D['release_time']) {
$PluginArticle->release_time = $D['release_time'];
} else {
$PluginArticle->release_time = date('Y-m-d H:i:s');
}
$PluginArticle->save();
$PluginArticleContent = new PluginArticleContent;
$PluginArticleContent->article_id = $PluginArticle->id;
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
$this->cacheHtml($PluginArticle->id);
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('update')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = PluginArticle::where(['id' => $D['id']])->find();
$PluginArticle->pid = $D['pid'];
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->keywords = $D['keywords'];
$PluginArticle->description = $D['description'];
$PluginArticle->view = $D['view'];
$PluginArticle->sort = $D['sort'];
$PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->release_time = $D['release_time'];
$PluginArticle->save();
$PluginArticleContent = PluginArticleContent::where(['article_id' => $D['id']])->find();
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('编辑成功');
}
$id = $request->get('id');
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c', 'c.article_id=a.id')->field('a.*,c.content')->find();
$builder = $this->getFormBuilder();
$builder->setData($PluginArticle->toArray());
return $this->resData($builder);
}
public function getFormBuilder()
{
$builder = new FormBuilder(null, null, ['size' => 'large']);
$Component = new ComponentBuilder;
$builder->add('classify_id', '所属分类', 'cascader', '', [
'required' => true,
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('subtitle', '副标题', 'input', '', [
'props' => [
'maxlength' => 200,
'show-word-limit' => true
]
]);
$builder->add('thumb', '封面', 'bundle', [], [
'props' => [
'accept' => 'image/*',
'multiple' => 5
]
]);
$builder->add('keywords', '关键词', 'input', '', [
'props' => [
'type' => 'textarea',
'maxlength' => 200,
'show-word-limit' => true,
'autosize' => [
'minRows' => 2,
'maxRows' => 4
]
]
]);
$builder->add('description', '描述', 'input', '', [
'props' => [
'type' => 'textarea',
'maxlength' => 300,
'show-word-limit' => true,
'autosize' => [
'minRows' => 3,
'maxRows' => 6
]
]
]);
$builder->add('alias', '别名', 'input', '', [
'col' => [
'xs' => 24,
'md' => 12
],
'prompt' => [
$Component->add('text', ['default' => '设置别名后可通过别名访问公告'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'maxlength' => 30,
'show-word-limit' => true
]
]);
$builder->add('view', '浏览量', 'input-number', 0, [
'col' => [
'xs' => 24,
'md' => 6
],
'props' => [
'min' => 0,
'controls' => false
]
]);
$builder->add('sort', '排序', 'input-number', 99, [
'col' => [
'xs' => 24,
'md' => 6
],
'props' => [
'min' => 0,
'controls' => false
]
]);
$builder->add('source', '来源名称', 'input', '', [
'prompt' => [
$Component->add('text', ['default' => '为空则自动读取网站应用名称'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'required' => true,
'options' => State::getOptions(),
'subProps' => [
'border' => true
]
]);
$builder->add('release_time', '发布时间', 'date-picker', null, [
'prompt' => [
$Component->add('text', ['default' => '为空则自动写入当前时间'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'type' => 'datetime',
'format' => 'YYYY-MM-DD HH:mm:ss',
'value-format' => 'YYYY-MM-DD HH:mm:ss',
'placeholder' => '发布时间'
]
]);
$builder->add('content', '内容', 'wangeditor', '', [
'required' => true,
'props' => [
'class' => 'vh-60'
]
]);
return $builder;
}
public function indexUpdateState(Request $request)
{
$id = $request->post('id');
$field = $request->post('field');
$value = $request->post('value');
$model = $this->model->where(['id' => $id])->find();
if (!$model) {
return $this->fail('数据不存在');
}
$model->{$field} = $value;
if ($model->save()) {
try {
if ($value === State::NO['value']) {
$this->clearHtml($id);
} else {
$this->cacheHtml($id);
}
} catch (\Throwable $th) {
}
return $this->success();
}
return $this->fail('操作失败');
}
public function clearHtml($id)
{
$PluginArticle = PluginArticle::where(['id' => $id])->find();
$path = public_path('article/' . $id . '.html');
if (file_exists($path)) {
unlink($path);
}
if ($PluginArticle->alias) {
$path = public_path('article/' . $PluginArticle->alias . '.html');
if (file_exists($path)) {
unlink($path);
}
}
}
public function cacheHtml($id)
{
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c', 'c.article_id=a.id')->field('a.*,c.content')->find();
$config = new Config('basic', '');
if (!$PluginArticle->source) {
$PluginArticle->source = $config['web_name'];
}
if ($config['logo_use'] == 'image') {
$PluginArticle->web_logo = $config['web_logo_light'];
} else {
$PluginArticle->web_logo = '/vite.svg';
}
$PluginArticle->web_title = "{$PluginArticle->title} - {$config['web_title']}";
$html = view(base_path('plugin/article/public/template.html'), $PluginArticle->toArray(), null, '')->rawBody();
$path = public_path('article/' . $id . '.html');
file_put_contents($path, $html);
if ($PluginArticle->alias) {
$path = public_path('article/' . $PluginArticle->alias . '.html');
file_put_contents($path, $html);
}
}
public function cache(Request $request)
{
$id = $request->post('id');
$this->cacheHtml($id);
return $this->success('缓存成功');
}
}
@@ -0,0 +1,301 @@
<?php
namespace plugin\article\app\admin\controller;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\Examine;
use app\expose\enum\State;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleClassify;
use support\Request;
use think\facade\Db;
class ClassifyController extends Basic
{
public function __construct()
{
$this->model = new PluginArticleClassify();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder([
'rowKey' => 'id',
'api' => $this->plugin.'admin/Classify/index',
'lazy' => true,
'treeProps' => [
'children' => 'children',
'hasChildren' => 'hasChildren'
]
]);
$builder->addAction('操作', [
'width' => '160px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'path' => $this->plugin . 'admin/Classify/update',
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('删除', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'admin/Classify/delete',
'props' => [
'type' => 'danger',
'title' => '确定要删除《{title}》分类吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'danger',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('新建分类', [
'path' => $this->plugin . 'admin/Classify/create',
'props' => [
'type' => 'success',
'title' => '新建分类'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder();
$formBuilder->add('title', '标题', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'placeholder' => '标题搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '80px'
]
]);
$builder->add('title', '标题', [
'props' => [
'minWidth' => '200px'
]
]);
$builder->add('alias', '别名', [
'props' => [
'width' => '200px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => $this->plugin . 'admin/Classify/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '160px'
]
]);
$builder->add('sort', '排序', [
'component' => [
'name' => 'input-number',
'api' => $this->plugin . 'admin/Classify/indexUpdateField',
'props' => [
'min' => 0,
'size'=>'small'
]
],
'props' => [
'width' => '200px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$id = $request->get('id');
if ($id) {
$where[] = ['pid', '=', $id];
} else {
$where[] = ['pid', '=', NULL];
}
$state = $request->get('state');
if ($state) {
$where[] = ['state', '=', $state];
}
$list = PluginArticleClassify::where($where)
->order('id desc')->paginate($limit)->each(function ($item) {
$item->hasChildren = PluginArticleClassify::where(['pid' => $item->id])->count() > 0;
});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
Db::startTrans();
try {
$PluginArticleClassify = new PluginArticleClassify;
if($D['pid']){
$PluginArticleClassify->pid = $D['pid'];
}
$PluginArticleClassify->title = $D['title'];
$PluginArticleClassify->alias = $D['alias'];
$PluginArticleClassify->sort = $D['sort'];
$PluginArticleClassify->state = $D['state'];
$PluginArticleClassify->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
Db::startTrans();
try {
$PluginArticleClassify = PluginArticleClassify::where(['id' => $D['id']])->find();
if($D['pid']){
$PluginArticleClassify->pid = $D['pid'];
}else{
$PluginArticleClassify->pid = null;
}
$PluginArticleClassify->title = $D['title'];
$PluginArticleClassify->alias = $D['alias'];
$PluginArticleClassify->sort = $D['sort'];
$PluginArticleClassify->state = $D['state'];
$PluginArticleClassify->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('编辑成功');
}
$id = $request->get('id');
$PluginArticleClassify = PluginArticleClassify::where(['id' => $id])->find();
$builder = $this->getFormBuilder();
$builder->setData($PluginArticleClassify->toArray());
return $this->resData($builder);
}
public function getFormBuilder()
{
$builder = new FormBuilder(null,null,['size'=>'large']);
$builder->add('pid', '分类等级', 'cascader', '', [
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('alias', '别名', 'input', '', [
'col'=>[
'xs'=>24,
'md'=>12
],
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('sort', '排序', 'input-number', 99, [
'required' => true,
'col'=>[
'xs'=>24,
'md'=>12
],
'props' => [
'min' => 0,
'controls'=>false
]
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'required' => true,
'options' => State::getOptions(),
'subProps' => [
'border' => true
]
]);
return $builder;
}
public function delete(Request $request)
{
$id=$request->post('id');
$PluginArticleClassify = PluginArticleClassify::where(['id' => $id])->find();
if(!$PluginArticleClassify){
return $this->fail('分类不存在');
}
if(PluginArticleClassify::where(['pid' => $id])->count()){
return $this->fail('请先删除子分类');
}
if(PluginArticle::where(['classify_id' => $id])->count()){
return $this->fail('请先删除该分类下的文章');
}
if($PluginArticleClassify->delete()){
return $this->success('删除成功');
}
return $this->fail('删除失败');
}
}
@@ -0,0 +1,544 @@
<?php
namespace plugin\article\app\admin\controller;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\Examine;
use app\expose\enum\State;
use app\expose\helper\Config;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleClassify;
use plugin\article\app\model\PluginArticleContent;
use plugin\article\app\validate\Article;
use support\Request;
use think\facade\Db;
class IndexController extends Basic
{
public function __construct()
{
$this->model = new PluginArticle();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder();
$builder->addAction('操作', [
'width' => '220px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'path' => $this->plugin . 'admin/Index/update',
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('缓存', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'admin/Index/cache',
'props' => [
'type' => 'warning',
'title' => '确定要重新缓存《{title}》文章吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'warning',
'size' => 'small'
]
]
]);
$builder->addTableAction('删除', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'admin/Index/delete',
'props' => [
'type' => 'danger',
'title' => '确定要删除《{title}》文章吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'danger',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('发布文章', [
'path' => $this->plugin . 'admin/Index/create',
'props' => [
'type' => 'success',
'title' => '发布文章'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder();
$formBuilder->add('title', '标题', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'placeholder' => '标题搜索',
'clearable' => true
]
]);
$formBuilder->add('classify_id', '分类等级', 'cascader', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$formBuilder->add('state', '状态', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'options' => State::getOptions(),
'props' => [
'placeholder' => '状态搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '80px'
]
]);
$builder->add('classify_title', '分类', [
'props' => [
'width' => '120px'
]
]);
$builder->add('title', '标题', [
'props' => [
'minWidth' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'title',
'label' => '标题',
'component' => 'text',
'props' => [
'type' => 'primary',
'size' => 'small'
]
],
[
'field' => 'subtitle',
'label' => '副标题',
'component' => 'text',
'props' => [
'type' => 'info',
'size' => 'small'
]
]
]
]
]
]);
$builder->add('alias', '别名', [
'props' => [
'width' => '200px'
]
]);
$builder->add('view', '浏览量', [
'props' => [
'width' => '100px'
]
]);
$builder->add('source', '来源', [
'props' => [
'width' => '100px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => $this->plugin . 'admin/Index/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '160px'
]
]);
$builder->add('sort', '排序', [
'component' => [
'name' => 'input-number',
'api' => $this->plugin . 'admin/Index/indexUpdateField',
'props' => [
'min' => 0,
'size'=>'small'
]
],
'props' => [
'width' => '180px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
],
[
'field' => 'release_time',
'label' => '发布'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$title = $request->get('title');
if ($title) {
$where[] = ['a.title', 'like', "%{$title}%"];
}
$classify_id = $request->get('classify_id');
if ($classify_id) {
$where[] = ['a.classify_id', '=', $classify_id];
}
$state = $request->get('state');
if ($state) {
$where[] = ['a.state', '=', $state];
}
$where[] = ['a.examine', '=', Examine::PASS['value']];
$list = PluginArticle::alias('a')->where($where)
->join('plugin_article_classify c', 'c.id = a.classify_id','LEFT')
->field('a.*,c.title as classify_title')
->order('a.id desc')->paginate($limit)->each(function ($item) {
});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('create')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = new PluginArticle;
$PluginArticle->pid = $D['pid'];
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->keywords = $D['keywords'];
$PluginArticle->description = $D['description'];
$PluginArticle->alias = $D['alias'];
$PluginArticle->view = $D['view'];
$PluginArticle->sort = $D['sort'];
$PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->examine = Examine::PASS['value'];
if($D['release_time']){
$PluginArticle->release_time = $D['release_time'];
}else{
$PluginArticle->release_time = date('Y-m-d H:i:s');
}
$PluginArticle->save();
$PluginArticleContent = new PluginArticleContent;
$PluginArticleContent->article_id = $PluginArticle->id;
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
$this->cacheHtml($PluginArticle->id);
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('update')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = PluginArticle::where(['id' => $D['id']])->find();
$PluginArticle->pid = $D['pid'];
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->keywords = $D['keywords'];
$PluginArticle->description = $D['description'];
$PluginArticle->alias = $D['alias'];
$PluginArticle->view = $D['view'];
$PluginArticle->sort = $D['sort'];
$PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->release_time = $D['release_time'];
$PluginArticle->save();
$PluginArticleContent = PluginArticleContent::where(['article_id' => $D['id']])->find();
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('编辑成功');
}
$id = $request->get('id');
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c','c.article_id=a.id')->field('a.*,c.content')->find();
$builder = $this->getFormBuilder();
$builder->setData($PluginArticle->toArray());
return $this->resData($builder);
}
public function getFormBuilder()
{
$builder = new FormBuilder(null,null,['size'=>'large']);
$Component = new ComponentBuilder;
$builder->add('classify_id', '所属分类', 'cascader', '', [
'required' => true,
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('subtitle', '副标题', 'input', '', [
'props' => [
'maxlength' => 200,
'show-word-limit' => true
]
]);
$builder->add('thumb', '封面', 'bundle', [], [
'props' => [
'accept' => 'image/*',
'multiple' => 5
]
]);
$builder->add('keywords', '关键词', 'input', '', [
'props' => [
'type' => 'textarea',
'maxlength' => 200,
'show-word-limit' => true,
'autosize' => [
'minRows' => 2,
'maxRows' => 4
]
]
]);
$builder->add('description', '描述', 'input', '', [
'props' => [
'type' => 'textarea',
'maxlength' => 300,
'show-word-limit' => true,
'autosize' => [
'minRows' => 3,
'maxRows' => 6
]
]
]);
$builder->add('alias', '别名', 'input', '', [
'col'=>[
'xs'=>24,
'md'=>12
],
'prompt'=>[
$Component->add('text',['default'=>'设置别名后可通过别名访问文章'],['type'=>'info','size'=>'small'])->builder()
],
'props' => [
'maxlength' => 30,
'show-word-limit' => true
]
]);
$builder->add('view', '浏览量', 'input-number', 0, [
'col'=>[
'xs'=>24,
'md'=>6
],
'props' => [
'min' => 0,
'controls'=>false
]
]);
$builder->add('sort', '排序', 'input-number', 99, [
'col'=>[
'xs'=>24,
'md'=>6
],
'props' => [
'min' => 0,
'controls'=>false
]
]);
$builder->add('source', '来源名称', 'input', '', [
'prompt'=>[
$Component->add('text',['default'=>'为空则自动读取网站应用名称'],['type'=>'info','size'=>'small'])->builder()
],
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'required' => true,
'options' => State::getOptions(),
'subProps'=>[
'border'=>true
]
]);
$builder->add('release_time', '发布时间', 'date-picker', null, [
'prompt' => [
$Component->add('text',['default'=>'为空则自动写入当前时间'],['type'=>'info','size'=>'small'])->builder()
],
'props' => [
'type' => 'datetime',
'format' => 'YYYY-MM-DD HH:mm:ss',
'value-format' => 'YYYY-MM-DD HH:mm:ss',
'placeholder' => '发布时间'
]
]);
$builder->add('content', '内容', 'wangeditor', '', [
'required' => true,
'props' => [
'class' => 'vh-60'
]
]);
return $builder;
}
public function indexUpdateState(Request $request)
{
$id = $request->post('id');
$field = $request->post('field');
$value = $request->post('value');
$model = $this->model->where(['id' => $id])->find();
if (!$model) {
return $this->fail('数据不存在');
}
$model->{$field} = $value;
if ($model->save()) {
try {
if($value===State::NO['value']){
$this->clearHtml($id);
}else{
$this->cacheHtml($id);
}
} catch (\Throwable $th) {
}
return $this->success();
}
return $this->fail('操作失败');
}
public function clearHtml($id)
{
$PluginArticle=PluginArticle::where(['id'=>$id])->find();
$path = public_path('article/'.$id.'.html');
if(file_exists($path)){
unlink($path);
}
if($PluginArticle->alias){
$path = public_path('article/'.$PluginArticle->alias.'.html');
if(file_exists($path)){
unlink($path);
}
}
}
public function cacheHtml($id)
{
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c','c.article_id=a.id')->field('a.*,c.content')->find();
$config=new Config('basic','');
if(!$PluginArticle->source){
$PluginArticle->source = $config['web_name'];
}
if($config['logo_use']=='image'){
$PluginArticle->web_logo=$config['web_logo_light'];
}else{
$PluginArticle->web_logo='/vite.svg';
}
$PluginArticle->web_title="{$PluginArticle->title} - {$config['web_title']}";
$html=view(base_path('plugin/article/public/template.html'),$PluginArticle->toArray(),null,'')->rawBody();
$path = public_path('article/'.$id.'.html');
file_put_contents($path, $html);
if($PluginArticle->alias){
$path = public_path('article/'.$PluginArticle->alias.'.html');
file_put_contents($path, $html);
}
}
public function cache(Request $request)
{
$id = $request->post('id');
$this->cacheHtml($id);
return $this->success('缓存成功');
}
}
@@ -0,0 +1,9 @@
<?php
namespace plugin\article\app\admin\middleware;
use app\expose\middleware\AdminAuth;
class Auth extends AdminAuth
{
}
@@ -0,0 +1,38 @@
<?php
namespace plugin\article\app\api\controller;
use app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleContent;
use support\Request;
class ArticleController extends Basic
{
protected $notNeedLogin = ['index', 'details'];
public function index(Request $request)
{
$alias = $request->get('key');
$article = PluginArticle::where(['alias' => $alias, 'channels_uid' => $request->channels_uid])->find();
if (!$article) {
return $this->resData('文章不存在');
}
$content = PluginArticleContent::where(['article_id' => $article->id])->find();
return $this->success('获取成功', $content->content);
}
public function details(Request $request)
{
$id = $request->get('id');
if (!$id) {
return $this->fail('文章ID不能为空');
}
$article = PluginArticle::where(['id' => $id, 'channels_uid' => $request->channels_uid])->with('content')->find();
if (!$article) {
$article = PluginArticle::where(['alias' => $id, 'channels_uid' => $request->channels_uid])->with('content')->find();
}
if (!$article) {
return $this->fail('文章不存在');
}
return $this->success('获取成功', $article);
}
}
@@ -0,0 +1,177 @@
<?php
namespace plugin\article\app\control\controller;
use app\expose\build\builder\FormBuilder;
use app\expose\enum\SubmitEvent;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleContent;
use support\Request;
use app\expose\helper\Config;
class AgreementController extends Basic
{
public function privacy(Request $request)
{
$alias = 'privacy';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function user(Request $request)
{
$alias = 'user';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function guide(Request $request)
{
$alias = 'guide';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function help(Request $request)
{
$alias = 'help';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function points(Request $request)
{
$alias = 'points';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function terms(Request $request)
{
$alias = 'terms';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function about(Request $request)
{
$alias = 'about';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
public function cloning(Request $request)
{
$alias = 'cloning';
if ($request->method() === 'POST') {
return $this->saveAgreement($request->post(), $alias, $request->channels_uid);
}
return $this->showAgreementForm($alias);
}
protected function saveAgreement(array $data, string $alias, $channels_uid)
{
$article = PluginArticle::where(['alias' => $alias])->find();
if (!$article) {
$article = new PluginArticle;
$article->alias = $alias;
$article->channels_uid = $channels_uid;
}
$article->title = $data['title'];
$article->save();
$content = PluginArticleContent::where(['article_id' => $article->id])->find();
if (!$content) {
$content = new PluginArticleContent;
$content->article_id = $article->id;
}
$content->content = $data['content'];
$result = $content->save();
$this->cacheHtml($article->id);
if ($result) {
return $this->success('保存成功1');
} else {
return $this->fail('保存失败');
}
}
protected function showAgreementForm(string $alias)
{
$builder = $this->getFormBuilder($alias);
$article = PluginArticle::where('alias', $alias)->find();
if ($article) {
$content = PluginArticleContent::where('article_id', $article->id)->find();
$article->content = $content->content ?? '';
$builder->setData($article->toArray());
}
return $this->resData($builder);
}
protected function getFormBuilder(string $alias)
{
$builder = new FormBuilder(null, null, ['size' => 'large','submitEvent' => SubmitEvent::SILENT]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('alias', '名称', 'input', $alias, [
'props' => [
'disabled' => true
]
]);
$builder->add('content', '内容', 'wangeditor', '', [
'required' => true,
'props' => [
'class' => 'vh-60'
]
]);
return $builder;
}
public function cacheHtml($id)
{
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c', 'c.article_id=a.id')->field('a.*,c.content')->find();
$config = new Config('basic', '');
if (!$PluginArticle->source) {
$PluginArticle->source = $config['web_name'];
}
if ($config['logo_use'] == 'image') {
$PluginArticle->web_logo = $config['web_logo_light'];
} else {
$PluginArticle->web_logo = '/vite.svg';
}
$PluginArticle->web_title = "{$PluginArticle->title} - {$config['web_title']}";
$html = view(base_path('plugin/article/public/template.html'), $PluginArticle->toArray(), null, '')->rawBody();
$path = public_path('article/' . $id . '.html');
file_put_contents($path, $html);
if ($PluginArticle->alias) {
$path = public_path('article/' . $PluginArticle->alias . '.html');
file_put_contents($path, $html);
}
}
}
@@ -0,0 +1,670 @@
<?php
namespace plugin\article\app\control\controller;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\Examine;
use app\expose\enum\State;
use app\expose\enum\SubmitEvent;
use app\expose\helper\Config;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleClassify;
use plugin\article\app\model\PluginArticleContent;
use plugin\article\app\validate\Article;
use plugin\article\utils\enum\CrowdEnum;
use plugin\notification\app\model\PluginNotificationMessage;
use plugin\notification\app\model\PluginNotificationMessageContent;
use plugin\notification\expose\helper\Message;
use plugin\notification\utils\enum\MessageScene;
use plugin\user\app\model\PluginUser;
use support\Log;
use support\Request;
use think\facade\Db;
class AnnouncementController extends Basic
{
public function __construct()
{
$this->model = new PluginArticle();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder();
$builder->addAction('操作', [
'width' => '220px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'path' => $this->plugin . 'control/Announcement/update',
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('缓存', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'control/Announcement/cache',
'props' => [
'type' => 'warning',
'title' => '确定要重新缓存《{title}》公告吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'warning',
'size' => 'small'
]
]
]);
$builder->addTableAction('删除', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'control/Announcement/delete',
'props' => [
'type' => 'danger',
'title' => '确定要删除《{title}》公告吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'danger',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('发布公告', [
'path' => $this->plugin . 'control/Announcement/create',
'props' => [
'type' => 'success',
'title' => '发布公告'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder();
$formBuilder->add('title', '标题', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'placeholder' => '标题搜索',
'clearable' => true
]
]);
$formBuilder->add('state', '状态', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'options' => State::getOptions(),
'props' => [
'placeholder' => '状态搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '80px'
]
]);
$builder->add('title', '标题', [
'props' => [
'minWidth' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'title',
'label' => '标题',
'component' => 'text',
'props' => [
'type' => 'primary',
'size' => 'small'
]
],
[
'field' => 'subtitle',
'label' => '副标题',
'component' => 'text',
'props' => [
'type' => 'info',
'size' => 'small'
]
]
]
]
]
]);
$builder->add('alias', '别名', [
'props' => [
'width' => '200px'
]
]);
$builder->add('view', '浏览量', [
'props' => [
'width' => '100px'
]
]);
$builder->add('source', '来源', [
'props' => [
'width' => '100px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => $this->plugin . 'control/Announcement/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '160px'
]
]);
$builder->add('sort', '排序', [
'component' => [
'name' => 'input-number',
'api' => $this->plugin . 'control/Announcement/indexUpdateField',
'props' => [
'min' => 0,
'size' => 'small'
]
],
'props' => [
'width' => '180px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
],
[
'field' => 'release_time',
'label' => '发布'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$title = $request->get('title');
if ($title) {
$where[] = ['a.title', 'like', "%{$title}%"];
}
$where[] = ['a.alias', '=', 'announcement'];
$state = $request->get('state');
if ($state) {
$where[] = ['a.state', '=', $state];
}
$where[] = ['a.examine', '=', Examine::PASS['value']];
$list = PluginArticle::alias('a')->where($where)
->join('plugin_article_classify c', 'c.id = a.classify_id', 'LEFT')
->field('a.*,c.title as classify_title')
->order('a.id desc')->paginate($limit)->each(function ($item) {});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('create')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = new PluginArticle;
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->channels_uid = $request->channels_uid;
// $PluginArticle->keywords = $D['keywords'];
// $PluginArticle->description = $D['description'];
$PluginArticle->alias = 'announcement';
// $PluginArticle->view = $D['view'];
// $PluginArticle->sort = $D['sort'];
// $PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->push_crowd = $D['push_crowd'];
$PluginArticle->push_crowd_uids = $D['push_crowd_uids'];
$PluginArticle->examine = Examine::PASS['value'];
if ($D['release_time']) {
$PluginArticle->release_time = $D['release_time'];
} else {
$PluginArticle->release_time = date('Y-m-d H:i:s');
}
$PluginArticle->save();
$PluginArticleContent = new PluginArticleContent;
$PluginArticleContent->article_id = $PluginArticle->id;
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
$this->cacheHtml($PluginArticle->id);
// 发送通知消息
$this->sendNotification($PluginArticle, $D['content'], $request);
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('update')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = PluginArticle::where(['id' => $D['id']])->find();
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
// $PluginArticle->keywords = $D['keywords'];
// $PluginArticle->description = $D['description'];
// $PluginArticle->view = $D['view'];
// $PluginArticle->sort = $D['sort'];
// $PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
// $PluginArticle->release_time = $D['release_time'];
$PluginArticle->push_crowd = $D['push_crowd'];
$PluginArticle->push_crowd_uids = $D['push_crowd_uids'];
$PluginArticle->save();
$PluginArticleContent = PluginArticleContent::where(['article_id' => $D['id']])->find();
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
// 同步更新通知消息
$this->sendNotification($PluginArticle, $D['content'], $request, true);
return $this->success('编辑成功');
}
$id = $request->get('id');
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c', 'c.article_id=a.id')->field('a.*,c.content')->find();
$builder = $this->getFormBuilder();
$builder->setData($PluginArticle->toArray());
return $this->resData($builder);
}
public function getFormBuilder()
{
$builder = new FormBuilder(null, null, ['size' => 'large', 'submitEvent' => SubmitEvent::SILENT]);
$Component = new ComponentBuilder;
$builder->add('classify_id', '所属分类', 'cascader', '', [
'required' => true,
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$builder->add('push_crowd', '受众', 'select', '', [
'options' => CrowdEnum::getOptions(),
'props' => [
'clearable' => true
]
]);
$builder->add('push_crowd_uids', '受众用户', 'select', '', [
'remote' => [
'url' => $this->plugin . 'control/Announcement/getUser',
],
'props' => [
'clearable' => true,
'filterable' => true,
'multiple' => true,
'remote' => true
],
'where' => [
['push_crowd', '=', CrowdEnum::SPECIFIED['value']]
]
]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('subtitle', '副标题', 'input', '', [
'props' => [
'maxlength' => 200,
'show-word-limit' => true
]
]);
$builder->add('thumb', '封面', 'bundle', [], [
'props' => [
'accept' => 'image/*',
'multiple' => 5
]
]);
$builder->add('sort', '排序', 'input-number', 99, [
'col' => [
'xs' => 24,
'md' => 6
],
'props' => [
'min' => 0,
'controls' => false
]
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'required' => true,
'options' => State::getOptions(),
'subProps' => [
'border' => true
]
]);
$builder->add('release_time', '发布时间', 'date-picker', null, [
'prompt' => [
$Component->add('text', ['default' => '为空则自动写入当前时间'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'type' => 'datetime',
'format' => 'YYYY-MM-DD HH:mm:ss',
'value-format' => 'YYYY-MM-DD HH:mm:ss',
'placeholder' => '发布时间'
]
]);
$builder->add('content', '内容', 'wangeditor', '', [
'required' => true,
'props' => [
'class' => 'vh-60'
]
]);
return $builder;
}
public function indexUpdateState(Request $request)
{
$id = $request->post('id');
$field = $request->post('field');
$value = $request->post('value');
$model = $this->model->where(['id' => $id])->find();
if (!$model) {
return $this->fail('数据不存在');
}
$model->{$field} = $value;
if ($model->save()) {
try {
if ($value === State::NO['value']) {
$this->clearHtml($id);
} else {
$this->cacheHtml($id);
}
} catch (\Throwable $th) {
}
return $this->success();
}
return $this->fail('操作失败');
}
public function clearHtml($id)
{
$PluginArticle = PluginArticle::where(['id' => $id])->find();
$path = public_path('article/' . $id . '.html');
if (file_exists($path)) {
unlink($path);
}
if (isset($PluginArticle->alias) && $PluginArticle->alias) {
$path = public_path('article/' . $PluginArticle->alias . '.html');
if (file_exists($path)) {
unlink($path);
}
}
}
public function cacheHtml($id)
{
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c', 'c.article_id=a.id')->field('a.*,c.content')->find();
$config = new Config('basic', '');
if (!$PluginArticle->source) {
$PluginArticle->source = $config['web_name'];
}
if ($config['logo_use'] == 'image') {
$PluginArticle->web_logo = $config['web_logo_light'];
} else {
$PluginArticle->web_logo = '/vite.svg';
}
$PluginArticle->web_title = "{$PluginArticle->title} - {$config['web_title']}";
$html = view(base_path('plugin/article/public/template.html'), $PluginArticle->toArray(), null, '')->rawBody();
$path = public_path('article/' . $id . '.html');
file_put_contents($path, $html);
if ($PluginArticle->alias) {
$path = public_path('article/' . $PluginArticle->alias . '.html');
file_put_contents($path, $html);
}
}
public function cache(Request $request)
{
$id = $request->post('id');
$this->cacheHtml($id);
return $this->success('缓存成功');
}
/**
* 发送通知消息
* @param PluginArticle $PluginArticle 公告对象
* @param string $content 公告内容
* @param Request $request 请求对象
* @param bool $isUpdate 是否为更新操作,更新时会同步更新已存在的消息
*/
private function sendNotification($PluginArticle, $content, $request, $isUpdate = false)
{
$uids = [];
// 获取渠道ID
$channels_uid = $request->channels_uid ?? $PluginArticle->channels_uid ?? null;
// 根据推送受众类型获取用户ID列表
if ($PluginArticle->push_crowd == CrowdEnum::ALL['value']) {
// 全部用户
$where = [];
if ($channels_uid) {
$where[] = ['channels_uid', '=', $channels_uid];
}
$users = PluginUser::where($where)->field('id')->select();
foreach ($users as $user) {
$uids[] = $user->id;
}
} elseif ($PluginArticle->push_crowd == CrowdEnum::SPECIFIED['value']) {
// 指定用户
if (!empty($PluginArticle->push_crowd_uids) && is_array($PluginArticle->push_crowd_uids)) {
$uids = $PluginArticle->push_crowd_uids;
}
}
var_dump($uids);
if (empty($uids)) {
return;
}
// 获取当前管理员ID
$form_uid = $request->uid ?? null;
// 如果是更新操作,先获取已存在的消息
$existingMessages = [];
if ($isUpdate) {
$where = [
'form_id' => $PluginArticle->id,
'scene' => MessageScene::ANNOUNCEMENT['value']
];
if ($channels_uid) {
$where['channels_uid'] = $channels_uid;
}
$messages = PluginNotificationMessage::where($where)->select();
foreach ($messages as $message) {
$existingMessages[$message->uid] = $message;
}
}
// 为每个用户发送/更新通知
foreach ($uids as $uid) {
try {
// 如果是更新操作且消息已存在,则更新消息
if ($isUpdate && isset($existingMessages[$uid])) {
$message = $existingMessages[$uid];
// 更新消息基本信息
$message->title = $PluginArticle->title;
$message->subtitle = $PluginArticle->subtitle ?? null;
if ($form_uid) {
$message->form_uid = $form_uid;
}
$message->save();
// 更新消息内容
$messageContent = PluginNotificationMessageContent::where('message_id', $message->id)->find();
if ($messageContent) {
$messageContent->content = $content;
$messageContent->save();
} else {
// 如果内容不存在,创建新内容
$messageContent = new PluginNotificationMessageContent();
$messageContent->message_id = $message->id;
$messageContent->content = $content;
$messageContent->save();
}
} else {
// 创建新消息
$Message = new Message();
if ($channels_uid) {
$Message->setChannelsUid($channels_uid);
}
$Message->setUid($uid);
if ($form_uid) {
$Message->setFormUid($form_uid);
}
$Message->setFormId($PluginArticle->id);
$Message->setScene(MessageScene::ANNOUNCEMENT['value']);
$Message->setTitle($PluginArticle->title);
$Message->setContent($content);
if ($PluginArticle->subtitle) {
$Message->setSubtitle($PluginArticle->subtitle);
}
$Message->setEffect('info');
$Message->save();
}
} catch (\Throwable $th) {
// 记录错误但不中断流程
var_dump($th->getMessage());
continue;
}
}
// 如果是更新操作,删除不再需要的消息(用户列表变化的情况)
if ($isUpdate && !empty($existingMessages)) {
$currentUids = array_flip($uids);
foreach ($existingMessages as $uid => $message) {
// 如果该用户不在新的用户列表中,删除该消息
if (!isset($currentUids[$uid])) {
try {
PluginNotificationMessageContent::where('message_id', $message->id)->delete();
$message->delete();
} catch (\Throwable $th) {
var_dump($th->getMessage());
// 记录错误但不中断流程
continue;
}
}
}
}
}
/**
* 删除指定公告的所有通知消息
* @param int $articleId 公告ID
*/
private function deleteNotificationMessages($articleId)
{
try {
// 查找该公告相关的所有通知消息
$messages = PluginNotificationMessage::where([
'form_id' => $articleId,
'scene' => MessageScene::ANNOUNCEMENT['value']
])->select();
if ($messages) {
foreach ($messages as $message) {
// 删除消息内容
PluginNotificationMessageContent::where('message_id', $message->id)->delete();
// 删除消息
$message->delete();
}
}
} catch (\Throwable $th) {
// 记录错误但不中断流程
}
}
public function getUser(Request $request)
{
$keyword = $request->get('query');
$where = [];
$where[] = ['username|nickname|mobile', 'like', "%{$keyword}%"];
$list = PluginUser::field('id as value,nickname as label')->where($where)->select();
return $this->resData($list->toArray());
}
public function delete(Request $request)
{
$id = $request->post('id');
$PluginArticle = PluginArticle::where(['id' => $id])->find();
if (!$PluginArticle) {
return $this->fail('数据不存在');
}
$PluginArticle->delete();
$this->clearHtml($id);
$this->deleteNotificationMessages($id);
return $this->success('删除成功');
}
}
@@ -0,0 +1,312 @@
<?php
namespace plugin\article\app\control\controller;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\Examine;
use app\expose\enum\State;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleClassify;
use support\Request;
use think\facade\Db;
class ClassifyController extends Basic
{
public function __construct()
{
$this->model = new PluginArticleClassify();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder([
'rowKey' => 'id',
'api' => $this->plugin . 'control/Classify/index',
'lazy' => true,
'treeProps' => [
'children' => 'children',
'hasChildren' => 'hasChildren'
]
]);
$builder->addAction('操作', [
'width' => '160px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'path' => $this->plugin . 'control/Classify/update',
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('删除', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'control/Classify/delete',
'props' => [
'type' => 'danger',
'title' => '确定要删除《{title}》分类吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'danger',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('新建分类', [
'path' => $this->plugin . 'control/Classify/create',
'props' => [
'type' => 'success',
'title' => '新建分类'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder();
$formBuilder->add('title', '标题', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'placeholder' => '标题搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '80px'
]
]);
$builder->add('title', '标题', [
'props' => [
'minWidth' => '200px'
]
]);
$builder->add('alias', '别名', [
'props' => [
'width' => '200px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => $this->plugin . 'control/Classify/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '160px'
]
]);
$builder->add('sort', '排序', [
'component' => [
'name' => 'input-number',
'api' => $this->plugin . 'control/Classify/indexUpdateField',
'props' => [
'min' => 0,
'size' => 'small'
]
],
'props' => [
'width' => '200px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$id = $request->get('id');
if ($id) {
$where[] = ['pid', '=', $id];
} else {
$where[] = ['pid', '=', NULL];
}
$state = $request->get('state');
if ($state) {
$where[] = ['state', '=', $state];
}
$list = PluginArticleClassify::where($where)
->order('id desc')->paginate($limit)->each(function ($item) {
$item->hasChildren = PluginArticleClassify::where(['pid' => $item->id])->count() > 0;
});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
if ($D['alias']) {
$count = PluginArticleClassify::where('alias', $D['alias'])->count();
if ($count) {
return $this->fail('别名不能重复');
}
}
Db::startTrans();
try {
$PluginArticleClassify = new PluginArticleClassify;
if ($D['pid']) {
$PluginArticleClassify->pid = $D['pid'];
}
$D['channels_uid'] = $request->channels_uid;
$PluginArticleClassify->title = $D['title'];
if ($D['alias']) {
$PluginArticleClassify->alias = $D['alias'];
}
$PluginArticleClassify->sort = $D['sort'];
$PluginArticleClassify->state = $D['state'];
$PluginArticleClassify->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
Db::startTrans();
try {
$PluginArticleClassify = PluginArticleClassify::where(['id' => $D['id']])->find();
if ($D['pid']) {
$PluginArticleClassify->pid = $D['pid'];
} else {
$PluginArticleClassify->pid = null;
}
$PluginArticleClassify->title = $D['title'];
if ($D['alias']) {
$PluginArticleClassify->alias = $D['alias'];
}
$PluginArticleClassify->sort = $D['sort'];
$PluginArticleClassify->state = $D['state'];
$PluginArticleClassify->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('编辑成功');
}
$id = $request->get('id');
$PluginArticleClassify = PluginArticleClassify::where(['id' => $id])->find();
$builder = $this->getFormBuilder();
$builder->setData($PluginArticleClassify->toArray());
return $this->resData($builder);
}
public function getFormBuilder()
{
$builder = new FormBuilder(null, null, ['size' => 'large']);
$builder->add('pid', '分类等级', 'cascader', '', [
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('alias', '别名', 'input', '', [
'col' => [
'xs' => 24,
'md' => 12
],
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('sort', '排序', 'input-number', 99, [
'required' => true,
'col' => [
'xs' => 24,
'md' => 12
],
'props' => [
'min' => 0,
'controls' => false
]
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'required' => true,
'options' => State::getOptions(),
'subProps' => [
'border' => true
]
]);
return $builder;
}
public function delete(Request $request)
{
$id = $request->post('id');
$PluginArticleClassify = PluginArticleClassify::where(['id' => $id])->find();
if (!$PluginArticleClassify) {
return $this->fail('分类不存在');
}
if (PluginArticleClassify::where(['pid' => $id])->count()) {
return $this->fail('请先删除子分类');
}
if (PluginArticle::where(['classify_id' => $id])->count()) {
return $this->fail('请先删除该分类下的文章');
}
if ($PluginArticleClassify->delete()) {
return $this->success('删除成功');
}
return $this->fail('删除失败');
}
}
@@ -0,0 +1,545 @@
<?php
namespace plugin\article\app\control\controller;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\Examine;
use app\expose\enum\State;
use app\expose\helper\Config;
use plugin\article\app\Basic;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleClassify;
use plugin\article\app\model\PluginArticleContent;
use plugin\article\app\validate\Article;
use support\Request;
use think\facade\Db;
class IndexController extends Basic
{
public function __construct()
{
$this->model = new PluginArticle();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder();
$builder->addAction('操作', [
'width' => '220px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'path' => $this->plugin . 'control/Index/update',
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('缓存', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'control/Index/cache',
'props' => [
'type' => 'warning',
'title' => '确定要重新缓存《{title}》文章吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'warning',
'size' => 'small'
]
]
]);
$builder->addTableAction('删除', [
'model' => Action::COMFIRM['value'],
'path' => $this->plugin . 'control/Index/delete',
'props' => [
'type' => 'danger',
'title' => '确定要删除《{title}》文章吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'danger',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('发布文章', [
'path' => $this->plugin . 'control/Index/create',
'props' => [
'type' => 'success',
'title' => '发布文章'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder();
$formBuilder->add('title', '标题', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'placeholder' => '标题搜索',
'clearable' => true
]
]);
$formBuilder->add('classify_id', '分类等级', 'cascader', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$formBuilder->add('state', '状态', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 12,
'md' => 8,
'lg' => 6,
'xl' => 4
],
'options' => State::getOptions(),
'props' => [
'placeholder' => '状态搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '80px'
]
]);
$builder->add('classify_title', '分类', [
'props' => [
'width' => '120px'
]
]);
$builder->add('title', '标题', [
'props' => [
'minWidth' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'title',
'label' => '标题',
'component' => 'text',
'props' => [
'type' => 'primary',
'size' => 'small'
]
],
[
'field' => 'subtitle',
'label' => '副标题',
'component' => 'text',
'props' => [
'type' => 'info',
'size' => 'small'
]
]
]
]
]
]);
$builder->add('alias', '别名', [
'props' => [
'width' => '200px'
]
]);
$builder->add('view', '浏览量', [
'props' => [
'width' => '100px'
]
]);
$builder->add('source', '来源', [
'props' => [
'width' => '100px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => $this->plugin . 'control/Index/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '160px'
]
]);
$builder->add('sort', '排序', [
'component' => [
'name' => 'input-number',
'api' => $this->plugin . 'control/Index/indexUpdateField',
'props' => [
'min' => 0,
'size'=>'small'
]
],
'props' => [
'width' => '180px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
],
[
'field' => 'release_time',
'label' => '发布'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$title = $request->get('title');
if ($title) {
$where[] = ['a.title', 'like', "%{$title}%"];
}
$classify_id = $request->get('classify_id');
if ($classify_id) {
$where[] = ['a.classify_id', '=', $classify_id];
}
$state = $request->get('state');
if ($state) {
$where[] = ['a.state', '=', $state];
}
$where[] = ['a.examine', '=', Examine::PASS['value']];
$list = PluginArticle::alias('a')->where($where)
->join('plugin_article_classify c', 'c.id = a.classify_id','LEFT')
->field('a.*,c.title as classify_title')
->order('a.id desc')->paginate($limit)->each(function ($item) {
});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$D['channels_uid'] = $request->channels_uid;
$validate = new Article;
try {
$validate->scene('create')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = new PluginArticle;
$PluginArticle->pid = $D['pid'];
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->keywords = $D['keywords'];
$PluginArticle->description = $D['description'];
$PluginArticle->alias = $D['alias'];
$PluginArticle->view = $D['view'];
$PluginArticle->sort = $D['sort'];
$PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->examine = Examine::PASS['value'];
if($D['release_time']){
$PluginArticle->release_time = $D['release_time'];
}else{
$PluginArticle->release_time = date('Y-m-d H:i:s');
}
$PluginArticle->save();
$PluginArticleContent = new PluginArticleContent;
$PluginArticleContent->article_id = $PluginArticle->id;
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
$this->cacheHtml($PluginArticle->id);
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new Article;
try {
$validate->scene('update')->check($D);
} catch (\Throwable $th) {
return $this->fail($th->getMessage());
}
Db::startTrans();
try {
$PluginArticle = PluginArticle::where(['id' => $D['id']])->find();
$PluginArticle->pid = $D['pid'];
$PluginArticle->title = $D['title'];
$PluginArticle->subtitle = $D['subtitle'];
$PluginArticle->thumb = $D['thumb'];
$PluginArticle->keywords = $D['keywords'];
$PluginArticle->description = $D['description'];
$PluginArticle->alias = $D['alias'];
$PluginArticle->view = $D['view'];
$PluginArticle->sort = $D['sort'];
$PluginArticle->source = $D['source'];
$PluginArticle->state = $D['state'];
$PluginArticle->release_time = $D['release_time'];
$PluginArticle->save();
$PluginArticleContent = PluginArticleContent::where(['article_id' => $D['id']])->find();
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
return $this->success('编辑成功');
}
$id = $request->get('id');
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c','c.article_id=a.id')->field('a.*,c.content')->find();
$builder = $this->getFormBuilder();
$builder->setData($PluginArticle->toArray());
return $this->resData($builder);
}
public function getFormBuilder()
{
$builder = new FormBuilder(null,null,['size'=>'large']);
$Component = new ComponentBuilder;
$builder->add('classify_id', '所属分类', 'cascader', '', [
'required' => true,
'props' => [
'options' => PluginArticleClassify::options(),
'clearable' => true,
'filterable' => true,
'props' => [
'checkStrictly' => true,
'emitPath' => false
]
]
]);
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('subtitle', '副标题', 'input', '', [
'props' => [
'maxlength' => 200,
'show-word-limit' => true
]
]);
$builder->add('thumb', '封面', 'bundle', [], [
'props' => [
'accept' => 'image/*',
'multiple' => 5
]
]);
$builder->add('keywords', '关键词', 'input', '', [
'props' => [
'type' => 'textarea',
'maxlength' => 200,
'show-word-limit' => true,
'autosize' => [
'minRows' => 2,
'maxRows' => 4
]
]
]);
$builder->add('description', '描述', 'input', '', [
'props' => [
'type' => 'textarea',
'maxlength' => 300,
'show-word-limit' => true,
'autosize' => [
'minRows' => 3,
'maxRows' => 6
]
]
]);
$builder->add('alias', '别名', 'input', '', [
'col'=>[
'xs'=>24,
'md'=>12
],
'prompt'=>[
$Component->add('text',['default'=>'设置别名后可通过别名访问文章'],['type'=>'info','size'=>'small'])->builder()
],
'props' => [
'maxlength' => 30,
'show-word-limit' => true
]
]);
$builder->add('view', '浏览量', 'input-number', 0, [
'col'=>[
'xs'=>24,
'md'=>6
],
'props' => [
'min' => 0,
'controls'=>false
]
]);
$builder->add('sort', '排序', 'input-number', 99, [
'col'=>[
'xs'=>24,
'md'=>6
],
'props' => [
'min' => 0,
'controls'=>false
]
]);
$builder->add('source', '来源名称', 'input', '', [
'prompt'=>[
$Component->add('text',['default'=>'为空则自动读取网站应用名称'],['type'=>'info','size'=>'small'])->builder()
],
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'required' => true,
'options' => State::getOptions(),
'subProps'=>[
'border'=>true
]
]);
$builder->add('release_time', '发布时间', 'date-picker', null, [
'prompt' => [
$Component->add('text',['default'=>'为空则自动写入当前时间'],['type'=>'info','size'=>'small'])->builder()
],
'props' => [
'type' => 'datetime',
'format' => 'YYYY-MM-DD HH:mm:ss',
'value-format' => 'YYYY-MM-DD HH:mm:ss',
'placeholder' => '发布时间'
]
]);
$builder->add('content', '内容', 'wangeditor', '', [
'required' => true,
'props' => [
'class' => 'vh-60'
]
]);
return $builder;
}
public function indexUpdateState(Request $request)
{
$id = $request->post('id');
$field = $request->post('field');
$value = $request->post('value');
$model = $this->model->where(['id' => $id])->find();
if (!$model) {
return $this->fail('数据不存在');
}
$model->{$field} = $value;
if ($model->save()) {
try {
if($value===State::NO['value']){
$this->clearHtml($id);
}else{
$this->cacheHtml($id);
}
} catch (\Throwable $th) {
}
return $this->success();
}
return $this->fail('操作失败');
}
public function clearHtml($id)
{
$PluginArticle=PluginArticle::where(['id'=>$id])->find();
$path = public_path('article/'.$id.'.html');
if(file_exists($path)){
unlink($path);
}
if($PluginArticle->alias){
$path = public_path('article/'.$PluginArticle->alias.'.html');
if(file_exists($path)){
unlink($path);
}
}
}
public function cacheHtml($id)
{
$PluginArticle = PluginArticle::alias('a')->where(['a.id' => $id])->join('plugin_article_content c','c.article_id=a.id')->field('a.*,c.content')->find();
$config=new Config('basic','');
if(!$PluginArticle->source){
$PluginArticle->source = $config['web_name'];
}
if($config['logo_use']=='image'){
$PluginArticle->web_logo=$config['web_logo_light'];
}else{
$PluginArticle->web_logo='/vite.svg';
}
$PluginArticle->web_title="{$PluginArticle->title} - {$config['web_title']}";
$html=view(base_path('plugin/article/public/template.html'),$PluginArticle->toArray(),null,'')->rawBody();
$path = public_path('article/'.$id.'.html');
file_put_contents($path, $html);
if($PluginArticle->alias){
$path = public_path('article/'.$PluginArticle->alias.'.html');
file_put_contents($path, $html);
}
}
public function cache(Request $request)
{
$id = $request->post('id');
$this->cacheHtml($id);
return $this->success('缓存成功');
}
}
@@ -0,0 +1,6 @@
<?php
/**
* Here is your custom functions.
*/
@@ -0,0 +1,42 @@
<?php
namespace plugin\article\app\model;
use app\model\Basic;
use think\model\concern\SoftDelete;
class PluginArticle extends Basic
{
use SoftDelete;
protected function getOptions(): array
{
return [
'type' => [
// 设置JSON字段的类型
'thumb' => 'json',
'push_crowd_uids' => 'json'
]
];
}
public function content()
{
return $this->hasOne(PluginArticleContent::class, 'article_id', 'id');
}
// public function getPushCrowdUidsAttr($value)
// {
// if (empty($value)) {
// return '';
// }
// return json_decode($value, true);
// }
// public function setPushCrowdUidsAttr($value)
// {
// if (empty($value)) {
// return '';
// }
// return json_encode($value, JSON_UNESCAPED_UNICODE);
// }
}
@@ -0,0 +1,33 @@
<?php
namespace plugin\article\app\model;
use app\model\Basic;
class PluginArticleClassify extends Basic
{
public static function options($pid=null)
{
if ($pid) {
$data = self::where(['pid' => $pid])->select();
} else {
$data = self::whereNull('pid')->select();
}
$options = [];
if ($data->isEmpty()) {
return $options;
}
foreach ($data as $item) {
$temp = [
'value' => $item->id,
'label' => $item->title
];
$children = self::options($item->id);
if (!empty($children)) {
$temp['children'] = $children;
}
$options[] = $temp;
}
return $options;
}
}
@@ -0,0 +1,10 @@
<?php
namespace plugin\article\app\model;
use app\model\Basic;
class PluginArticleContent extends Basic
{
// protected $pk='token_id';
}
@@ -0,0 +1,34 @@
<?php
namespace plugin\article\app\validate;
use app\expose\validate\Validate;
class Article extends Validate
{
protected $rule = [
'classify_id'=>'require',
'title'=>'require',
'subtitle'=>'length:0,200',
'thumb'=>'array',
'keywords'=>'length:0,200',
'description'=>'length:0,300',
'alias'=>'alphaDash|length:0,30',
'content'=>'require'
];
protected $message = [
'classify_id.require' => '请选择分类',
'title.require' => '请输入标题',
'subtitle.length' => '副标题长度不能超过200个字符',
'thumb.array' => '缩略图格式错误',
'keywords.length' => '关键词长度不能超过200个字符',
'description.length' => '描述长度不能超过300个字符',
'alias.alphaDash' => '别名只能是字母、数字、下划线和破折号',
'alias.length' => '别名长度不能超过30个字符',
'content.require' => '请输入内容'
];
protected $scene = [
'agreement' => ['title','alias','content'],
];
}
@@ -0,0 +1,9 @@
<?php
use support\Request;
return [
'debug' => true,
'controller_suffix' => 'Controller',
'controller_reuse' => false
];
@@ -0,0 +1,6 @@
<?php
return [
'files' => [
base_path() . '/plugin/article/app/functions.php',
]
];
@@ -0,0 +1,2 @@
<?php
return new Webman\Container;
@@ -0,0 +1,4 @@
<?php
return [
];
@@ -0,0 +1,5 @@
<?php
return [
'' => app\exception\Handler::class,
];
@@ -0,0 +1,20 @@
<?php
return [
'default' => [
'handlers' => [
[
'class' => Monolog\Handler\RotatingFileHandler::class,
'constructor' => [
runtime_path() . '/logs/article.log',
7,
Monolog\Logger::DEBUG,
],
'formatter' => [
'class' => Monolog\Formatter\LineFormatter::class,
'constructor' => [null, 'Y-m-d H:i:s', true],
],
]
],
],
];
@@ -0,0 +1,21 @@
<?php
return [
// 'admin' => [
// plugin\article\app\admin\middleware\Auth::class
// ]
'' => [
app\expose\middleware\Platform::class
],
'admin' => [
app\expose\middleware\AdminAuth::class
],
'control' => [
plugin\control\expose\middleware\ControlAuth::class
],
'api' => [
plugin\control\expose\middleware\DomainMapping::class,
plugin\user\expose\middleware\UserAuth::class,
plugin\user\expose\middleware\Twofa::class,
]
];
@@ -0,0 +1,11 @@
<?php
use plugin\article\process\JoinPushMessage;
use Workerman\Events\Select;
return [
'JoinPushMessage' => [
'eventLoop' => Select::class,
'handler' => JoinPushMessage::class
],
];
@@ -0,0 +1,6 @@
<?php
return [
'enable' => true,
'middleware' => [
],
];
@@ -0,0 +1,25 @@
<?php
/**
* This file is part of webman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Multilingual configuration
*/
return [
// Default language
'locale' => 'zh_CN',
// Fallback language
'fallback_locale' => ['zh_CN', 'en'],
// Folder where language files are stored
'path' => base_path() . '/plugin/article/resource/translations',
];
+154
View File
@@ -0,0 +1,154 @@
{
"title":"内容",
"icon":"Notebook",
"path":"/app/article/control",
"sort":4999,
"children":[
{
"title":"公告",
"icon":"BellFilled",
"path":"/app/article/control/Announcement/index",
"component":"table"
},
{
"title":"隐私政策",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/privacy",
"component":"form"
},
{
"title":"帮助中心",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/help",
"component":"form"
},
{
"title":"积分规则",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/points",
"component":"form"
},
{
"title":"用户协议",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/user",
"component":"form"
},
{
"title":"使用条款",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/terms",
"component":"form"
},
{
"title":"关于我们",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/about",
"component":"form"
},
{
"title":"使用指南",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/guide",
"component":"form",
"show":false
},
{
"title":"声音克隆协议",
"icon":"BellFilled",
"path":"/app/article/control/Agreement/cloning",
"component":"form",
"show":true
},
{
"title":"添加公告",
"path":"/app/article/control/Announcement/create",
"component":"form",
"show":false
},
{
"title":"编辑公告",
"path":"/app/article/control/Announcement/update",
"component":"form",
"show":false
},
{
"title":"文章列表",
"icon":"Notebook",
"path":"/app/article/control/Index/index",
"component":"table",
"show":false
},
{
"title":"添加文章",
"path":"/app/article/control/Index/create",
"component":"form",
"show":false
},
{
"title":"编辑文章",
"path":"/app/article/control/Index/update",
"component":"form",
"show":false
},
{
"title":"审核文章",
"path":"/app/article/control/Index/examine",
"component":"form",
"show":false
},
{
"title":"更新文章状态",
"path":"/app/article/control/Index/indexUpdateState",
"show":false
},
{
"title":"更新文章排序",
"path":"/app/article/control/Index/indexUpdateField",
"show":false
},
{
"title":"删除文章",
"path":"/app/article/control/Index/delete",
"show":false
},
{
"title":"缓存文章",
"path":"/app/article/control/Index/cache",
"show":false
},
{
"title":"文章分类",
"icon":"FolderOpened",
"path":"/app/article/control/Classify/index",
"component":"table"
},
{
"title":"添加分类",
"path":"/app/article/control/Classify/create",
"component":"form",
"show":false
},
{
"title":"编辑分类",
"path":"/app/article/control/Classify/update",
"component":"form",
"show":false
},
{
"title":"更新分类状态",
"path":"/app/article/control/Classify/indexUpdateState",
"show":false
},
{
"title":"更新分类排序",
"path":"/app/article/control/Classify/indexUpdateField",
"show":false
},
{
"title":"删除分类",
"path":"/app/article/control/Classify/delete",
"show":false
}
]
}
@@ -0,0 +1,88 @@
<?php
namespace plugin\article\expose\helper;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\enum\State;
use plugin\article\app\admin\controller\IndexController;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleContent;
use plugin\article\app\validate\Article as ValidateArticle;
use support\Request;
use think\facade\Db;
class Article extends IndexController
{
public function agreement(Request $request,$alias)
{
if ($request->method() == 'POST') {
$D = $request->post();
$validate = new ValidateArticle;
try {
$validate->scene('agreement')->check($D);
} catch (\Throwable $th) {
return $this->exception($th);
}
Db::startTrans();
try {
$PluginArticle = PluginArticle::where(['alias' => $alias])->find();
if (!$PluginArticle) {
$PluginArticle = new PluginArticle;
}
$PluginArticle->title = $D['title'];
$PluginArticle->alias = $D['alias'];
$PluginArticle->state = State::YES['value'];
$PluginArticle->release_time = date('Y-m-d H:i:s');
$PluginArticle->save();
$PluginArticleContent = PluginArticleContent::where(['article_id' => $PluginArticle->id])->find();
if (!$PluginArticleContent) {
$PluginArticleContent = new PluginArticleContent;
}
$PluginArticleContent->article_id = $PluginArticle->id;
$PluginArticleContent->content = $D['content'];
$PluginArticleContent->save();
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
return $this->fail($th->getMessage());
}
$this->cacheHtml($PluginArticle->id);
return $this->success('编辑成功');
}
$PluginArticle = PluginArticle::alias('a')->where(['a.alias' => $alias])->join('plugin_article_content c', 'c.article_id=a.id')->field('a.*,c.content')->find();
$builder = new FormBuilder(null, null, ['size' => 'large','submitEvent' => 'SILENT']);
$Component = new ComponentBuilder;
$builder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'maxlength' => 100,
'show-word-limit' => true
]
]);
$builder->add('alias', '别名', 'input', $alias, [
'col' => [
'xs' => 24,
'md' => 12
],
'prompt' => [
$Component->add('text', ['default' => '设置别名后可通过别名访问文章'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'maxlength' => 30,
'show-word-limit' => true,
'disabled' => true
]
]);
$builder->add('content', '内容', 'wangeditor', '', [
'required' => true,
'props' => [
'class' => 'vh-55'
]
]);
if($PluginArticle){
$builder->setData($PluginArticle->toArray());
}
return $this->resData($builder);
}
}
@@ -0,0 +1,12 @@
{
"name": "article",
"title": "文章系统",
"version": "0.0.1",
"description": "文章系统",
"author": {
"name": "余心",
"email": "unknown.renloong@gmail.com"
},
"plugin":{
}
}
@@ -0,0 +1,68 @@
<?php
namespace plugin\article\process;
use app\expose\enum\Examine;
use app\expose\enum\State;
use plugin\article\app\model\PluginArticle;
use plugin\article\app\model\PluginArticleContent;
use plugin\notification\app\model\PluginNotificationMessage;
use support\Log;
use support\think\Db;
use Workerman\Crontab\Crontab;
class JoinPushMessage
{
public function onWorkerStart()
{
new Crontab('*/5 * * * * *', function () {
try {
$where = [];
$where[] = ['state', '=', State::YES['value']];
$where[] = ['examine', '<', Examine::PASS['value']];
$where[] = ['release_time', '<=', date('Y-m-d H:i:s')];
$where[] = ['last_heartbeat', '<=', date('Y-m-d H:i:s')];
$where[] = ['push_state', '=', State::YES['value']];
$PluginArticle = PluginArticle::where($where)->find();
if (!$PluginArticle) {
return;
}
$content = '';
$PluginArticleContent = PluginArticleContent::where('article_id', $PluginArticle->id)->find();
if ($PluginArticleContent) {
$content = $PluginArticleContent->content;
}
Db::startTrans();
try {
$MessageData = [];
if (empty($PluginArticle->push_crowd_uids)) {
} else {
foreach ($PluginArticle->push_crowd_uids as $key => $value) {
$MessageData[] = [
'channels_uid' => $PluginArticle->channels_uid,
'uid' => $value,
'form_id' => $PluginArticle->id,
'scene' => $PluginArticle->alias,
'state' => State::YES['value'],
'title' => $PluginArticle->title,
'content' => $content,
];
}
$PluginArticle->push_state = State::YES['value'];
$PluginArticle->last_heartbeat = date('Y-m-d H:i:s');
$PluginArticle->push_people_num = count($PluginArticle->push_crowd_uids);
}
$PluginArticle->save();
$PluginNotificationMessage = new PluginNotificationMessage();
$PluginNotificationMessage->together(['content'=>['content']])->saveAll($MessageData);
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
Log::error("JoinPushMessage Process Error: " . $th->getMessage(), $th->getTrace());
}
} catch (\Throwable $th) {
Log::error("JoinPushMessage Process Error: " . $th->getMessage(), $th->getTrace());
}
});
}
}
@@ -0,0 +1,35 @@
html,body
{
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
font-size: 14px;
color: #333;
}
.title{
margin: 0 auto;
max-width: 1140px;
padding: 20px;
}
.info{
margin: 0 auto;
max-width: 1140px;
padding: 20px;
display: flex;
gap: 10px;
align-items: center;
}
.content{
margin: 0 auto;
max-width: 1140px;
padding: 20px;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar:horizontal { height: 6px; }
::-webkit-scrollbar-track { border-radius: 10px; }
::-webkit-scrollbar-thumb { background-color: #0003; border-radius: 10px; -webkit-transition: all .2s ease-in-out; transition: all .2s ease-in-out; }
::-webkit-scrollbar-thumb:hover { cursor: pointer; background-color: #0000004d; }
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="{$web_logo}">
<link rel="apple-touch-icon" href="{$web_logo}">
<link rel="apple-touch-icon-precomposed" href="{$web_logo}">
<title>{$web_title}</title>
<meta name="description" content="{$description}">
<meta name="keywords" content="{$keywords}">
<link rel="stylesheet" href="/app/article/static/index.css">
</head>
<body>
<div>
<h1 class="title">{$title}</h1>
<div class="info">
<span class="author">{$source}</span>
<span class="time">{$release_time}</span>
</div>
</div>
<div class="content">{$content|raw}</div>
</body>
</html>
@@ -0,0 +1,5 @@
<?php
return [
'success' => 'Success',
];
@@ -0,0 +1,5 @@
<?php
return [
'success' => '成功',
];
@@ -0,0 +1,25 @@
<?php
namespace plugin\article\utils\enum;
use app\expose\enum\builder\Enum;
class CrowdEnum extends Enum
{
const ALL = [
'label' => '全部',
'value' => 'all',
];
const SPECIFIED = [
'label' => '指定',
'value' => 'specified',
];
// const WEEK = [
// 'label' => '一周内',
// 'value' => 'week',
// ];
// const MONTH = [
// 'label' => '一个月',
// 'value' => 'month',
// ];
}