Add files via upload

This commit is contained in:
niubility000 2021-11-22 13:01:51 +08:00 committed by GitHub
parent b7149e7ea1
commit 51d4a07965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,16 @@
<header-bar> <header-bar>
<action icon="close" :label="$t('buttons.close')" @action="close()" /> <action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ name }}</title> <title>{{ name }}</title>
<button
v-if="address!=='none'"
:disabled="loading"
class="action"
@click="switchShowLocation"
aria-label="Location Info"
title="Location Info"
>
<i :style="{color: showLocation? 'blue':'white'}" class="material-icons">location_on</i>
</button>
<action <action
:disabled="loading" :disabled="loading"
v-if="isResizeEnabled && req.type === 'image'" v-if="isResizeEnabled && req.type === 'image'"
@ -55,7 +65,7 @@
</div> </div>
<template v-else> <template v-else>
<div class="preview"> <div class="preview">
<ExtendedImage v-if="req.type == 'image'" :src="raw"></ExtendedImage> <ExtendedImage v-if="req.type == 'image'" :src="raw" ref="container"></ExtendedImage>
<audio <audio
v-else-if="req.type == 'audio'" v-else-if="req.type == 'audio'"
ref="player" ref="player"
@ -114,6 +124,11 @@
</a> </a>
</div> </div>
</div> </div>
<div v-if="showLocation && address!=='none'">
<span id="locationInfo" align="center">{{address}}</span>
</div>
</div> </div>
</template> </template>
@ -151,6 +166,7 @@ import throttle from "lodash.throttle";
import HeaderBar from "@/components/header/HeaderBar"; import HeaderBar from "@/components/header/HeaderBar";
import Action from "@/components/header/Action"; import Action from "@/components/header/Action";
import ExtendedImage from "@/components/files/ExtendedImage"; import ExtendedImage from "@/components/files/ExtendedImage";
import {EXIF} from 'exif-js';
const mediaTypes = ["image", "video", "audio", "blob"]; const mediaTypes = ["image", "video", "audio", "blob"];
@ -175,6 +191,8 @@ export default {
autoPlay: false, autoPlay: false,
previousRaw: "", previousRaw: "",
nextRaw: "", nextRaw: "",
address:'none',
showLocation: false,
}; };
}, },
computed: { computed: {
@ -216,16 +234,69 @@ export default {
this.updatePreview(); this.updatePreview();
this.toggleNavigation(); this.toggleNavigation();
}, },
raw: function () {
this.address='none';
this.getImgLocation();
},
}, },
async mounted() { async mounted() {
window.addEventListener("keydown", this.key); window.addEventListener("keydown", this.key);
this.listing = this.oldReq.items; this.listing = this.oldReq.items;
this.updatePreview(); this.updatePreview();
this.getImgLocation();
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("keydown", this.key); window.removeEventListener("keydown", this.key);
}, },
methods: { methods: {
switchShowLocation(){
this.showLocation=!this.showLocation;
},
getImgLocation(){
this.$nextTick(() => {
if(this.req.type == 'image'){
let _this = this
EXIF.getData(this.$refs.container,function(){
const imgLon = EXIF.getTag(this, 'GPSLongitude')
const imgLat = EXIF.getTag(this, 'GPSLatitude')
let lon, lat
if(imgLon && imgLat){
if(EXIF.getTag(this, 'GPSLongitudeRef')=="E") {
lon = (imgLon[0] + imgLon[1]/60 + imgLon[2]/60/60).toFixed(7);
} else {
lon = -(imgLon[0] + imgLon[1]/60 + imgLon[2]/60/60).toFixed(7);
}
if(EXIF.getTag(this, 'GPSLatitudeRef')=="N") {
lat = (imgLat[0] + imgLat[1]/60 + imgLat[2]/60/60).toFixed(7);
} else {
lat = -(imgLat[0] + imgLat[1]/60 + imgLat[2]/60/60).toFixed(7);
}
fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}&zoom=18&addressdetails=0`)
.then((response) => {
if (response.status === 200) {
return response.json()
} else {
return {}
}
})
.then((data) => {
if(data.display_name.length==0){
_this.address = 'none'
} else {
_this.address = data.display_name
}
})
} else {
_this.address = 'none'
}
})
} else {
this.address = 'none'
}
})
},
deleteFile() { deleteFile() {
this.$store.commit("showHover", { this.$store.commit("showHover", {
prompt: "delete", prompt: "delete",
@ -363,3 +434,17 @@ export default {
}, },
}; };
</script> </script>
<style>
#locationInfo {
position:fixed;
bottom:0em;
left:50%;
background: #6f6f6f;
transform:translateX(-50%);
border:0.5em solid #6f6f6f;
border-radius: 0.5em;
color: #fff;
z-index: 99999;
}
</style>