作者 zhangyang

提交

@@ -4,7 +4,7 @@ intro = 使用七牛云储存,支持直传、服务器中转、分片上传 @@ -4,7 +4,7 @@ intro = 使用七牛云储存,支持直传、服务器中转、分片上传
4 author = FastAdmin 4 author = FastAdmin
5 website = https://www.fastadmin.net 5 website = https://www.fastadmin.net
6 version = 1.2.4 6 version = 1.2.4
7 -state = 1 7 +state = 0
8 url = /addons/qiniu 8 url = /addons/qiniu
9 license = basic 9 license = basic
10 licenseto = 10789 10 licenseto = 10789
@@ -6,25 +6,15 @@ return [ @@ -6,25 +6,15 @@ return [
6 'response_send' => [ 6 'response_send' => [
7 'loginvideo', 7 'loginvideo',
8 ], 8 ],
9 - 'module_init' => [  
10 - 'qiniu',  
11 - 'third',  
12 - ],  
13 - 'upload_config_init' => [  
14 - 'qiniu',  
15 - ],  
16 - 'upload_delete' => [  
17 - 'qiniu',  
18 - ],  
19 - 'app_init' => [  
20 - 'qiniu',  
21 - ],  
22 'user_delete_successed' => [ 9 'user_delete_successed' => [
23 'third', 10 'third',
24 ], 11 ],
25 'user_logout_successed' => [ 12 'user_logout_successed' => [
26 'third', 13 'third',
27 ], 14 ],
  15 + 'module_init' => [
  16 + 'third',
  17 + ],
28 'action_begin' => [ 18 'action_begin' => [
29 'third', 19 'third',
30 ], 20 ],
1 define([], function () { 1 define([], function () {
2 - require(['../addons/bootstrapcontextmenu/js/bootstrap-contextmenu'], function (undefined) {  
3 - if (Config.controllername == 'index' && Config.actionname == 'index') {  
4 - $("body").append(  
5 - '<div id="context-menu">' +  
6 - '<ul class="dropdown-menu" role="menu">' +  
7 - '<li><a tabindex="-1" data-operate="refresh"><i class="fa fa-refresh fa-fw"></i>刷新</a></li>' +  
8 - '<li><a tabindex="-1" data-operate="refreshTable"><i class="fa fa-table fa-fw"></i>刷新表格</a></li>' +  
9 - '<li><a tabindex="-1" data-operate="close"><i class="fa fa-close fa-fw"></i>关闭</a></li>' +  
10 - '<li><a tabindex="-1" data-operate="closeOther"><i class="fa fa-window-close-o fa-fw"></i>关闭其他</a></li>' +  
11 - '<li class="divider"></li>' +  
12 - '<li><a tabindex="-1" data-operate="closeAll"><i class="fa fa-power-off fa-fw"></i>关闭全部</a></li>' +  
13 - '</ul>' +  
14 - '</div>');  
15 -  
16 - $(".nav-addtabs").contextmenu({  
17 - target: "#context-menu",  
18 - scopes: 'li[role=presentation]',  
19 - onItem: function (e, event) {  
20 - var $element = $(event.target);  
21 - var tab_id = e.attr('id');  
22 - var id = tab_id.substr('tab_'.length);  
23 - var con_id = 'con_' + id;  
24 - switch ($element.data('operate')) {  
25 - case 'refresh':  
26 - $("#" + con_id + " iframe").attr('src', function (i, val) {  
27 - return val;  
28 - });  
29 - break;  
30 - case 'refreshTable':  
31 - try {  
32 - if ($("#" + con_id + " iframe").contents().find(".btn-refresh").size() > 0) {  
33 - $("#" + con_id + " iframe")[0].contentWindow.$(".btn-refresh").trigger("click");  
34 - }  
35 - } catch (e) {  
36 -  
37 - }  
38 - break;  
39 - case 'close':  
40 - if (e.find(".close-tab").length > 0) {  
41 - e.find(".close-tab").click();  
42 - }  
43 - break;  
44 - case 'closeOther':  
45 - e.parent().find("li[role='presentation']").each(function () {  
46 - if ($(this).attr('id') == tab_id) {  
47 - return;  
48 - }  
49 - if ($(this).find(".close-tab").length > 0) {  
50 - $(this).find(".close-tab").click();  
51 - }  
52 - });  
53 - break;  
54 - case 'closeAll':  
55 - e.parent().find("li[role='presentation']").each(function () {  
56 - if ($(this).find(".close-tab").length > 0) {  
57 - $(this).find(".close-tab").click();  
58 - }  
59 - });  
60 - break;  
61 - default:  
62 - break;  
63 - }  
64 - }  
65 - });  
66 - }  
67 - $(document).on('click', function () { // iframe内点击 隐藏菜单  
68 - try {  
69 - top.window.$(".nav-addtabs").contextmenu("closemenu");  
70 - } catch (e) {  
71 - }  
72 - });  
73 -  
74 -});  
75 -//修改上传的接口调用  
76 -require(['upload'], function (Upload) {  
77 -  
78 - var _onInit = Upload.events.onInit;  
79 - //初始化中完成判断  
80 - Upload.events.onInit = function () {  
81 - _onInit.apply(this, Array.prototype.slice.apply(arguments));  
82 - //如果上传接口不是七牛云,则不处理  
83 - if (this.options.url !== Config.upload.uploadurl) {  
84 - return;  
85 - }  
86 - var _success = this.options.success;  
87 -  
88 - $.extend(this.options, {  
89 - //关闭自动处理队列功能  
90 - autoQueue: false,  
91 - chunkSuccess: function (chunk, file, response) {  
92 - this.contexts = this.contexts ? this.contexts : [];  
93 - this.contexts.push(typeof response.ctx !== 'undefined' ? response.ctx : response.data.ctx);  
94 - },  
95 - chunksUploaded: function (file, done) {  
96 - var that = this;  
97 - var params = $(that.element).data("params") || {};  
98 - var category = typeof params.category !== 'undefined' ? params.category : ($(that.element).data("category") || '');  
99 - category = typeof category === 'function' ? category.call(this, file) : category;  
100 - Fast.api.ajax({  
101 - url: "/addons/qiniu/index/upload",  
102 - data: {  
103 - action: 'merge',  
104 - filesize: file.size,  
105 - filename: file.name,  
106 - chunkid: file.upload.uuid,  
107 - chunkcount: file.upload.totalChunkCount,  
108 - width: file.width || 0,  
109 - height: file.height || 0,  
110 - type: file.type,  
111 - category: category,  
112 - qiniutoken: Config.upload.multipart.qiniutoken,  
113 - contexts: this.contexts  
114 - },  
115 - }, function (data, ret) {  
116 - done(JSON.stringify(ret));  
117 - return false;  
118 - }, function (data, ret) {  
119 - file.accepted = false;  
120 - that._errorProcessing([file], ret.msg);  
121 - return false;  
122 - });  
123 -  
124 - },  
125 - });  
126 -  
127 - //先移除已有的事件  
128 - this.off("success", _success).on("success", function (file, response) {  
129 - var that = this;  
130 - var ret = {code: 0, msg: response};  
131 - try {  
132 - ret = typeof response === 'string' ? JSON.parse(response) : response;  
133 - if (file.xhr.status === 200) {  
134 - if (Config.upload.uploadmode === 'client') {  
135 - if (typeof ret.key !== 'undefined') {  
136 - ret = {code: 1, msg: "", data: {url: '/' + ret.key, hash: ret.hash}};  
137 - }  
138 - }  
139 -  
140 - if (ret.code == 1) {  
141 - var url = ret.data.url || '';  
142 - var params = $(that.element).data("params") || {};  
143 - var category = typeof params.category !== 'undefined' ? params.category : ($(that.element).data("category") || '');  
144 - category = typeof category === 'function' ? category.call(that, file) : category;  
145 - Fast.api.ajax({  
146 - url: "/addons/qiniu/index/notify",  
147 - data: {name: file.name, url: ret.data.url, hash: ret.data.hash, size: file.size, width: file.width || 0, height: file.height || 0, type: file.type, category: category, qiniutoken: Config.upload.multipart.qiniutoken}  
148 - }, function () {  
149 - return false;  
150 - }, function () {  
151 - return false;  
152 - });  
153 - } else {  
154 - console.error(ret);  
155 - }  
156 - } else {  
157 - console.error(file.xhr);  
158 - }  
159 - } catch (e) {  
160 - console.error(e);  
161 - }  
162 - _success.call(this, file, ret);  
163 - });  
164 -  
165 - this.on("addedfile", function (file) {  
166 - var that = this;  
167 - setTimeout(function () {  
168 - if (file.status === 'error') {  
169 - return;  
170 - }  
171 -  
172 - var md5 = ''; //七牛云无需本地获取文件MD5  
173 - var chunk = that.options.chunking && file.size > that.options.chunkSize ? 1 : 0;  
174 - var params = $(that.element).data("params") || {};  
175 - var category = typeof params.category !== 'undefined' ? params.category : ($(that.element).data("category") || '');  
176 - category = typeof category === 'function' ? category.call(that, file) : category;  
177 - Fast.api.ajax({  
178 - url: "/addons/qiniu/index/params",  
179 - data: {method: 'POST', category: category, md5: md5, name: file.name, type: file.type, size: file.size, chunk: chunk, chunksize: that.options.chunkSize, qiniutoken: Config.upload.multipart.qiniutoken},  
180 - }, function (data) {  
181 - file.qiniutoken = data.qiniutoken;  
182 - file.params = data;  
183 - file.category = category;  
184 -  
185 - if (file.status != 'error') {  
186 - //开始上传  
187 - that.enqueueFile(file);  
188 - } else {  
189 - that.removeFile(file);  
190 - }  
191 - return false;  
192 - }, function () {  
193 - that.removeFile(file);  
194 - });  
195 - }, 0);  
196 - });  
197 -  
198 - //如果是直传模式  
199 - if (Config.upload.uploadmode === 'client') {  
200 - var _url = this.options.url;  
201 -  
202 - //分片上传时URL链接不同  
203 - this.options.url = function (files) {  
204 - this.options.headers = {"Authorization": "UpToken " + Config.upload.multipart.qiniutoken};  
205 - if (files[0].upload.chunked) {  
206 - var chunk = null;  
207 - files[0].upload.chunks.forEach(function (item) {  
208 - if (item.status === 'uploading') {  
209 - chunk = item;  
210 - }  
211 - });  
212 - if (!chunk) {  
213 - return Config.upload.uploadurl + '/mkfile/' + files[0].size;  
214 - } else {  
215 - return Config.upload.uploadurl + '/mkblk/' + chunk.dataBlock.data.size;  
216 - }  
217 - }  
218 - return _url;  
219 - };  
220 -  
221 - this.options.params = function (files, xhr, chunk) {  
222 - var params = Config.upload.multipart;  
223 - if (chunk) {  
224 - return $.extend({}, params, {  
225 - filesize: chunk.file.size,  
226 - filename: chunk.file.name,  
227 - chunkid: chunk.file.upload.uuid,  
228 - chunkindex: chunk.index,  
229 - chunkcount: chunk.file.upload.totalChunkCount,  
230 - chunkfilesize: chunk.dataBlock.data.size,  
231 - width: chunk.file.width || 0,  
232 - height: chunk.file.height || 0,  
233 - type: chunk.file.type,  
234 - });  
235 - } else {  
236 - var retParams = $.extend({}, params, files[0].params || {});  
237 - //七牛云直传使用的是token参数  
238 - retParams.token = retParams.qiniutoken;  
239 - delete retParams.qiniutoken;  
240 - return retParams;  
241 - }  
242 - };  
243 -  
244 - //分片上传时需要变更提交的内容  
245 - this.on("sending", function (file, xhr, formData) {  
246 - if (file.upload.chunked) {  
247 - var _send = xhr.send;  
248 - xhr.send = function () {  
249 - var chunk = null;  
250 - file.upload.chunks.forEach(function (item) {  
251 - if (item.status == 'uploading') {  
252 - chunk = item;  
253 - }  
254 - });  
255 - if (chunk) {  
256 - _send.call(xhr, chunk.dataBlock.data);  
257 - }  
258 - };  
259 - }  
260 - });  
261 - }  
262 - };  
263 - 2 + require(['../addons/bootstrapcontextmenu/js/bootstrap-contextmenu'], function (undefined) {
  3 + if (Config.controllername == 'index' && Config.actionname == 'index') {
  4 + $("body").append(
  5 + '<div id="context-menu">' +
  6 + '<ul class="dropdown-menu" role="menu">' +
  7 + '<li><a tabindex="-1" data-operate="refresh"><i class="fa fa-refresh fa-fw"></i>刷新</a></li>' +
  8 + '<li><a tabindex="-1" data-operate="refreshTable"><i class="fa fa-table fa-fw"></i>刷新表格</a></li>' +
  9 + '<li><a tabindex="-1" data-operate="close"><i class="fa fa-close fa-fw"></i>关闭</a></li>' +
  10 + '<li><a tabindex="-1" data-operate="closeOther"><i class="fa fa-window-close-o fa-fw"></i>关闭其他</a></li>' +
  11 + '<li class="divider"></li>' +
  12 + '<li><a tabindex="-1" data-operate="closeAll"><i class="fa fa-power-off fa-fw"></i>关闭全部</a></li>' +
  13 + '</ul>' +
  14 + '</div>');
  15 +
  16 + $(".nav-addtabs").contextmenu({
  17 + target: "#context-menu",
  18 + scopes: 'li[role=presentation]',
  19 + onItem: function (e, event) {
  20 + var $element = $(event.target);
  21 + var tab_id = e.attr('id');
  22 + var id = tab_id.substr('tab_'.length);
  23 + var con_id = 'con_' + id;
  24 + switch ($element.data('operate')) {
  25 + case 'refresh':
  26 + $("#" + con_id + " iframe").attr('src', function (i, val) {
  27 + return val;
  28 + });
  29 + break;
  30 + case 'refreshTable':
  31 + try {
  32 + if ($("#" + con_id + " iframe").contents().find(".btn-refresh").size() > 0) {
  33 + $("#" + con_id + " iframe")[0].contentWindow.$(".btn-refresh").trigger("click");
  34 + }
  35 + } catch (e) {
  36 +
  37 + }
  38 + break;
  39 + case 'close':
  40 + if (e.find(".close-tab").length > 0) {
  41 + e.find(".close-tab").click();
  42 + }
  43 + break;
  44 + case 'closeOther':
  45 + e.parent().find("li[role='presentation']").each(function () {
  46 + if ($(this).attr('id') == tab_id) {
  47 + return;
  48 + }
  49 + if ($(this).find(".close-tab").length > 0) {
  50 + $(this).find(".close-tab").click();
  51 + }
  52 + });
  53 + break;
  54 + case 'closeAll':
  55 + e.parent().find("li[role='presentation']").each(function () {
  56 + if ($(this).find(".close-tab").length > 0) {
  57 + $(this).find(".close-tab").click();
  58 + }
  59 + });
  60 + break;
  61 + default:
  62 + break;
  63 + }
  64 + }
  65 + });
  66 + }
  67 + $(document).on('click', function () { // iframe内点击 隐藏菜单
  68 + try {
  69 + top.window.$(".nav-addtabs").contextmenu("closemenu");
  70 + } catch (e) {
  71 + }
  72 + });
  73 +
264 }); 74 });
265 -  
266 if (Config.modulename === 'index' && Config.controllername === 'user' && ['login', 'register'].indexOf(Config.actionname) > -1 && $("#register-form,#login-form").length > 0 && $(".social-login").length == 0) { 75 if (Config.modulename === 'index' && Config.controllername === 'user' && ['login', 'register'].indexOf(Config.actionname) > -1 && $("#register-form,#login-form").length > 0 && $(".social-login").length == 0) {
267 $("#register-form,#login-form").append(Config.third.loginhtml || ''); 76 $("#register-form,#login-form").append(Config.third.loginhtml || '');
268 } 77 }
@@ -101,7 +101,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -101,7 +101,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
101 {field: 'ronda', title: __('Ronda'),operate:'LIKE'}, 101 {field: 'ronda', title: __('Ronda'),operate:'LIKE'},
102 {field: 'earn_score', title: __('Earn_score'),operate:false}, 102 {field: 'earn_score', title: __('Earn_score'),operate:false},
103 {field: 'unique', title: __('Unique'), operate:false}, 103 {field: 'unique', title: __('Unique'), operate:false},
104 - //{field: 'barcode_images', title: __('Barcode'),events: Table.api.events.image, formatter: Table.api.formatter.image, operate:false}, 104 + {field: 'barcode', title: __('Barcode'),events: Table.api.events.image, formatter: Table.api.formatter.image, operate:false},
105 {field: 'rank', title: __('Rank'),operate: false}, 105 {field: 'rank', title: __('Rank'),operate: false},
106 // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, 106 // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
107 // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, 107 // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
@@ -123,8 +123,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -123,8 +123,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
123 success: function (res) { 123 success: function (res) {
124 if (res.code === 1) { 124 if (res.code === 1) {
125 var domain = window.location.href.split(':')[0] + '://' + document.domain; 125 var domain = window.location.href.split(':')[0] + '://' + document.domain;
126 - var url = domain + data.barcode; 126 + var url = domain + '/uploads/20231011/fee9458c29cdccf10af7ec01155dc7f0.png';
  127 + // console.log(url);
127 var link = document.createElement('a'); 128 var link = document.createElement('a');
  129 + console.log(link);
128 link.setAttribute("download", ""); 130 link.setAttribute("download", "");
129 link.href = url; 131 link.href = url;
130 link.click(); 132 link.click();