2 Star 12 Fork 3

xslooi / Fastadmin_cms_optimize

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Fastadmin-CMS网站内容管理系统程序修改日志

* 注该cms插件为官方收费插件请自行在官方渠道购买安装!

此项目仅为系统日常使用中遇到的奇葩问题的小小优化

Author:xslooi

适配系统:

  • Fastadmin框架 version = V1.4.0.20230711
  • title = CMS内容管理系统 version = 1.5.23
  • title = 百度ueditor插件 version = 1.0.9

网站后台修改登录地址:

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\adminlogin88.php
  • 系统安装默认生成的后台入口文件名称修改
  • 链接:http://localhost/adminlogin88.php/index/login

CMS设置为首页

  • 网站后台->CMS管理->站点配置->伪静态->值里边去掉 /cms

栏目管理-添加自定义字段

  • title 栏目标题 字符
  • content 栏目内容 编辑器

CMS管理-后台菜单名称更换为网站管理

  • SQL:
  UPDATE `fa_auth_rule` SET `title` = '网站管理' WHERE `name` = 'cms'; 

修改默认安装网址的登录头像

UPDATE `fa_admin` SET `avatar` = '/assets/img/avatar.png' WHERE `id` = 1;
UPDATE `fa_user` SET `avatar` = '/assets/img/avatar.png' WHERE `id` = 1;

栏目名称字段修改长度为 200

