-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinject.lua
51 lines (48 loc) · 1.08 KB
/
inject.lua
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
-- ignore *.html files
if ngx.var.uri:match(".html$") then
return "</body>"
end
local inject_div = [[
<div id="upload-inject">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/styles/iview.css">
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/iview.min.js"></script>
<style>a {color: -webkit-link}</style>
<div id="app-upload">
<upload
multiple
type="drag"
:action="uploadUrl"
:before-upload="beforeUpload">
<div style="padding: 20px 0">
<icon type="ios-cloud-upload" size="52" style="color: #3399ff"></icon>
<p>点击或拖拽文件上传</p>
</div>
</upload>
</div>
<script>
new Vue({
el: '#app-upload',
data: {
uploadUrl: ''
},
mounted() {
this.uploadApi = '/_upload'
},
methods: {
beforeUpload: function() {
this.uploadUrl = this.uploadApi + window.location.pathname
let promise = new Promise((resolve) => {
this.$nextTick(function () {
resolve(true);
})
})
return promise
}
}
})
</script>
<div>
</body>
]]
return inject_div