mirror of
https://github.com/eiblog/eiblog.git
synced 2026-03-01 00:34:58 +08:00
update
This commit is contained in:
4
api.go
4
api.go
@@ -430,7 +430,7 @@ func apiFileUpload(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
typ := c.Request.Header.Get("Content-Type")
|
typ := c.Request.Header.Get("Content-Type")
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"name": filename,
|
"title": filename,
|
||||||
"isImage": typ[:5] == "image",
|
"isImage": typ[:5] == "image",
|
||||||
"url": url,
|
"url": url,
|
||||||
"bytes": fmt.Sprintf("%dkb", s.Size()/1000),
|
"bytes": fmt.Sprintf("%dkb", s.Size()/1000),
|
||||||
@@ -445,7 +445,7 @@ func apiFileDelete(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.String(http.StatusOK, "删掉了吗?鬼知道。。。")
|
c.String(http.StatusOK, "删掉了吗?鬼知道。。。")
|
||||||
}()
|
}()
|
||||||
name := c.PostForm("name")
|
name := c.PostForm("title")
|
||||||
if name == "" {
|
if name == "" {
|
||||||
err = errors.New("参数错误")
|
err = errors.New("参数错误")
|
||||||
return
|
return
|
||||||
|
|||||||
3
qiniu.go
3
qiniu.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/eiblog/eiblog/setting"
|
"github.com/eiblog/eiblog/setting"
|
||||||
"qiniupkg.com/api.v7/kodo"
|
"qiniupkg.com/api.v7/kodo"
|
||||||
"qiniupkg.com/api.v7/kodocli"
|
"qiniupkg.com/api.v7/kodocli"
|
||||||
|
url "qiniupkg.com/x/url.v7"
|
||||||
)
|
)
|
||||||
|
|
||||||
var qiniu_cfg = &kodo.Config{
|
var qiniu_cfg = &kodo.Config{
|
||||||
@@ -71,7 +72,7 @@ func FileUpload(name string, size int64, data io.Reader) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := kodo.MakeBaseUrl(setting.Conf.Kodo.Domain, ret.Key)
|
url := "https://" + setting.Conf.Kodo.Domain + "/" + url.Escape(key)
|
||||||
return url, nil
|
return url, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -739,11 +739,11 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
var completeFile = null;
|
var completeFile = null;
|
||||||
function fileUploadComplete (id, data) {
|
function fileUploadComplete (id, data) {
|
||||||
var li = $('#' + id).removeClass('loading').data('name', data.name)
|
var li = $('#' + id).removeClass('loading').data('title', data.title)
|
||||||
.data('url', data.url)
|
.data('url', data.url)
|
||||||
.data('image', data.isImage)
|
.data('image', data.isImage)
|
||||||
.html('<input type="hidden" name="attachment[]" value="' + data.cid + '" />'
|
.html('<input type="hidden" name="attachment[]" value="' + data.title + '" />'
|
||||||
+ '<a class="insert" target="_blank" href="###" title="点击插入文件">' + data.name + '</a><div class="info">' + data.bytes
|
+ '<a class="insert" target="_blank" href="###" title="点击插入文件">' + data.title + '</a><div class="info">' + data.bytes
|
||||||
+ ' <a class="file" target="_blank" href="'
|
+ ' <a class="file" target="_blank" href="'
|
||||||
+ data.url + '" title="查看"><i class="i-edit"></i></a>'
|
+ data.url + '" title="查看"><i class="i-edit"></i></a>'
|
||||||
+ ' <a class="delete" href="###" title="删除"><i class="i-delete"></i></a></div>')
|
+ ' <a class="delete" href="###" title="删除"><i class="i-delete"></i></a></div>')
|
||||||
@@ -763,11 +763,11 @@ $(document).ready(function() {
|
|||||||
browse_button : $('.upload-file').get(0),
|
browse_button : $('.upload-file').get(0),
|
||||||
url : '/admin/api/file-upload',
|
url : '/admin/api/file-upload',
|
||||||
runtimes : 'html5,flash,html4',
|
runtimes : 'html5,flash,html4',
|
||||||
flash_swf_url : '/static/admin/js/Moxie.swf',
|
flash_swf_url : '/static/admin/Moxie.swf',
|
||||||
drop_element : $('.upload-area').get(0),
|
drop_element : $('.upload-area').get(0),
|
||||||
filters : {
|
filters : {
|
||||||
max_file_size : '2mb',
|
max_file_size : '2mb',
|
||||||
<!-- mime_types : [{'title' : '允许上传的文件', 'extensions' : 'gif,jpg,jpeg,png,tiff,bmp'}], -->
|
// mime_types : [{'title' : '允许上传的文件', 'extensions' : 'gif,jpg,jpeg,png,tiff,bmp'}],
|
||||||
prevent_duplicates : true
|
prevent_duplicates : true
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -824,9 +824,9 @@ $(document).ready(function() {
|
|||||||
var file = $('a.insert', el).text();
|
var file = $('a.insert', el).text();
|
||||||
$('.delete', el).click(function () {
|
$('.delete', el).click(function () {
|
||||||
if (confirm('确认要删除文件 %s 吗?'.replace('%s', file))) {
|
if (confirm('确认要删除文件 %s 吗?'.replace('%s', file))) {
|
||||||
var name = $(this).parents('li').data('name');
|
var title = $(this).parents('li').data('title');
|
||||||
$.post('/admin/api/file-delete',
|
$.post('/admin/api/file-delete',
|
||||||
{'name' : name},
|
{'title' : title},
|
||||||
function () {
|
function () {
|
||||||
$(el).fadeOut(function () {
|
$(el).fadeOut(function () {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user