优化细节

This commit is contained in:
hdm 2021-07-08 11:52:46 +08:00
parent dabeea9fcb
commit 5ed3964b65
6 changed files with 38 additions and 27 deletions

View File

@ -51,7 +51,6 @@ class Article extends BaseController
if ($res) {
add_log('edit', $data['id'], $data);
}
return to_assign();
} else {
try {
@ -65,7 +64,6 @@ class Article extends BaseController
if ($insertId) {
add_log('add', $insertId, $param);
}
return to_assign();
}
}
@ -105,7 +103,7 @@ class Article extends BaseController
$where[] = ['a.status', '>=', 0];
$rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit'];
$content = ArticleList::where($where)
->field('*,w.id as cate_id,a.id as id,w.title as cate_title,a.title as title')
->field('a.*,w.id as cate_id,a.id as id,w.title as cate_title,a.title as title')
->alias('a')
->join('article_cate w', 'a.article_cate_id = w.id')
->order('a.create_time desc')
@ -144,7 +142,6 @@ class Article extends BaseController
return to_assign(0, $e->getError());
}
$param['update_time'] = time();
Db::startTrans();
try {
$res = ArticleList::strict(false)->field(true)->update($param);
@ -185,6 +182,9 @@ class Article extends BaseController
$param['create_time'] = time();
Db::startTrans();
try {
if(empty($param['desc'])){
$param['desc'] = getDescriptionFromContent($param['content'], 100);
}
$aid = ArticleList::strict(false)->field(true)->insertGetId($param);
if ($aid) {
if (isset($param['keyword_names']) && $param['keyword_names']) {

View File

@ -9,7 +9,7 @@
class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray2">分类<span style="color: red">*</span></td>
<td class="layui-td-gray2">文章分类<span style="color: red">*</span></td>
<td>
<select name="article_cate_id" lay-verify="required" lay-reqText="请选择分类">
<option value="">请选择分类</option>
@ -41,8 +41,8 @@
</td>
<td class="layui-td-gray2">首页显示</td>
<td>
<input type="radio" name="is_home" value="1" title="是">
<input type="radio" name="is_home" value="0" title="否" checked>
<input type="radio" name="is_home" value="1" title="是" checked>
<input type="radio" name="is_home" value="0" title="否">
</td>
<td class="layui-td-gray2">状态<span style="color: red">*</span></td>
<td>
@ -51,24 +51,29 @@
</td>
</tr>
<tr>
<td class="layui-td-gray2">文章来源</td>
<td class="layui-td-gray2">是否原创</td>
<td>
<input type="text" name="origin" class="layui-input" autocomplete="off" placeholder="请输入文章来源">
<input type="radio" name="original" value="1" title="是">
<input type="radio" name="original" value="0" title="否" checked>
</td>
<td class="layui-td-gray2">作者/来源</td>
<td>
<input type="text" name="origin" class="layui-input" autocomplete="off" placeholder="请输入文章作者或来源">
</td>
<td class="layui-td-gray2">来源链接</td>
<td colspan="3">
<td>
<input type="text" name="origin_url" class="layui-input" autocomplete="off" placeholder="请输入来源链接">
</td>
</tr>
<tr>
<td class="layui-td-gray2" style="vertical-align:top;">摘要</td>
<td class="layui-td-gray2" style="vertical-align:top;">文章摘要</td>
<td colspan="3">
<textarea name="desc" placeholder="请输入摘要不能超过200个字" class="layui-textarea"></textarea>
</td>
<td class="layui-td-gray2" style="vertical-align:top;">缩略图</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="test1">上传缩略图(尺寸:498x280</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="test1">上传缩略图(尺寸:240x136</button>
<div class="layui-upload-list" id="demo1" style="width: 120px; height:66px; overflow: hidden;">
<img src="" style="max-width: 100%; height:66px;" />
<input type="hidden" name="thumb" value="">
@ -77,7 +82,7 @@
</td>
</tr>
<tr>
<td class="layui-td-gray2" style="vertical-align:top;">内容<span style="color: red">*</span></td>
<td class="layui-td-gray2" style="vertical-align:top;">文章内容<span style="color: red">*</span></td>
<td colspan="5">
<textarea name="content" placeholder="请输入内容" class="layui-textarea" id="container" lay-verify="required" lay-reqText="请完善文章内容"
style="border:0;padding:0"></textarea>

View File

@ -10,7 +10,7 @@
class="layui-input" value="{$article.title}"></td>
</tr>
<tr>
<td class="layui-td-gray2">分类<span style="color: red">*</span></td>
<td class="layui-td-gray2">文章分类<span style="color: red">*</span></td>
<td>
<select name="article_cate_id" lay-verify="required" lay-reqText="请选择分类">
<option value="">请选择分类</option>
@ -53,13 +53,18 @@
</td>
</tr>
<tr>
<td class="layui-td-gray2">文章来源</td>
<td class="layui-td-gray2">是否原创</td>
<td>
<input type="radio" name="original" value="1" title="是" {eq name="$article.original" value="1" }checked{/eq}>
<input type="radio" name="original" value="0" title="否" {eq name="$article.original" value="0" }checked{/eq}>
</td>
<td class="layui-td-gray2">作者/来源</td>
<td>
<input type="text" name="origin" class="layui-input" autocomplete="off" placeholder="请输入文章来源"
value="{$article.origin}">
</td>
<td class="layui-td-gray2">来源链接</td>
<td colspan="3">
<td>
<input type="text" name="origin_url" class="layui-input" autocomplete="off" placeholder="请输入来源链接"
value="{$article.origin_url}">
</td>
@ -72,7 +77,7 @@
<td class="layui-td-gray2" style="vertical-align:top;">缩略图</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="test1">上传缩略图(尺寸:498x280</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="test1">上传缩略图(尺寸:240x136</button>
<div class="layui-upload-list" id="demo1" style="width: 120px; height:66px; overflow: hidden;">
<img src="{:get_file($article.thumb)}" style="max-width: 100%; height:66px;" />
<input type="hidden" name="thumb" value="{$article.thumb}">
@ -81,7 +86,7 @@
</td>
</tr>
<tr>
<td class="layui-td-gray2" style="vertical-align:top;">内容<span style="color: red">*</span></td>
<td class="layui-td-gray2" style="vertical-align:top;">文章内容<span style="color: red">*</span></td>
<td colspan="5">
<textarea name="content" placeholder="请输入内容" class="layui-textarea" id="container" lay-verify="required" lay-reqText="请完善文章内容"
style="border:0;padding:0">{$article.content}</textarea>

View File

@ -51,10 +51,10 @@
<div class="bottom">
<form class="layui-form" id="gougu-login">
<div class="layui-form-item">
<input type="text" name="username" lay-verify="required" placeholder="体验账户gougucms" lay-reqText="请输入账户" autocomplete="off" class="layui-input">
<input type="text" name="username" lay-verify="required" placeholder="请输入账户" lay-reqText="请输入账户" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<input type="password" name="password" lay-verify="required" placeholder="体验密码gougucms" lay-reqText="请输入密码" autocomplete="off" class="layui-input">
<input type="password" name="password" lay-verify="required" placeholder="请输入密码" lay-reqText="请输入密码" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="width:188px;">

View File

@ -20,7 +20,7 @@ function get_cache($key)
//清空缓存
function clear_cache($key)
{
Cache::clear($key);
Cache::delete($key);
}

View File

@ -303,8 +303,9 @@ CREATE TABLE `cms_article` (
`keywords` varchar(255) DEFAULT '' COMMENT '关键字',
`desc` varchar(1000) DEFAULT '' COMMENT '摘要',
`status` int(1) NOT NULL DEFAULT '1' COMMENT '1正常-1下架',
`thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '缩略图',
`origin` varchar(255) NOT NULL DEFAULT '' COMMENT '来源',
`thumb` int(11) NOT NULL DEFAULT 0 COMMENT '缩略图id',
`original` int(1) NOT NULL DEFAULT 0 COMMENT '是否原创1原创',
`origin` varchar(255) NOT NULL DEFAULT '' COMMENT '来源或作者',
`origin_url` varchar(255) NOT NULL DEFAULT '' COMMENT '来源地址',
`content` text NOT NULL,
`read` int(11) NOT NULL DEFAULT '0' COMMENT '阅读量',
@ -321,7 +322,7 @@ CREATE TABLE `cms_article` (
-- ----------------------------
-- Records of cms_article
-- ----------------------------
INSERT INTO `cms_article` VALUES (1, '勾股CMS简介', '', '', 1, '', '', '', '<p>勾股CMS是一套基于ThinkPHP6 + Layui + MySql打造的轻量级、高性能快速建站的内容管理系统。后台管理模块一目了然操作简单通用型后台权限管理框架紧随潮流、极低门槛、开箱即用。</p>', 0, 0, 0, 0, 1, 1608178497, 1608180590, '0');
INSERT INTO `cms_article` VALUES (1, '勾股CMS简介', '', '勾股CMS是一套基于ThinkPHP6+Layui+MySql打造的轻量级、高性能快速建站的内容管理系统。后台管理模块一目了然操作简单通用型后台权限管理框架紧随潮流、极低门槛、开箱即用。', 1, 0, 0, '', '', '<p>勾股CMS是一套基于ThinkPHP6 + Layui + MySql打造的轻量级、高性能快速建站的内容管理系统。后台管理模块一目了然操作简单通用型后台权限管理框架紧随潮流、极低门槛、开箱即用。</p>', 0, 2, 1, 0, 1, 1625071256, 0, 0);
-- ----------------------------
-- Table structure for `cms_article_keywords`
@ -420,10 +421,10 @@ CREATE TABLE `cms_nav_info` (
-- -----------------------------
INSERT INTO `cms_nav_info` VALUES ('1', '0', '1', '首页', '/', '', '0', '1', '1', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('2', '0', '1', '文档', '/', '', '0', '1', '2', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('3', '0', '1', '社区', '/', '', '1', '1', '3', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('3', '0', '1', '社区', '/', '', '0', '1', '3', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('4', '0', '1', '腾讯云优惠', 'https://curl.qcloud.com/PPEgI0oV', '', '1', '1', '4', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('5', '0', '1', '阿里云特惠', 'https://www.aliyun.com/activity/daily/bestoffer?userCode=dmrcx154', '', '1', '1', '5', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('6', '0', '1', '后台演示', 'https://cms.gougucms.com/admin/index/index.html', '', '1', '1', '6', '0', '0');
INSERT INTO `cms_nav_info` VALUES ('6', '0', '1', '后台演示', 'https://www.gougucms.com/admin/index/index.html', '', '1', '1', '6', '0', '0');
-- ----------------------------
-- Table structure for `cms_slide`