切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Karson
8 years ago
提交
ec0eefd16ae9a980141e92bffbc54d40816f2f0e
1 个父辈
3cac7c1f
统一上传接口的回传格式
新增附件通过summernote上传 修正wipecache为小写
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
51 行增加
和
27 行删除
application/admin/controller/Ajax.php
application/admin/lang/zh-cn/index.php
application/admin/view/common/header.html
application/admin/view/general/attachment/add.html
application/extra/upload.php
public/assets/js/backend/general/attachment.js
public/assets/js/require-upload.js
application/admin/controller/Ajax.php
查看文件 @
ec0eefd
...
...
@@ -187,10 +187,13 @@ class Ajax extends Backend
//判断是否已经存在附件
$sha1
=
$file->hash
();
$uploaded
= model("
attachment
")->where('sha1',
$sha1
)->find();
if(
$uploaded
){
$this->code
= 200;
$this->data
=
$uploaded['url']
;
$uploaded
= model("
attachment
")->where('sha1',
$sha1
)->find();
if (
$uploaded
)
{
$this->code
= 1;
$this->data
= [
'url' =>
$uploaded['url']
];
return;
}
...
...
@@ -245,8 +248,10 @@ class Ajax extends Backend
'sha1' =>
$sha1
,
);
model("
attachment
")->create(array_filter(
$params
));
$this->code
= 200;
$this->data
=
$uploadDir
.
$splInfo->getSaveName
();
$this->code
= 1;
$this->data
= [
'url' =>
$uploadDir
.
$splInfo->getSaveName
()
];
}
else
{
...
...
@@ -343,22 +348,27 @@ class Ajax extends Backend
/**
* 清空系统缓存
*/
public
function
wipe
C
ache
()
public
function
wipe
c
ache
()
{
$wipe_cache_type
=
[
'TEMP_PATH'
,
'LOG_PATH'
,
'CACHE_PATH'
];
foreach
(
$wipe_cache_type
as
$item
)
{
if
(
$item
==
'LOG_PATH'
)
{
foreach
(
$wipe_cache_type
as
$item
)
{
if
(
$item
==
'LOG_PATH'
)
{
$dirs
=
(
array
)
glob
(
constant
(
$item
)
.
'*'
);
foreach
(
$dirs
as
$dir
)
{
foreach
(
$dirs
as
$dir
)
{
array_map
(
'unlink'
,
(
array
)
glob
(
$dir
.
DIRECTORY_SEPARATOR
.
'*.*'
));
}
array_map
(
'rmdir'
,
$dirs
);
}
else
{
}
else
{
array_map
(
'unlink'
,
(
array
)
glob
(
constant
(
$item
)
.
DIRECTORY_SEPARATOR
.
'*.*'
));
}
}
Cache
::
clear
();
$this
->
success
(
'清空系统缓存成功!'
)
;
$this
->
code
=
1
;
}
}
...
...
application/admin/lang/zh-cn/index.php
查看文件 @
ec0eefd
...
...
@@ -28,4 +28,6 @@ return [
'Login successful'
=>
'登录成功!'
,
'Logout successful'
=>
'退出成功!'
,
'Verification code is incorrect'
=>
'验证码不正确'
,
'Wipe cache completed'
=>
'清除缓存成功'
,
'Wipe cache failed'
=>
'清除缓存失败'
,
];
...
...
application/admin/view/common/header.html
查看文件 @
ec0eefd
...
...
@@ -43,7 +43,7 @@
</li>
<li>
<a
href=
"javascript:;"
data-toggle=
"wipe
C
ache"
title=
"清空缓存"
>
<a
href=
"javascript:;"
data-toggle=
"wipe
c
ache"
title=
"清空缓存"
>
<i
class=
"fa fa-trash"
></i>
</a>
</li>
...
...
application/admin/view/general/attachment/add.html
查看文件 @
ec0eefd
...
...
@@ -23,7 +23,14 @@
<div
class=
"form-group"
>
<label
for=
"c-local"
class=
"control-label col-xs-12 col-sm-2"
></label>
<div
class=
"col-xs-12 col-sm-8"
>
<button
id=
"plupload-local"
class=
"btn btn-primary plupload"
data-url=
"{:url('ajax/upload')}"
><i
class=
"fa fa-upload"
></i>
{:__("Upload to local")}
</button>
<button
id=
"plupload-local"
class=
"btn btn-primary plupload"
data-url=
"{:url('ajax/upload')}"
data-after-upload=
"afteruploadcallback"
><i
class=
"fa fa-upload"
></i>
{:__("Upload to local")}
</button>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"c-local"
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Upload by summernote')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<textarea
name=
"row[summernote]"
id=
"c-summernote"
cols=
"30"
rows=
"5"
class=
"summernote"
></textarea>
</div>
</div>
</form>
...
...
application/extra/upload.php
查看文件 @
ec0eefd
...
...
@@ -3,9 +3,9 @@
//上传配置
return
[
/**
* 上传地址,如果不使用又拍云,则可以使用
/
ajax/upload
* 上传地址,如果不使用又拍云,则可以使用ajax/upload
*/
'uploadurl'
=>
'
/admin/
ajax/upload'
,
'uploadurl'
=>
'ajax/upload'
,
/**
* 又拍云或本机的CDN地址
*/
...
...
public/assets/js/backend/general/attachment.js
查看文件 @
ec0eefd
...
...
@@ -56,7 +56,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'config'], function (
thumb
:
function
(
value
,
row
,
index
)
{
//console.log(row);
if
(
row
.
mimetype
.
indexOf
(
"image"
)
>
-
1
)
{
if
(
Config
.
upload
.
bucket
.
replace
(
/^
\s
+|
\s
+$/gm
,
''
).
length
===
0
)
{
if
(
Config
.
upload
.
bucket
.
replace
(
/^
\s
+|
\s
+$/gm
,
''
).
length
===
0
)
{
return
'<a href="'
+
Config
.
upload
.
cdnurl
+
value
+
'" target="_blank"><img src="'
+
Config
.
upload
.
cdnurl
+
value
+
'" alt="" style="max-height:90px;max-width:120px"></a>'
;
}
else
{
return
'<a href="'
+
Config
.
upload
.
cdnurl
+
value
+
'" target="_blank"><img src="'
+
Config
.
upload
.
cdnurl
+
value
+
'!/fwfh/50x50" alt=""></a>'
;
...
...
public/assets/js/require-upload.js
查看文件 @
ec0eefd
...
...
@@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
plupload
:
function
(
element
,
onAfterUpload
)
{
element
=
typeof
element
==
'undefined'
?
Upload
.
config
.
classname
:
element
;
$
(
element
,
Upload
.
config
.
container
).
each
(
function
()
{
var
that
=
this
;
var
id
=
$
(
this
).
prop
(
"id"
);
var
url
=
$
(
this
).
data
(
"url"
);
var
maxsize
=
$
(
this
).
data
(
"maxsize"
);
...
...
@@ -69,17 +70,21 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
try
{
var
ret
=
JSON
.
parse
(
info
.
response
);
if
(
ret
.
hasOwnProperty
(
'code'
))
{
ret
.
data
=
ret
.
code
==
200
?
ret
.
data
:
ret
.
data
;
ret
.
data
=
ret
.
code
==
200
?
ret
:
ret
.
data
;
ret
.
code
=
ret
.
code
==
200
?
1
:
ret
.
code
;
var
data
=
ret
.
hasOwnProperty
(
"data"
)
&&
ret
.
data
!=
""
?
ret
.
data
:
null
;
var
msg
=
ret
.
hasOwnProperty
(
"msg"
)
&&
ret
.
msg
!=
""
?
ret
.
msg
:
""
;
$
(
"input[data-plupload-id='"
+
id
+
"-text']"
).
val
(
data
);
var
afterUpload
=
$
(
"#"
+
id
).
data
(
"after-upload"
);
if
(
afterUpload
&&
typeof
Upload
.
api
.
custom
[
afterUpload
]
==
'function'
)
{
Upload
.
api
.
custom
[
afterUpload
].
call
(
info
,
id
,
data
);
}
if
(
typeof
onAfterUpload
==
'function'
)
{
onAfterUpload
.
call
(
info
,
id
,
data
);
if
(
ret
.
code
===
1
)
{
$
(
"input[data-plupload-id='"
+
id
+
"-text']"
).
val
(
data
.
url
);
var
afterUpload
=
$
(
"#"
+
id
).
data
(
"after-upload"
);
if
(
afterUpload
&&
typeof
Upload
.
api
.
custom
[
afterUpload
]
==
'function'
)
{
Upload
.
api
.
custom
[
afterUpload
].
call
(
that
,
data
);
}
if
(
typeof
onAfterUpload
==
'function'
)
{
onAfterUpload
.
call
(
that
,
data
);
}
}
else
{
Toastr
.
error
(
msg
?
msg
:
__
(
'Operation failed'
));
}
}
else
{
Toastr
.
error
(
e
.
message
+
"(code:-2)"
);
...
...
@@ -137,8 +142,8 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
},
custom
:
{
//自定义上传完成回调
afteruploadcallback
:
function
(
id
,
response
)
{
console
.
log
(
this
,
id
,
response
);
afteruploadcallback
:
function
(
response
)
{
console
.
log
(
this
,
response
);
alert
(
"Custom Callback,Response URL:"
+
response
.
url
);
},
},
...
...
请
注册
或
登录
后发表评论