Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Sep 16, 2022
1 parent e26dd9d commit 136a425
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 25 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ $form->video('video','视频')

### 参数说明
```
path(string) : 快速定位目录,默认为根目录
nametype(string): 文件重命名方式 uniqid|datetime|sequence|original,默认 uniqid
pageSize(int) : 弹出层列表每页显示数量
limit(int) : 限制条数
remove(boolean) : 是否有删除按钮
disk(string) : 文件存储的磁盘,具体信息可以查看 `config/filesystems.php`
path(string) : 快速定位目录,默认为根目录
nametype(string) : 文件重命名方式 uniqid|datetime|sequence|original,默认 uniqid
pageSize(int) : 弹出层列表每页显示数量
limit(int) : 限制条数
remove(boolean) : 是否有删除按钮
saveFullUrl(boolean) : 是否保存完整链接
disk(string) : 文件存储的磁盘,具体信息可以查看 `config/filesystems.php`
photo 、 photos 、 video 的参数默认值不一样
Expand Down
18 changes: 15 additions & 3 deletions resources/assets/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ $(function () {
var limit = options.limit;
var type = options.type

var rootpath = options.rootpath
var saveFullUrl = options.saveFullUrl

// 可多选时
var multiplechoice = options.multiplechoice

Expand Down Expand Up @@ -450,7 +453,13 @@ $(function () {
}

for (var i = 0; i < select_true_list.length; i++) {
urlList.push($(select_true_list[i]).data('url'));
var url = $(select_true_list[i]).data('url');

if (saveFullUrl == 1) {
url = rootpath + url
}

urlList.push(url);
}

urlList = thiz.unique(urlList);
Expand Down Expand Up @@ -632,7 +641,6 @@ $(function () {
var disk = options.disk;
var limit = options.limit;
var remove = options.remove;
var rootpath = options.rootpath;
var pageSize = options.pagesize;

var mediaModalCont = $('#LakeFormMediaModel' + name);
Expand Down Expand Up @@ -823,6 +831,8 @@ $(function () {
var showtitle = options.showtitle;
var showicon = options.showicon;

var saveFullUrl = options.saveFullUrl;

var mediaCont = $('.lake-form-media-'+name);
var imgShowCont = mediaCont.find('.lake-form-media-img-show');
var imgShowRowCont = mediaCont.find('.lake-form-media-img-show-row');
Expand All @@ -837,7 +847,9 @@ $(function () {
for (var i = 0; i < urlList.length; i++) {
var src = urlList[i];
if (! this.isUrl(src)) {
src = rootpath + urlList[i];
if (saveFullUrl != 1) {
src = rootpath + urlList[i];
}
}

var html = '<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3 lake-form-media-preview-item" data-src="'+urlList[i]+'">';
Expand Down
51 changes: 38 additions & 13 deletions src/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Field extends BaseField

protected $resize = [];

protected $saveFullUrl = false;

protected $type = '';
protected $disk = '';

Expand Down Expand Up @@ -106,59 +108,64 @@ public function rootpath($rootpath = null)
/**
* 禁止上传
*
* @param boolen $value
* @return $this
*/
public function disableUpload()
public function disableUpload(bool $value = true)
{
$this->disableUpload = true;
$this->disableUpload = $value;

return $this;
}

/**
* 禁止创建文件夹
*
* @param boolen $value
* @return $this
*/
public function disableCreateFolder()
public function disableCreateFolder(bool $value = true)
{
$this->disableCreateFolder = true;
$this->disableCreateFolder = $value;

return $this;
}

/**
* 显示标题
*
* @param boolen $value
* @return $this
*/
public function enableShowTitle()
public function enableShowTitle(bool $value = true)
{
$this->enableShowTitle = true;
$this->enableShowTitle = $value;

return $this;
}

/**
* 可多选
*
* @param boolen $value
* @return $this
*/
public function enableMultipleChoice()
public function enableMultipleChoice(bool $value = true)
{
$this->enableMultipleChoice = true;
$this->enableMultipleChoice = $value;

return $this;
}

/**
* 显示图标
*
* @param boolen $value
* @return $this
*/
public function showIcon()
public function showIcon(bool $value = true)
{
$this->showIcon = true;
$this->showIcon = $value;

return $this;
}
Expand All @@ -175,6 +182,19 @@ public function resize($width, $height)
return $this;
}

/**
* 保存完整链接
*
* @param boolen $value
* @return $this
*/
public function saveFullUrl(bool $value = true)
{
$this->saveFullUrl = $value;

return $this;
}

/**
* 设置类型
*
Expand Down Expand Up @@ -233,12 +253,12 @@ public function limit($limit = 1)
/**
* 移除
*
* @param boolen $remove
* @param boolen $value
* @return $this
*/
public function remove($remove = false)
public function remove(bool $value = true)
{
$this->remove = $remove;
$this->remove = $value;

return $this;
}
Expand Down Expand Up @@ -335,6 +355,7 @@ public function render()
$pageSize = $this->pageSize;
$remove = ($this->remove == true) ? 1 : 0;

$rootpath = "";
if (! empty($this->rootpath)) {
$rootpath = $this->rootpath;
} else {
Expand Down Expand Up @@ -373,6 +394,8 @@ public function render()
$showIcon = ($this->showIcon == true) ? 1 : 0;

$resize = $this->resize;

$saveFullUrl = ($this->saveFullUrl == true) ? 1 : 0;

$this->addVariables([
'options' => [
Expand All @@ -391,6 +414,8 @@ public function render()

'resize' => implode(',', $resize),

'saveFullUrl' => $saveFullUrl,

'rootpath' => $rootpath,
'get_files_url' => $this->listUrl,
'upload_url' => $this->uploadUrl,
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php

return [
'1.0.25' => [
'添加自定义存储磁盘方式。',
],
'1.0.26' => [
'修复帮助函数没有适配自定义存储磁盘问题。',
],
Expand All @@ -16,4 +13,7 @@
'1.0.30' => [
'增加图片裁剪。更新JS。',
],
'1.0.31' => [
'增加保存全路径。',
],
];

0 comments on commit 136a425

Please sign in to comment.