summaryrefslogtreecommitdiff
path: root/src/client/pages/share.vue
blob: dd1e82dedb3fa53933c4fcf306fcf11524415f54 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
<div class="">
	<section class="_section">
		<div class="_title" v-if="title">{{ title }}</div>
		<div class="_content">
			<XPostForm v-if="!posted" fixed :instant="true" :initial-text="initialText" @posted="posted = true" class="_panel"/>
			<MkButton v-else primary @click="close()">{{ $t('close') }}</MkButton>
		</div>
		<div class="_footer" v-if="url">{{ url }}</div>
	</section>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
import MkButton from '@/components/ui/button.vue';
import XPostForm from '@/components/post-form.vue';
import * as os from '@/os';

export default defineComponent({
	components: {
		XPostForm,
		MkButton,
	},

	data() {
		return {
			INFO: {
				header: [{
					title: this.$t('share'),
					icon: faShareAlt
				}],
			},
			title: null,
			text: null,
			url: null,
			initialText: null,
			posted: false,

			faShareAlt
		}
	},

	created() {
		const urlParams = new URLSearchParams(window.location.search);
		this.title = urlParams.get('title');
		this.text = urlParams.get('text');
		this.url = urlParams.get('url');
		
		let text = '';
		if (this.title) text += `【${this.title}】\n`;
		if (this.text) text += `${this.text}\n`;
		if (this.url) text += `${this.url}`;
		this.initialText = text.trim();
	},

	methods: {
		close() {
			window.close()
		}
	}
});
</script>

<style lang="scss" scoped>
</style>