quansitech/qscmf-buttontype-download-img
Composer 安装命令:
composer require quansitech/qscmf-buttontype-download-img
包简介
qscmf modal button download
README 文档
README
qscmf 按钮类型组件--download-img
可以向列表行、表单页添加此类型按钮
展示并可以下载带有文字描述的图片,常用于下载二维码、小程序码场景。
安装
composer require quansitech/qscmf-buttontype-download-img
添加按钮
-
向列表添加一个顶部按钮
protected function genDownloadImage($ent){ $img_full_url = showFileUrl($ent['cover']); $img_full_url = $img_full_url ? HTTP_PROTOCOL."://".SITE_URL.$img_full_url: ""; $builder = new DownloadImgButtonBuilder("下载小程序码", $img_full_url, "全思-亲子阅读分享码"); $builder->setImgName("全思-亲子阅读", "font-weight: bold;font-size: 20px;"); $builder->setModalDialogWidth("450"); return $builder; } public function index(){ $data = D('User')->getOne(I("get.user_id")); // 每一行数据需要定义'download_img'的值,且该值为DownloadImgButtonBuilder对象 (new \Qscmf\Builder\ListBuilder()) ->addTopButton('download_img',['title' => '下载小程序码'], '', '', $this->genDownloadImage($data)) ->setTableDataList($data_list); }
-
向列表添加一个行按钮
protected function genDownloadImage($ent){ $img_full_url = showFileUrl($ent['cover']); $img_full_url = $img_full_url ? HTTP_PROTOCOL."://".SITE_URL.$img_full_url: ""; $builder = new DownloadImgButtonBuilder("下载小程序码", $img_full_url, "全思-亲子阅读分享码"); $builder->setImgName("全思-亲子阅读", "font-weight: bold;font-size: 20px;"); $builder->setModalDialogWidth("450"); return $builder; } public function index(){ $data_list = D('User')->select(); foreach($data_list as &$data){ $data['download_img'] = $this->genDownloadImage($data); } // 每一行数据需要定义'download_img'的值,且该值为DownloadImgButtonBuilder对象 (new \Qscmf\Builder\ListBuilder()) ->addRightButton('download_img',['title' => '下载小程序码'], '', '', 'download_img') ->setTableDataList($data_list); }
-
向表单添加一个按钮
public function edit($id){ if (IS_POST) { // 业务逻辑 } else { $info = D('User')->getOne($id); $info['download_img'] = $this->genDownloadImage($info) // 表单数据需要定义'download_img'的值,且该值为DownloadImgButtonBuilder对象 (new \Qscmf\Builder\FormBuilder()) ->addButton('download_img',['title' => '下载小程序码'], '', '', 'download_img') ->setFormData($info) } }
-
使用接口返回图片地址等信息,实例化DownloadImgButtonBuilder类的img_full_url为api地址。
protected function genDownloadImage($ent){ $builder = new DownloadImgButtonBuilder("下载小程序码", U("fetchDownloadImageInfo",['id' => $ent['id']]), "全思-亲子阅读分享码"); $builder->setImgName("全思-亲子阅读", "font-weight: bold;font-size: 20px;"); $builder->setModalDialogWidth("450"); $builder->setUseApi(true); return $builder; } public function fetchDownloadImageInfo($id){ $ent = D("TestModal")->getOne($id); $img_full_url = showFileUrl($ent['cover']); $img_full_url = $img_full_url ? HTTP_PROTOCOL."://".SITE_URL.$img_full_url: ""; // 返回值说明 // img_full_url 设置图片路径,为绝对地址,该字段不能为空 // 其它字段按需赋值,为空则以实例化类时设置的值为准,否则替换对应字段的值 // file_name 设置文件名 // img_name 设置图片描述文字 // img_name_style 设置图片描述文字样式 // img_scale 设置下载图片比例 $this->ajaxReturn(['status' => 1, 'data' => [ 'img_full_url' => $img_full_url, 'file_name' => '全思-亲子阅读分享码', 'img_name' => '全思-亲子阅读', 'img_name_style' => "font-weight: bold;font-size: 30px;", 'img_scale' => 4, ]]); } public function edit($id){ if (IS_POST) { // 业务逻辑 } else { $info = D('User')->getOne($id); $info['download_img'] = $this->genDownloadImage($info) // 表单数据需要定义'download_img'的值,且该值为DownloadImgButtonBuilder对象 (new \Qscmf\Builder\FormBuilder()) ->addButton('download_img',['title' => '下载小程序码'], '', '', 'download_img') ->setFormData($info) } }
效果图
v1 升级 v2
v2增加了topButton类型,同时修改了命名空间,因此原来使用了DownloadImgButtonBuilder的地方需要修改成新的命名空间 Qs\DownloadImg\DownloadImgButtonBuilder
quansitech/qscmf-buttontype-download-img 适用场景与选型建议
quansitech/qscmf-buttontype-download-img 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 273 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「component」 「modal」 「download」 「button」 「qscmf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 quansitech/qscmf-buttontype-download-img 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quansitech/qscmf-buttontype-download-img 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 quansitech/qscmf-buttontype-download-img 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
FSi DataSource Component
The NzoFileDownloaderBundle is a Symfony Bundle used to Download all types of files from servers and Web applications safely and with ease. You can also read/show the file content in the Web Browser.
Fork from ghosh/Micromodal. Tiny, dependency-free javascript library for creating accessible modal dialogs.
Adds a download link next to assets
Make Filament modals draggable.
A Filament form component that displays repeater items in a table with modal-based editing.
统计信息
- 总下载量: 273
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-29