ALTER TABLE `fa_cms_channel` 
MODIFY COLUMN `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '名称' AFTER `parent_id`;

模型管理-新闻-添加自定义字段

  • shorttitle 短标题 字符
  • source 来源 字符

添加常用字段如:电话、手机、微信、邮箱、地址等

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\config.php
  • 添加:line: 1067;
  [
        'name' => 'sitecopyright',
        'title' => '网站版权说明',
        'type' => 'string',
        'content' => [],
        'value' => 'Copyright © 2018-2022 版权所有',
        'rule' => '',
        'msg' => '',
        'tip' => '网站底部常见的Copyright 20XX 版权所有等描述信息',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'icp_license',
        'title' => '网站备案号',
        'type' => 'string',
        'content' => [],
        'value' => '豫ICP备12345678号',
        'rule' => '',
        'msg' => '',
        'tip' => '中国大陆网站备案号http://beian.miit.gov.cn',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_tel',
        'title' => '联系电话',
        'type' => 'string',
        'content' => [],
        'value' => '0371-1234567',
        'rule' => '',
        'msg' => '',
        'tip' => '座机、400电话或者其他联系号码',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_phone',
        'title' => '联系手机',
        'type' => 'string',
        'content' => [],
        'value' => '15612345678',
        'rule' => '',
        'msg' => '',
        'tip' => '公司手机号或者个人手机号',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_email',
        'title' => '联系邮箱',
        'type' => 'string',
        'content' => [],
        'value' => '123@qq.com',
        'rule' => '',
        'msg' => '',
        'tip' => '公司邮箱或者个人邮箱',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_qq',
        'title' => '联系QQ',
        'type' => 'string',
        'content' => [],
        'value' => '',
        'rule' => '',
        'msg' => '',
        'tip' => '联系人的QQ号',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_weixin',
        'title' => '联系微信',
        'type' => 'string',
        'content' => [],
        'value' => 'webfirst',
        'rule' => '',
        'msg' => '',
        'tip' => '联系人的微信号',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_address',
        'title' => '联系地址',
        'type' => 'string',
        'content' => [],
        'value' => '河南省郑州市',
        'rule' => '',
        'msg' => '',
        'tip' => '一般为公司的办公地址',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_factory',
        'title' => '工厂地址',
        'type' => 'string',
        'content' => [],
        'value' => '工厂地址',
        'rule' => '',
        'msg' => '',
        'tip' => '一般为公司的工厂地址',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'contact_third',
        'title' => '在线咨询链接',
        'type' => 'string',
        'content' => [],
        'value' => 'tencent://message/?uin=12346578&Site=web&Menu=yes',
        'rule' => '',
        'msg' => '',
        'tip' => '第三方独立沟通链接或客服链接',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'custom_field1',
        'title' => '自定义字段1',
        'type' => 'string',
        'content' => [],
        'value' => '',
        'rule' => '',
        'msg' => '',
        'tip' => '由程序员定义的字段,如:联系人姓名,为空则未启用。',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'custom_field2',
        'title' => '自定义字段2',
        'type' => 'string',
        'content' => [],
        'value' => '',
        'rule' => '',
        'msg' => '',
        'tip' => '由程序员定义的字段,如:顶部宣传语,为空则未启用。',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'custom_field3',
        'title' => '自定义字段3',
        'type' => 'string',
        'content' => [],
        'value' => '',
        'rule' => '',
        'msg' => '',
        'tip' => '由程序员定义的字段,如:某个专有链接,为空则未启用。',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'code_in_head',
        'title' => 'head标签中代码',
        'type' => 'text',
        'content' => [],
        'value' => '',
        'rule' => '',
        'msg' => '',
        'tip' => '一般要求放在< head/>标签之前的的第三方javascript代码',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'code_in_body',
        'title' => 'body标签中代码',
        'type' => 'text',
        'content' => [],
        'value' => '',
        'rule' => '',
        'msg' => '',
        'tip' => '一般要求放在< body/>标签之前的的第三方javascript代码',
        'ok' => '',
        'extend' => '',
    ],
    [
        'name' => 'syncphonesite',
        'title' => '开启同步手机站',
        'type' => 'radio',
        'content' => [
            1 => '开启',
            0 => '关闭',
        ],
        'value' => '0',
        'rule' => 'required',
        'msg' => '',
        'tip' => '需要新建【default(设定皮肤)_mobile】目录,再添加一套手机模板。否则手机打开网站将显示错误',
        'ok' => '',
        'extend' => '',
    ],
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\config.html
  • 添加:line: 13; 'config'=>'system_user_id,sitename,sitelogo,title,keywords,description,indexpagesize,theme,qrcode,wxapp,donateimage,userpage,openedsite,searchtype,autopinyin,baidupush,usersidenav,loadmode,pagemode,indexloadmode,indexpagemode,cachelifetime,urlsuffix,syncphonesite,sitecopyright,icp_license,contact_tel,contact_phone,contact_email,contact_qq,contact_weixin,contact_address,contact_factory,contact_third,custom_field1,custom_field2,custom_field3,code_in_head,code_in_body',

添加手机版识别

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Base.php
  • 添加:line: 73;
    /**
     * 检测设备是否是手机
     * @return bool
     */
    public function checkMobileDevice(){
        $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : '';
        $mobile_browser = 0;

        if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
            $mobile_browser++;
        }

        if((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') !== false)) {
            $mobile_browser++;
        }

        if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
            $mobile_browser++;
        }

        if(isset($_SERVER['HTTP_PROFILE'])) {
            $mobile_browser++;
        }

        $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
        $mobile_agents = array(
            'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
            'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
            'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
            'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
            'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
            'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
            'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
            'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
            'wapr','webc','winw','winw','xda','xda-'
        );

        if(in_array($mobile_ua, $mobile_agents)) {
            $mobile_browser++;
        }

        if(strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) {
            $mobile_browser++;
        }

        // Pre-final check to reset everything if the user is on Windows
        if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) {
            $mobile_browser = 0;
        }

        // But WP7 is also Windows, with a slightly different characteristic
        if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) {
            $mobile_browser++;
        }

        if($mobile_browser>0) {
            return true;
        }
        else {
            return false;
        }
    }
  • 添加:line: 22-25;
      // 同步手机站变更模板目录
        if(!empty($config['syncphonesite']) && $this->checkMobileDevice()){
            $config['theme'] = $config['theme'] . '_mobile';
        }
      // 设定主题模板目录

栏目展示,调用默认排序修改

  • 路径:line 41; line 194; E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\cms\Channel.php

  • 路径:line 34; E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\cms\Builder.php

  • 路径:line 52; line 272; E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\cms\Archives.php

  • 路径:line 176; E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Api.php

  • 路径:line 190; line 208; line 239; line 361; line 407; line 491; E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\model\Channel.php

  • 修改:weigh desc,id desc 修改为 weigh asc,id asc

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\model\Channel.php

  • 修改:line 269; desc 修改为 asc

  • 修改:line 273; $orderway : 'desc'; 修改为 $orderway : 'asc';

后台添加内容默认权重递增

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\cms\Archives.php
  • 添加:add方法
  /**
     * 添加
     *
     * @return string
     * @throws \think\Exception
     */
    public function add()
    {
        if (false === $this->request->isPost()) {
            // 权重默认随着id递增
            $row_reigh = $this->model->max('id') + 1;
            $this->view->assign('row_weigh', $row_reigh);

            return $this->view->fetch();
        }
        $params = $this->request->post('row/a');
        if (empty($params)) {
            $this->error(__('Parameter %s can not be empty', ''));
        }
        $params = $this->preExcludeFields($params);

        if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
            $params[$this->dataLimitField] = $this->auth->id;
        }
        $result = false;
        Db::startTrans();
        try {
            //是否采用模型验证
            if ($this->modelValidate) {
                $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
                $this->model->validateFailException()->validate($validate);
            }
            $result = $this->model->allowField(true)->save($params);
            Db::commit();
        } catch (ValidateException|PDOException|Exception $e) {
            Db::rollback();
            $this->error($e->getMessage());
        }
        if ($result === false) {
            $this->error(__('No rows were inserted'));
        }
        $this->success();
    }
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\view\cms\archives\add.html
  • 修改:line 203; 0 修改为 {$row_weigh}

页码默认边界修改(使手机一行可放下)

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\library\Bootstrap.php
  • 修改:line 69-84;
        $side = 2;
        $window = $side * 2;

        if ($this->lastPage < $window + 4) {
            $block['first'] = $this->getUrlRange(1, $this->lastPage);
        } elseif ($this->currentPage <= $window) {
            $block['first'] = $this->getUrlRange(1, $window + 1);
            $block['last'] = $this->getUrlRange($this->lastPage, $this->lastPage);
        } elseif ($this->currentPage > ($this->lastPage - $window)) {
            $block['first'] = $this->getUrlRange(1, 1);
            $block['last'] = $this->getUrlRange($this->lastPage - ($window), $this->lastPage);
        } else {
            $block['first'] = $this->getUrlRange(1, 1);
            $block['slider'] = $this->getUrlRange($this->currentPage - 1, $this->currentPage + 1);
            $block['last'] = $this->getUrlRange($this->lastPage, $this->lastPage);
        }
  • 修改:line 24; « 修改为 上一页
  • 修改:line 42; » 修改为 下一页

修改上一篇下一篇链接(由权重排序)

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\model\Archives.php

  • 修改:line 578; prev 修改为: next

  • 修改-添加:line 582;

  $weigh = self::where(['id'=>$archives])->value('weigh');
  $model = self::where('weigh', $type === 'next' ? '<' : '>', $weigh)->where('status', 'normal');
  • 修改:line 591;
$model->order($type === 'prev' ? 'id desc' : 'id asc');
//修改为:
$model->order($type === 'next' ? 'weigh desc, id desc' : 'weigh asc, id asc');

栏目添加默认导航显示isnav=1

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\view\cms\channel\add.html
  • 修改:line 169; value="0" 修改为 value="1"
  • 修改:line 171; fa fa-toggle-on text-success fa-flip-horizontal text-gray fa-2x 修改为 fa fa-toggle-on text-success fa-2x

修改单页、栏目页、详情页TDK

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Page.php
  • 添加:line 19; $config = get_addon_config('cms');
  • 修改:line 43; line 44;
        Config::set('cms.keywords', isset($page['keywords']) && $page['keywords'] ? $page['keywords'] : $config['keywords']);
        Config::set('cms.description', isset($page['description']) && $page['description'] ? $page['description'] : $config['description']);
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Channel.php
  • 修改:line 173; line 174;
        Config::set('cms.keywords', isset($channel['keywords']) && $channel['keywords'] ? $channel['keywords'] : $config['keywords']);
        Config::set('cms.description', isset($channel['description']) && $channel['description'] ? $channel['description'] : $config['description']);
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Archives.php
  • 修改:line 89; line 90;
Config::set('cms.keywords', isset($archives['keywords']) && $archives['keywords'] ? $archives['keywords'] : $config['keywords']);
Config::set('cms.description', isset($archives['description']) && $archives['description'] ? $archives['description'] : $config['description']);

自动提取关键词和描述和缩略图

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\cms\Archives.php
  • 添加:add方法体内:$result = false; Db::startTrans();之前

        // 自动提取关键词
        if(empty($params['keywords'])){
            $keywords = \addons\cms\library\Service::getContentTags($params['title']);
            $keywords = in_array($params['title'], $keywords) ? [] : $keywords;
            $keywords = array_filter(array_merge([$params['tags']], $keywords));

            $params['keywords'] = implode(',', $keywords);
        }

        // 自动提取描述
        if(empty($params['description']) && !empty($params['content'])){
            $description = mb_substr(strip_tags(str_replace(['&nbsp;', "\r", "\n", "\t"], ' ', $params['content'])), 0, 150);
            $params['description'] = $description;
        }

        // 自动提取缩略图 todo 目前仅提取后台自行上传和手动下载的。不提取远程图片
        if(empty($params['image']) && false !== stripos($params['content'], '/uploads/')){
            $matches = [];
            preg_match('/<img src="(.*?)"/i', $params['content'], $matches);
            if(isset($matches[1])){
                $params['image'] = $matches[1];
            }
        }

修改内容标题输入框默认背景颜色

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\css\backend.css
  • 添加:line 341-343;
#c-title{
  background-color: #deffde;
}
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\css\backend.min.css
  • 添加:最后
#c-title{background-color:#deffde;}

添加过滤广告词(常见的旧版本)

最先进科学
史上最低价
最受欢迎
最大程度
最新技术
最新科学
最先进
最便宜
最流行
最时尚
最聚拢
最符合
最舒适
最低级
最低价
最高级
最高端
最奢侈
最优秀
最佳
最具
最爱
最赚
最优
最好
最大
最高
最低
最底
最先
最后
最新
大品牌之一
仅此一次
仅此一款
最后一波
中国第一
全网第一
销量第一
排名第一
独一无二
全国第一
第一品牌
唯一
遗留
一天
第一
销冠
NO.1
TOP1
国家级
国际级
世界级
千万级
百万级
超甲级
星级
甲级
第一
第二
三甲
十强
百强
5A
翘楚之作
不可再生
不可复制
绝无仅有
寸土寸金
淋漓尽致
无与伦比
顶级享受
前所未有
无人能及
非此莫属
顶级
顶尖
尖端
高级
极品
极佳
绝佳
绝对
终极
极致
致极
极具
完美
绝佳
极佳
至尊
至臻
臻品
臻致
臻席
压轴
问鼎
空前
绝后
绝版
无双
巅峰
顶级
鼎级
鼎冠
定鼎
完美
唯一
卓越
卓著
前无古人后无来者
绝无仅有
绝不在有
稀世珍宝
千金难求
世所罕见
不可多得
空前绝后
寥寥无几
屈指可数
绝版
珍稀
臻稀
稀少
开发者
缔造者
创始者
发明者
独家
独创
独据
国家领导人推荐
填补国内空白
全国销量冠军
国际品质
中国驰名
首屈一指
全国首家
首个
首款
独家
首发
首席
首府
首选
国门
国宅
首次
黄金旺铺
黄金价值
黄金地段
商品已注册驰名商标
领先上市
驰名商标
掌门人
大牌
金牌
名牌
王牌
巨星
著名
至尊
巅峰
之王
王者
领袖
皇家
世界领先
遥遥领先
领导者
领袖
引领
创领
领航
耀领
史无前例
前无古人
百分之百
永久
万能
祖传
特效
无敌
纯天然
正品
超强
100%
领导人推荐
专家推荐
特供
专供
无需国家质量检测
质量免检
免抽检
免检
点击有惊喜
点击领奖
恭喜获奖
全民免单
点击获取
点击转身
领取奖品
抽奖
错过就没机会了
再不抢就没了
史上最低价
不会再便宜
未曾有过的
价格你来定
即将售罄
错过不再
错过即无
万人疯抢
全民疯抢
免费领
免费住
0首付
免首付
零距离
售空
抢购
让孩子赢在起跑线上
一站式教育
入住学区房
教育护航
优先入学
教育无忧
全程无忧
起跑线
升学
买个房啥都解决了
承诺户口
蓝印户口
承诺移民
升值潜力无线
炒股不如买房
买到即赚到
升值价值
价值洼地
价值天成
千亿价值
投资回报
众筹
抄涨
随时结束
随时涨价
马上降价
购物大趴
倒计时
趁现在
周年庆
特惠趴
品牌团
仅限
周末
闪购

内容管理列表权重可以直接编辑

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\js\backend\cms\archives.js
  • 修改:line 145; {field: 'weigh', title: __('Weigh'), operate: false, sortable: true}, 修改为:
{
    field: 'weigh',
    title: __('Weigh'),
    formatter: function (value, row, index) {
        return '<input type="text" class="form-control text-center text-weigh" data-id="' + row.id + '" value="' + value + '" style="width:60px;margin:0 auto;" />';
    },
    events: {
        "dblclick .text-weigh": function (e) {
            e.preventDefault();
            e.stopPropagation();
            return false;
        }
    },
    sortable: true
},
  • 添加:line 415-421;
  • 添加在
Controller.index // 方法体内, 在$(document).on('click', '.btn-move', function () { 省略... }); 后边
 //权重绑定事件
$(document).on("change", ".text-weigh", function () {
    $(this).data("params", {weigh: $(this).val()});
    Table.api.multi('', [$(this).data("id")], table, this);
    return false;
});

自定义字段展示顺序按照模型添加的(权重 升序,id 升序)

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\library\Service.php
  • 修改:line 229; weigh desc,id desc 修改为:weigh asc,id asc

文章标题-遇到不认识的编码

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\library\VicWord.php
  • 修改:line 91;
 // exit('我不认识的编码');
return false; // todo 遇到不认识的编码返回false
  • 添加:line 176-179; 在 list($d, $i) = $this->getD($str, $i); 之前
  • 添加:line 233-236; 在 list($d, $i) = $this->getD($str, $i); 之前
      // 遇到不认识的编码,跳过
          if(false === $this->getD($str, $i)){
              continue;
          }

修改默认页码大小为12

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\view\cms\channel\add.html
  • 修改:line 129;
<input id="c-pagesize" data-rule="required" class="form-control" name="row[pagesize]" type="number" value="12" data-tip="用于前台列表页分页">

关闭标题和文章名称自动转换拼音 并添加按钮手动识别

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\view\cms\channel\add.html
  • 修改:line 89 - 91;
  <div class="col-xs-12 col-sm-8">
  <div class="input-group">
    <input id="c-diyname" data-rule="required(single); diyname" class="form-control" name="row[diyname]" type="text" data-tip="用于伪静态规则中[:diyname]替换" style="width: 50%;">
    <div class="input-group-addon no-border no-padding">
      <span><button type="button" id="diyname-pinyin" class="btn btn-info" data-input-id="c-pinyin">拼音识别</button></span>
    </div>
  </div>
</div>
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\view\cms\channel\edit.html
  • 修改:line 90 - 92;
 <div class="col-xs-12 col-sm-8">
  <div class="input-group">
    <input id="c-diyname" data-rule="required; diyname" class="form-control" name="row[diyname]" type="text" value="{$row.diyname|htmlentities}" data-tip="用于伪静态规则中[:diyname]替换" style="width: 50%;">
    <div class="input-group-addon no-border no-padding">
      <span><button type="button" id="diyname-pinyin" class="btn btn-info" data-input-id="c-pinyin">拼音识别</button></span>
    </div>
  </div>
</div>
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\js\backend\cms\channel.js
  • 删除:line 405 - 424;
 var si;
                $(document).on("keyup", "#c-name", function () {
                    var value = $(this).val();
                    if (value != '' && !value.match(/\n/)) {
                        clearTimeout(si);
                        si = setTimeout(function () {
                            Fast.api.ajax({
                                loading: false,
                                url: "cms/ajax/get_title_pinyin",
                                data: {title: value}
                            }, function (data, ret) {
                                $("#c-diyname").val(data.pinyin.substr(0, 100));
                                return false;
                            }, function (data, ret) {
                                return false;
                            });
                        }, 200);
                    }
                });
  • 添加:line 405 - 424; 上边删除的位置
          //获取栏目拼音
          var si;
          $(document).on("click", "#diyname-pinyin", function () {
                    var _cname = $("#c-name");
                    var value = _cname.val();
                    if (value != '' && !value.match(/\n/)) {
                        clearTimeout(si);
                        si = setTimeout(function () {
                            Fast.api.ajax({
                                loading: false,
                                url: "cms/ajax/get_title_pinyin",
                                data: {title: value, check: 0}
                            }, function (data, ret) {
                                $("#c-diyname").val(data.pinyin.substr(0, 100));
                                return false;
                            }, function (data, ret) {
                                return false;
                            });
                        }, 200);
                    }
                });

搜索添加检索字段(description)

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Search.php
  • 修改:line 108; $query->where('a.title', 'like', '%' . $item . '%'); 修改为: $query->where('a.title|a.description', 'like', '%' . $item . '%');

百度UEditor 视频和附件上传采用系统分片上传(同时修改文件上传大小)

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\extra\upload.php

  • 修改:line 20; 'maxsize' => '10mb', 修改为: 'maxsize' => '2048mb',

  • 修改:line 28; 'multiple' => false, 修改为: 'multiple' => true,

  • 修改:line 32; 'chunking' => false, 修改为: 'chunking' => true,

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\js\require-upload.js

  • 修改:搜索;

class="btn btn-danger hidden faupload"
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\js\require-backend.min.js
  • 修改:替换; 修改为:
class="btn btn-danger hidden faupload" data-chunking="true" data-maxsize="2048M" data-timeout="600000"

百度UEditor编辑器 后台附件上传允许文件:

E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\addons\ueditor\dialogs\attachment\attachment.js line:162;

acceptExtensions = (editor.getOpt('fileAllowFiles') || [".txt", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".odt", ".ott", ".fodt", ".uot", ".xml", ".dot", ".htm", ".html", ".rtf", ".docm", ".zip", ".rar", ".tar", ".7z", ".tar.gz", ".tar.bz", ".tar.xz"]).join('').replace(/\./g, ',').replace(/^[,]/, '');

添加一个客户管理员组并分配一个默认的管理员adminuser

  • 使客户便于管理网站和降低后台操作学习成本
  • 仅赋予客户正常使用的权限(最小权限原则)例如:
  • 网站管理-站点配置
  • 网站管理-栏目管理
  • 网站管理-内容管理

后台文章权重 子管理员 mulit 修改提示无权限

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\cms\Archives.php
  • 添加:line:32; protected $searchFields = 'id,title'; 之后
protected $multiFields = 'status,weigh';

修改cms - config.html 非总管理员菜单显示

  • 路径: E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\config.html
  • 修改:line: 28;
<form id="config-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="display: none;">
  • 修改:line: 199-222; tabevent 函数内
// 非管理员隐藏元素
var lastlogin = localStorage.getItem('lastlogin');
if(lastlogin){
  var lastloginObj = $.parseJSON(lastlogin);
  if(1 !== parseInt(lastloginObj.id)){
    $(".panel-heading").hide();
    $(".table-config tr").hide();

    $("input[name='row[sitename]']").parents('tr').show();
    $("input[name='row[title]']").parents('tr').show();
    $("input[name='row[keywords]']").parents('tr').show();
    $("input[name='row[description]']").parents('tr').show();
    $("input[name='row[sitecopyright]']").parents('tr').show();
    $("input[name='row[icp_license]']").parents('tr').show();
    $("input[name='row[contact_tel]']").parents('tr').show();
    $("input[name='row[contact_phone]']").parents('tr').show();
    $("input[name='row[contact_email]']").parents('tr').show();
    $("input[name='row[contact_qq]']").parents('tr').show();
    $("input[name='row[contact_weixin]']").parents('tr').show();
    $("input[name='row[contact_address]']").parents('tr').show();
    $("input[name='row[contact_factory]']").parents('tr').show();
    $("input[name='row[custom_field1]']").parents('tr').show();
    $("input[name='row[custom_field2]']").parents('tr').show();
    $("input[name='row[custom_field3]']").parents('tr').show();
    $("input[name='row[contact_third]']").parents('tr').show();
  }
}
$("#config-form").show();

客户管理员默认有些栏目选项不显示

  • 路径: E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\js\backend\cms\channel.js
  • 添加:line 210-227; edit 函数体内
// 非管理员隐藏元素
var lastlogin = localStorage.getItem('lastlogin');
if(lastlogin){
  var lastloginObj = $.parseJSON(lastlogin);
  if(1 !== parseInt(lastloginObj.id)){
    $("input[name='row" + '[type]' + "']").parents(".form-group").hide(); // 类型
    $("select[name='row" + '[model_id]' + "']").parents(".form-group").hide(); // 模型
    $("select[name='row" + '[parent_id]' + "']").parents(".form-group").hide(); // 上级栏目
    $("button#fachoose-image").hide(); // 选择图片按钮

    setTimeout(function () {
      $("input[name='row" + '[channeltpl]_text' + "']").parents(".form-group").hide(); // 频道页模板
      $("input[name='row" + '[listtpl]_text' + "']").parents(".form-group").hide(); // 列表页模板
      $("input[name='row" + '[showtpl]_text' + "']").parents(".form-group").hide(); // 详情页模板
    }, 100);
  }
}

客户管理员默认有些添加文章没有权限的按钮不显示

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\public\assets\js\backend\cms\archives.js
  • 添加:line 948-980; api: {} 对象体内添加方法 adminhide
    ,adminhide: function () {
                var lastlogin = localStorage.getItem('lastlogin');
                if(lastlogin){
                    var lastloginObj = $.parseJSON(lastlogin);
                    if(1 != lastloginObj.id){
                        // 10秒内不断查找元素并处理
                        var __admin_elements = [],
                            admin_elements_load_time = Date.now(),
                            admin_elements_timer_handler = function(){

                                $("[id^='fachoose-']").each(function () {
                                    var __that = $(this);
                                    var __admin_element_id = __that.attr('id');

                                    if(-1 !== __admin_elements.indexOf(__admin_element_id)){
                                        return;
                                    }

                                    __that.hide();
                                    __admin_elements.push(__admin_element_id);
                                });

                                // 超时10秒
                                if(10000 > (Date.now() -admin_elements_load_time)){
                                    setTimeout(function(){admin_elements_timer_handler();}, 1000);
                                }
                            };

                        admin_elements_timer_handler();
                    }
                }
            }
  • 添加:line 607 612; add 和 edit 方法体内 Controller.api.bindevent(); 之后
   Controller.api.adminhide();

栏目添加默认 sitemap.html 和 sitemap.xml 处理逻

  • 系统自带的sitemap未使用-请自行查看
  • 模板文件sitemap.html 和 sitemapxml.html请自行处理
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Channel.php
  • 添加:line 34-40; if (!$channel || $channel['status'] != 'normal') { 在这里... $this->error(__('No specified channel found')); } 分支内部
            if('/sitemap.html' == $this->request->url()){
                return $this->fetch('/sitemap');
            }

            if('/sitemap.xml' == $this->request->url()){
                return \\think\Response::create($this->fetch('/sitemapxml'), 'html', 200, ['Content-Type' => 'text/xml; charset=utf-8']);
            }

自定义表单在每个表单下可以自行设定成功后跳转url

  • 自己的模板表单文件中添加:value 为跳转链接,默认成功返回上一页
<input type="hidden" name="row[redirecturl]" value="referer">
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\controller\Diyform.php
  • 添加:line: 258-266; unset($row['id']); 之后
         // 处理用户自定义跳转链接
            if(isset($row['redirecturl']) && !empty($row['redirecturl'])){
                $diy_redirecturl = $row['redirecturl'];
                unset($row['redirecturl']);
            }
            else{
                $diy_redirecturl = '';
            }
  • 添加:line: 282-290; $this->success($diyform['successtips'] ? $diyform['successtips'] : '提交成功!', $redirecturl); 之前
            // 提交表单可以自定义跳转链接
            if(!empty($diy_redirecturl)){
                if('referer' == $diy_redirecturl){
                    $redirecturl = null; // 默认跳转引用页
                }
                else{
                    $redirecturl = $diy_redirecturl;
                }
            }

伪静态兼容模式 ?s=/static/image/logo.png 资源文件不存在时处理

!!!注意此修改会破坏插件URL路由

  • 请在仅使用电脑版和手机版 *.html 链接时修改!如:api接口和小程序会连接错误!
  • 此修改是解决资源文件不存在时候自动刷新验证Token
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\common\behavior\Common.php
  • 添加:line: 79-82; addonBegin 函数体内
        $uri_ext = $request->ext();
        if($uri_ext && (!in_array($uri_ext, ['xml', Config::get('default_return_type')]))) {
            throw new \think\exception\HttpException(404, 'uri suffix error!');
        }


程序适配 SiteGround 空间 public_html 为站点根目录

  • 变更兼容public目录为变量使之可以放入任意二级目录中

  • 使用说明:
  • 适配某些空间固定的网站根目录,需要网站根目录外可以解压文件
  1. 空间根目录外正常解压程序压缩包
  2. public目录中所有文件复制到任意目录中如(public_html)中

生成缓存路径

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin_root\public_html\adminlogin88.php
  • 添加:17-18;
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin_root\public_html\index.php
  • 添加:15-16;
// 定义当前运行的web目录
define('WEB_DIR', __DIR__ . DIRECTORY_SEPARATOR);
  • 路径: E:\WWWROOT\OtherPHPSystem\fastadmin_root\vendor\karsonzhang\fastadmin-addons\src\addons\Service.php
  • 添加:line 393-396; $addonsFile = ROOT_PATH . str_replace("/", DS, "public/assets/js/addons.js"); 之后
        if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){
            $addonsFile = ROOT_PATH . str_replace("/", DS, basename(WEB_DIR) . "/assets/js/addons.js");
        }
  • 添加:line 1061-1063; $assetsDir = ROOT_PATH . str_replace("/", DS, "public/assets/addons/{$name}/"); 之后
     if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){
            $assetsDir = ROOT_PATH . str_replace("/", DS, basename(WEB_DIR) . "/assets/addons/{$name}/");
     }
  • 添加:line 1082-1088; getCheckDirs 函数体内第一行
        if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){
            return [
                'application',
                'public',
                basename(WEB_DIR)
            ];
        }

导入上传的路径

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin_root\application\admin\library\traits\Backend.php
  • 添加:line 358-361; $filePath = ROOT_PATH . DS . 'public' . DS . $file; 之后
     if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){
            $filePath = ROOT_PATH . DS . basename(WEB_DIR) . DS . $file;
     }

上传文件路径

  • 路径: E:\WWWROOT\OtherPHPSystem\fastadmin_root\application\common\library\Upload.php
  • 添加:line 371-374; $destDir = ROOT_PATH . 'public' . str_replace('/', DS, $uploadDir); 之后
        if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){
            $destDir = ROOT_PATH . basename(WEB_DIR) . str_replace('/', DS, $uploadDir);
        }

删除上传的文件

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\general\Attachment.php
  • 添加:line 119-121; $attachmentFile = ROOT_PATH . '/public' . $params['url']; 之后
 if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){
      $attachmentFile = ROOT_PATH . basename(WEB_DIR) . $params['url'];
  }

程序适配景安空间,首页放入根目录(直接解压到空间里运行)

  • 1、请先完成适配 SiteGround 空间修改

  • 2、复制 public 目录中所有文件到 public 上级目录 (不需要的文件请自行删减)

  • 根目录放入Apache的伪静态配置文件.htaccess

<IfModule mod_rewrite.c>
    Options +FollowSymlinks -Multiviews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]

    ###不能访问目录
    RewriteRule ^addons - [F,L,NC]
    RewriteRule ^application - [F,L,NC]
    RewriteRule ^extend - [F,L,NC]
    RewriteRule ^runtime - [F,L,NC]
    RewriteRule ^thinkphp - [F,L,NC]
    RewriteRule ^vendor - [F,L,NC]

    ###不能执行目录
    RewriteRule ^assets/(.*).(php)$ – [F,L,NC]
    RewriteRule ^template/(.*).(php)$ – [F,L,NC]
    RewriteRule ^mobile/(.*).(php)$ – [F,L,NC]
    RewriteRule ^static(.*).(php)$ – [F,L,NC]
    RewriteRule ^statics(.*).(php)$ – [F,L,NC]
    RewriteRule ^skin(.*).(php)$ – [F,L,NC]
    RewriteRule ^skins(.*).(php)$ – [F,L,NC]
    RewriteRule ^upload(.*).(php)$ – [F,L,NC]
    RewriteRule ^uploads(.*).(php)$ – [F,L,NC]

</IfModule>

###限制后缀文件访问
<FilesMatch "\\.(txt|bak|inc|lib|sh|tpl|lbi|dwt|htm)$">
    order deny,allow
    deny from all
</FilesMatch>

首页入口文件修改

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\index.php
  • 修改:line: 16;
define('APP_PATH', __DIR__ . '/application/');
  • 修改:line: 24;
require __DIR__ . '/thinkphp/start.php';

后台入口文件修改

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\adminlogin88.php
  • 修改:line: 16;
define('APP_PATH', __DIR__ . '/application/');
  • 修改:line: 26;
require __DIR__ . '/thinkphp/base.php';

生成缓存路径 去掉默认public/目录

  • 路径: E:\WWWROOT\OtherPHPSystem\fastadmin_root\vendor\karsonzhang\fastadmin-addons\src\addons\Service.php
  • 修改:line 392; if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){ 上边
      $addonsFile = ROOT_PATH . str_replace("/", DS, "assets/js/addons.js");
  • 修改:line 1061; if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){ 上边
    $assetsDir = ROOT_PATH . str_replace("/", DS, "assets/addons/{$name}/");

导入上传的路径

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin_root\application\admin\library\traits\Backend.php
  • 修改:line 357; if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){ 上边
  $filePath = ROOT_PATH . DS . $file;

上传文件路径

  • 路径: E:\WWWROOT\OtherPHPSystem\fastadmin_root\application\common\library\Upload.php
  • 添加:line 365; if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){ 上边
   $destDir = rtrim(ROOT_PATH, DS) . str_replace('/', DS, $uploadDir);

删除上传的文件

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\controller\general\Attachment.php
  • 添加:line 118; if(defined('WEB_DIR') && strlen(WEB_DIR) > strlen(ROOT_PATH)){ 上边
 $attachmentFile = rtrim(ROOT_PATH, DS) . $params['url'];

!!! 修改网站 public 目录未处理的文件列表

  • 下列文件中有使用public目录(但CMS网站日常操作不需要)可以自行修改
  • E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\command\Addon.php
  • E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\command\Api.php
  • E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\command\Crud.php
  • E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\command\Install.php
  • E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\command\Min.php
  • 各个插件的.addonrc配置文件

百度收录织梦文章多级目录URL兼容SEO打开处理

!!!注意此修改会破坏插件URL路由

  • 请在仅使用电脑版和手机版 *.html 链接时修改!如:api接口和小程序会连接错误!
  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\addons\cms\Cms.php
  • 添加:line: 128; public function appInit() 函数体内第一行
 $request = \\think\Request::instance();
        $request_url = $request->url();
        // 百度收录织梦文章多级目录URL,fastadmin-cms系统302跳转处理 todo 手机URL未处理 附带参数未处理如:?1590650404
        if (2 < substr_count($request_url, '/') && false === strpos($request_url, 'admin')) {
            $response_url = '/';
            $request_url_array = explode('/', $request_url);
            foreach($request_url_array as $item){
                if(false !== stripos($item, '.html')){
                    $response_url .= '/' . $item;
                }
                else{
                    $response_url .= ucfirst($item);
                }
            }

            header('Location:' . $response_url);
            exit();
        }

区块管理添加常用名称

  • 路径:E:\WWWROOT\OtherPHPSystem\fastadmin\application\admin\model\cms\Block.php
  • 修改:line: 67;
return ['pcbanner' => 'PC轮播图', 'wapbanner' => 'Phone轮播图', 'indexfocus' => 'PC首页焦点图', 'downloadfocus' => 'PC下载频道页焦点图', 'newsfocus' => 'PC资讯频道页焦点图', 'productfocus' => 'PC产品频道页焦点图', 'uniappfocus' => 'UniAPP焦点图', 'wxappfocus' => '原生微信小程序焦点图'];

UEditor 图片、视频、附件上传按钮美化

  • public 文件夹复制覆盖即可(内部为3个样式表文件)

自定义表单管理-留言-字段列表

  • 修改每个字段把验证规则全部删空(方便后期处理)

发布 uniapp 为H5

  • 在你的项目的根目录/public 下新建一个目录为h5 把刚刚打包好的static文件夹和index.html上传到h5目录下
  • 访问路径:域名/h5/
nginx:

location /h5/ {
   try_files $uri /h5/index.html;
}

apache:

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^h5/(.*) /h5/index.html [QSA,PT,L]

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond $1 !^(h5)
  RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]

</IfModule>

启用本地环境调试配置 .env 文件

!!!注意线上一定要删除此文件

  • 默认仅开启调试模式
  • 注意此文件数据库链接配置
MIT License Copyright (c) 2022 xslooi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

此项目仅为Fastadmin-cms系统日常使用中遇到的奇葩问题的小小优化(持续更新) 展开 收起
PHP 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/xslooi/fastadmin_cms_optimize.git
git@gitee.com:xslooi/fastadmin_cms_optimize.git
xslooi
fastadmin_cms_optimize
Fastadmin_cms_optimize
master

搜索帮助