From c473b62aed5abca314b5eaf195cd50b3b3a5fee4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 12 Mar 2019 12:55:43 +0900 Subject: [PATCH] Follow latest Web Share Target specification --- src/client/app/desktop/views/pages/share.vue | 15 +++++++++++++-- src/client/app/mobile/views/pages/share.vue | 15 +++++++++++++-- src/client/assets/manifest.json | 7 ++++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/client/app/desktop/views/pages/share.vue b/src/client/app/desktop/views/pages/share.vue index c4ec356d9d..d20e6e864c 100644 --- a/src/client/app/desktop/views/pages/share.vue +++ b/src/client/app/desktop/views/pages/share.vue @@ -3,7 +3,7 @@

{{ this.$t('share-with', { name }) }}

- +

@@ -20,9 +20,20 @@ export default Vue.extend({ return { name: null, posted: false, - text: new URLSearchParams(location.search).get('text') + text: new URLSearchParams(location.search).get('text'), + url: new URLSearchParams(location.search).get('url'), + title: new URLSearchParams(location.search).get('title'), }; }, + computed: { + template(): string { + let t = ''; + if (this.title) t += `【${title}】\n`; + if (this.text) t += `${text}\n`; + if (this.url) t += `${url}`; + return t.trim(); + } + }, methods: { close() { window.close(); diff --git a/src/client/app/mobile/views/pages/share.vue b/src/client/app/mobile/views/pages/share.vue index 6eabbef18e..dbafc9e7ba 100644 --- a/src/client/app/mobile/views/pages/share.vue +++ b/src/client/app/mobile/views/pages/share.vue @@ -3,7 +3,7 @@

{{ $t('share-with', { name }) }}

- +

{{ $t('@.close') }} @@ -20,9 +20,20 @@ export default Vue.extend({ return { name: null, posted: false, - text: new URLSearchParams(location.search).get('text') + text: new URLSearchParams(location.search).get('text'), + url: new URLSearchParams(location.search).get('url'), + title: new URLSearchParams(location.search).get('title'), }; }, + computed: { + template(): string { + let t = ''; + if (this.title) t += `【${title}】\n`; + if (this.text) t += `${text}\n`; + if (this.url) t += `${url}`; + return t.trim(); + } + }, methods: { close() { window.close(); diff --git a/src/client/assets/manifest.json b/src/client/assets/manifest.json index 30aea9e267..895afbed36 100644 --- a/src/client/assets/manifest.json +++ b/src/client/assets/manifest.json @@ -43,6 +43,11 @@ } ], "share_target": { - "url_template": "share?text=【{title}】%0A{text}%0A{url}" + "action": "/share/", + "params": { + "title": "title", + "text": "text", + "url": "url" + } } }