-
-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathembed.js
More file actions
168 lines (166 loc) * 5.29 KB
/
embed.js
File metadata and controls
168 lines (166 loc) * 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
const getAliOSSCreds = (params) => {
return request({
url: "admin/base/getOssToken",
method: "get",
params
});
};
function userupLoad(user) {{
let params = {};
params.type = fileType;
return getAliOSSCreds(params).then((res) => {
const Oss = require("ali-oss");
const client = new Oss({
region: res.region,
secure: true,
accessKeyId: res.accessKeyId,
accessKeySecret: res.accessKeySecret,
stsToken: res.securityToken,
bucket: res.bucket,
endpoint: res.endpoint
});
methods:
//Wen Jian Da Xiao Xian Zhi
{
let isLimit = file.size / 1024 / 1024 <= 1000;
if (!isLimit) {
this.$message.warning("Shang Chuan Wen Jian Bu Chao Guo 1G");
return false;
} }
let key = res.dir + "/" + item.name;
if (option != null) {
return client.multipartUpload(key, item, { //Qie Pian Shang Chuan
progress: function (p, checkpoint) {
option.onProgress({percent: Math.floor(p * 100)}); // Hong Fa el-uploadZu Jian De onProgressFang Fa
}
})
} else {
return client.put(key, item);
}
});
}
}
function copyurl(node){
var clipboard = new ClipboardJS(".copy-btn", {
text: function(trigger) {
return $("#"+node).val();
}
});
clipboard.on('success', function (e) {
layer.msg('Fu Zhi Cheng Gong !', {icon: 1});
});
clipboard.on('error', function (e) {
layer.msg('Fu Zhi Shi Bai ,Qing Chang An Lian Jie Hou Shou Dong Fu Zhi ', {icon: 2});
});
}
function getFileName(path){
var pos1 = path.lastIndexOf('/');
var pos2 = path.lastIndexOf('\\');
var pos = Math.max(pos1, pos2)
if( pos<0 )
return path;
else
return path.substring(pos+1);
}
layui.use(['form','upload'], function(){
var form = layui.form;
var upload = layui.upload;
var predata;
form.render();
upload.render({
elem: '#multiple'
,url: "api.jsp"
,accept: 'file'
//,acceptMime: 'image/*'
,size: 102400
,drag: true
,auto: false
,data: {}
,headers: {'X-OSS-server-side-encrpytion': 'AES256'}
,bindAction: '#uploadBtn'
,choose: function(obj) {
var filename = $("input[name=file]").val();
if(filename == ''){
layer.alert('Qing Xuan Ze Wen Jian !', {icon: 2, skin: 'layui-layer-molv', closeBtn: 0});
throw new Error('upload failed');
}
filename = getFileName(filename);
layer.msg('Teng Xun Fan Bing Du Yin Qing Cha Sha Wen Jian Zhong ...', {icon: 16,time: 2000,shade:[0.3, "#000"]});
var that = this;
$.ajax({
type : "POST",
url : "https://api.isoyu.com/upload/api.jsp?aup=pre_upload&appCode=B586A14C4EC466D33682F8626CCB3794&auturl=api.isoyu.com",
data : {filename:filename},
dataType : 'json',
success : function(data) {
layer.closeAll();
if(data.code == 0){
predata = data.data;
that.data = {'Cache-Control':'max-age=2592000', 'Content-Disposition':'attachment', 'OSSAccessKeyId':predata.accessKeyId, 'Signature':predata.signature, 'host':predata.host, 'id':predata.id, 'key':predata.ossPath, 'policy':predata.policy, 'success_action_status':'200'};
that.url = 'https://' + predata.host + '/';
$('#uploadBtn').click();
}else{
layer.alert(data.msg, {icon: 2, skin: 'layui-layer-molv', closeBtn: 0});
$("input[name=file]").val('')
}
},
error: function () {
layer.closeAll();
layer.alert('Shang Chuan Shi Bai !Jie Kou Cuo Wu ', {icon: 2});
}
});
}
,before: function(obj) {
layui.element.progress('demo', '0%');
layer.load();
}
,progress: function(n) {
var percent = n + '%';
layui.element.progress('demo', percent);
if (n==100){
layer.msg('Shang Chuan Cheng Gong ', {icon: 16,time: 10000,shade:[0.3, "#000"]});
}
}
,done: function(res){
layer.closeAll();
$.ajax({
type : "POST",
url : "https://api.isoyu.com/upload/api.jsp?aup=complete_upload&appCode=B586A14C4EC466D33682F8626CCB3794&auturl=api.isoyu.com",
data : {id: predata.id},
dataType : 'json',
success : function(data) {
layer.closeAll();
if(data.code == 0){
var imgurlcdn = 'https://cdn.pan.360pan.ml/' + predata.ossPath;
var imgurl = 'https://' + predata.host + '/' + predata.ossPath;
var imgurlsy = 'https://' + predata.host + '/' + predata.ossPath + '?x-oss-process=image/watermark,size_30,text_eXl5LnNn,color_FFFFFF,shadow_50,t_100,g_se,x_10,y_10';
var id = predata.id;
$("#img-thumb a").attr('href',imgurl);
$("#img-thumb img").attr('src',imgurl);
$("#cdnurl").val(imgurlcdn);
$("#url").val(imgurl);
$("#urlsy").val(imgurlsy);
$("#html").val("
");
$("#markdown").val("");
$("#bbcode").val("[img]" + imgurl + "[/img]");
$("#dlink").val(id);
$("#imgshow").show();
$("input[name=file]").val('')
}else{
layer.alert(data.msg, {icon: 2, skin: 'layui-layer-molv', closeBtn: 0});
}
},
error: function () {
layer.closeAll();
layer.alert('Shang Chuan Shi Bai !Jie Kou Cuo Wu ', {icon: 2});
}
});
$("input[name=file]").val('')
}
,error: function(){
layer.closeAll();
layer.alert("Wen Jian Shang Chuan Shi Bai !", {icon: 2, skin: 'layui-layer-molv', closeBtn: 0});
$("input[name=file]").val('')
}
});
});