mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-07 04:59:37 +02:00
First webui commit
This commit is contained in:
parent
e38f5d08ab
commit
c4611b92f8
2011 changed files with 30382 additions and 1874 deletions
50
webui/node_modules/vue-auth-image/vue-auth-image.js
generated
vendored
Normal file
50
webui/node_modules/vue-auth-image/vue-auth-image.js
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
;(function () {
|
||||
var vueAuthImage = {};
|
||||
var axios = typeof require === 'function'
|
||||
? require('axios')
|
||||
: window.Axios;
|
||||
|
||||
if (!axios) {
|
||||
throw new Error('[vue-auth-image] cannot locate Axios');
|
||||
}
|
||||
|
||||
function setImgSrc(el, binding) {
|
||||
if (binding.oldValue === undefined || binding.value !== binding.oldValue) {
|
||||
var imageUrl = binding.value;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: imageUrl,
|
||||
responseType: 'arraybuffer'
|
||||
})
|
||||
.then(function(resp) {
|
||||
var mimeType = resp.headers['content-type'].toLowerCase();
|
||||
var imgBase64 = new Buffer(resp.data, 'binary').toString('base64');
|
||||
el.src = 'data:' + mimeType + ';base64,' + imgBase64;
|
||||
}).catch((function() {
|
||||
el.src = imageUrl;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
vueAuthImage.install = function(Vue) {
|
||||
Vue.directive('auth-image', {
|
||||
bind: function(el, binding) {
|
||||
setImgSrc(el, binding);
|
||||
},
|
||||
componentUpdated: function(el, binding) {
|
||||
setImgSrc(el, binding);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof exports == 'object') {
|
||||
module.exports = vueAuthImage;
|
||||
} else if (typeof define == 'function' && define.amd) {
|
||||
define([], function() {
|
||||
return vueAuthImage;
|
||||
});
|
||||
} else if (window.Vue) {
|
||||
window.VueAuthImage = vueAuthImage;
|
||||
Vue.use(vueAuthImage);
|
||||
}
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue