feige
feige
分享运营真实案例,用编程创造自己的产品

注册于 6月前

回答
40
文章
44
关注者
1

JS里动态设置validator 校验,关键点:JS调用$('#edit-form').validator来设置校验规则。
例如:

if ($("#txt_previewUrl").val() == "" || $("#txt_previewUrl").val() == undefined) { 
    $('#edit-form').validator({
        fields: {
            'row[axurehtmlzip]': 'required; '
        }
    })
}

如果是单选框的必填,不是使用required;而是使用checked

$('#post-form').validator({
    fields: {
        'row[axureversion]': 'checked; '
    }
})

输出文件流用于下载

$filePath =  $_SERVER['DOCUMENT_ROOT'].$other['sourcefile'];  
$postfix=strrchr($filePath, '.');
$fileName = $archives["title"].$postfix;

header('Content-Disposition:attachment;filename='.$fileName);
return file_get_contents($filePath);

seo title 写死在代码里了
D:\2.work\04git\axureshop\addons\cms-1.3.2-regular\controller\Index.php

$seotitle = "Axure原型模板与元件库作品、素材资源下载,高保真设计平台";
$seokeywords = "Axure原型模板,元件库,高保真原型,手机APP,后台管理系统,大数据,demo";
$seodescription = "Axure工坊为产品经理、设计师等互联网软件从业者提供Axure原型作品模板、元件库以及素材范例。免费下载工具资源,分享Axure使用教程与职场心得。本站也提供原型定制服务。";

Config::set('cms.title', $seotitle);
Config::set('cms.keywords', $seokeywords);
Config::set('cms.description', $seodescription);

打开文件

D:\2.work\fastadmin\1.2.0.20201008_full\vendor\nelexa\zip\src\ZipFile.php

在523上加上dump($file); 页面上重新保存一次,打印出来的内容可以看到问题:

string(133) "D:\2.work\fastadmin\1.2.0.20201008_full\public/assets/axurefiles/0b1181d12f61bec10032d6977a035894\images\p4-1-5_�罻�˺�\Բ_u2156.png"

就是图片是中文名,他前面的文件夹也是中文名,就出现问题了。以前也发生过一次。
到文件夹下看,解压出来的文件也是乱码

输入图片说明
解决办法:

输入图片说明

输入图片说明
重新打个zip就好。

使用nginx后伪静态出问题,要配置

server {        listen       9001;
        server_name  www.ff.com *.ff.com;
        root   "D:\2.work\fastadmin\1.2.0.20201008_full\public";
        client_max_body_size     300m;
        client_header_timeout    5m;
        client_body_timeout      5m;
        proxy_connect_timeout     6000s;
        proxy_read_timeout      5m;
        proxy_send_timeout      5m;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
       location / {
            index  index.html index.htm index.php;
            #主要是这一段一定要确保存在
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
            #结束
            #autoindex  on;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;

        }
    }

关键是这段

location / {
            index  index.html index.htm index.php;
            #主要是这一段一定要确保存在
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
            #结束
            #autoindex  on;
        }

Session 前后台是打通的
支持admin 设置, index 获取。admin 和index 是打通的。
Session::set("__reviewcodeRandom__","")
Session::get("__reviewcodeRandom__")

index(前台的后台模块)调用admin的模型。模型全路径即可
appadminmodelcmsAddonworkversion::get($id);

上传大文件
FastAdmin使用的是Nginx,
nginx.conf配置
client_max_body_size 500m;
再加php.ini配置
post_max_size = 500M
upload_max_filesize = 500M
即可实现大文件上传

但是还是发现上传大文件总是在30秒时中断。
原因是upload 上传时 控件超时。修改办法

输入图片说明

后台刷新列表的方法
方法一:
var table = $("#table");
table.bootstrapTable('refresh');

方法二:如果toolbar里有刷新按钮,可以调用它的点击事件
$(".btn-refresh").trigger("click");

退出直接到首页
C:\08fastadmin\1.2.0.20201008_full\application\index\controller\User.php

/**
* 退出登录
*/
public function logout()
{
   //退出本站
   $this->auth->logout();
   //$this->success(__('Logout successful'), url('/'));//edit by astonish 20201209
   $this->redirect('/',302);//edit by astonish 20201209 退出直接到首页
}

时间格式化int 转 字符 date("Y-m-d H:i:s",$order->paytime)

controller 调用另外一个controller的方法,new 对方的controll对象,返回直接调用它的方法

/** 
* 更新作品的下载次数,直接调用另外一个controll的方法
*/
public function downloadwork()
{
  $archives = new \addons\cms\controller\Archives;
  $archives->downloadwork();
}

时间差的2个方式
方式1:
$d1 =date_create(date('Ymd',time()));
$d2 = date_create(date('Ymd',$archives['publishtime']));
$d = date_diff( $d1 ,$d2);
echo $interval->format('%R%a 天');

方式2:
time()-$archives['publishtime']
如果求相差多少天
round((time()-$archives['publishtime'])/86400);

发布
问题