[share] navigator.share
This commit is contained in:
parent
8c1b9faa46
commit
bb34702222
|
@ -4,6 +4,10 @@
|
||||||
<Icon v="share"/>
|
<Icon v="share"/>
|
||||||
<T>share</T>:
|
<T>share</T>:
|
||||||
</p>
|
</p>
|
||||||
|
<button class="btn btn-primary" v-if="hasShareApi" @click="shareApi">
|
||||||
|
<Icon v="share"/>
|
||||||
|
<span class="d-none d-md-inline"><T>share</T></span>
|
||||||
|
</button>
|
||||||
<SquareButton v-for="network in networks" :key="network" :link="link(network)" :colour="colour(network)" :aria-label="network">
|
<SquareButton v-for="network in networks" :key="network" :link="link(network)" :colour="colour(network)" :aria-label="network">
|
||||||
<Icon :v="icon(network)" set="b"/>
|
<Icon :v="icon(network)" set="b"/>
|
||||||
</SquareButton>
|
</SquareButton>
|
||||||
|
@ -58,6 +62,7 @@
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
hasShareApi: false,
|
||||||
preset: {
|
preset: {
|
||||||
url: this.$base + this.$route.path,
|
url: this.$base + this.$route.path,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
|
@ -69,6 +74,11 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
if (process.client) {
|
||||||
|
this.hasShareApi = navigator.share !== undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
link(network) {
|
link(network) {
|
||||||
return NETWORKS[network](this.preset);
|
return NETWORKS[network](this.preset);
|
||||||
|
@ -78,7 +88,14 @@
|
||||||
},
|
},
|
||||||
icon(network) {
|
icon(network) {
|
||||||
return ICONS[network] || network;
|
return ICONS[network] || network;
|
||||||
}
|
},
|
||||||
}
|
shareApi() {
|
||||||
|
navigator.share({
|
||||||
|
url: this.preset.url,
|
||||||
|
title: this.preset.title,
|
||||||
|
text: this.preset.extra.text,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Reference in New Issue