PHPackages                             quansitech/qscmf-buttontype-download-img - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. quansitech/qscmf-buttontype-download-img

ActiveLibrary

quansitech/qscmf-buttontype-download-img
========================================

qscmf modal button download

v2.1.0(1y ago)0258↓100%1MITJavaScriptPHP &gt;=7.2

Since Apr 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/quansitech/qscmf-buttontype-download-img)[ Packagist](https://packagist.org/packages/quansitech/qscmf-buttontype-download-img)[ RSS](/packages/quansitech-qscmf-buttontype-download-img/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (6)Used By (0)

quansitech/qscmf-buttontype-download-img
========================================

[](#quansitechqscmf-buttontype-download-img)

```
qscmf 按钮类型组件--download-img

可以向列表行、表单页添加此类型按钮

展示并可以下载带有文字描述的图片，常用于下载二维码、小程序码场景。

```

#### 安装

[](#安装)

```
composer require quansitech/qscmf-buttontype-download-img
```

#### 添加按钮

[](#添加按钮)

[DownloadImgButtonBuilder使用说明](https://github.com/quansitech/qscmf-buttontype-download-img/blob/master/DownloadImgButtonBuilder.md)

- 向列表添加一个顶部按钮

    ```
      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)
      }
    }
    ```

#### 效果图

[](#效果图)

[![download-img-eg](https://user-images.githubusercontent.com/35066497/165727366-a93d48c6-51f1-4cc1-ac61-34668d7e206d.png)](https://user-images.githubusercontent.com/35066497/165727366-a93d48c6-51f1-4cc1-ac61-34668d7e206d.png)

#### v1 升级 v2

[](#v1-升级-v2)

v2增加了topButton类型，同时修改了命名空间，因此原来使用了DownloadImgButtonBuilder的地方需要修改成新的命名空间 Qs\\DownloadImg\\DownloadImgButtonBuilder

###  Health Score

27

—

LowBetter than 52% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~178 days

Total

5

Last Release

711d ago

Major Versions

v1.1.0 → v2.0.02024-03-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/15a0610fee78753bdad92fd45c3506455c0fd45ae51924797b1841d260495a3f?d=identicon)[tiderjian](/maintainers/tiderjian)

![](https://www.gravatar.com/avatar/6c2b4bb10b346cb957c091d3273e3332276b5d09a29e255d387184f5dd4b5976?d=identicon)[xhiny](/maintainers/xhiny)

---

Top Contributors

[![Xhiny](https://avatars.githubusercontent.com/u/35066497?v=4)](https://github.com/Xhiny "Xhiny (8 commits)")

---

Tags

componentmodaldownloadbuttonqscmf

### Embed Badge

![Health badge](/badges/quansitech-qscmf-buttontype-download-img/health.svg)

```
[![Health](https://phpackages.com/badges/quansitech-qscmf-buttontype-download-img/health.svg)](https://phpackages.com/packages/quansitech-qscmf-buttontype-download-img)
```

###  Alternatives

[atk4/ui

Agile UI - Web Component Framework written in PHP

448539.4k30](/packages/atk4-ui)[kompo/kompo

Laravel &amp; Vue.js FullStack Components for Rapid Application Development

11911.8k15](/packages/kompo-kompo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
