2020-02-06 15:12:27 +01:00
|
|
|
|
<template>
|
|
|
|
|
<div class="">
|
2020-10-17 13:12:00 +02:00
|
|
|
|
<section class="_section">
|
2020-02-06 15:12:27 +01:00
|
|
|
|
<div class="_title" v-if="title">{{ title }}</div>
|
|
|
|
|
<div class="_content">
|
2021-02-12 17:28:20 +01:00
|
|
|
|
<XPostForm
|
|
|
|
|
v-if="state === 'writing'"
|
|
|
|
|
fixed
|
|
|
|
|
:share="true"
|
|
|
|
|
:initial-text="initialText"
|
|
|
|
|
:initial-visibility="visibility"
|
|
|
|
|
:initial-files="files"
|
|
|
|
|
:reply="reply"
|
|
|
|
|
:renote="renote"
|
|
|
|
|
:specified="specified"
|
|
|
|
|
@posted="state = 'posted'"
|
|
|
|
|
class="_panel"
|
|
|
|
|
/>
|
|
|
|
|
<MkButton v-else-if="state === 'posted'" primary @click="close()">{{ $ts.close }}</MkButton>
|
2020-02-06 15:12:27 +01:00
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
|
import { defineComponent } from 'vue';
|
2020-02-06 15:12:27 +01:00
|
|
|
|
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
|
import XPostForm from '@/components/post-form.vue';
|
|
|
|
|
import * as os from '@/os';
|
2021-02-12 17:28:20 +01:00
|
|
|
|
import { noteVisibilities } from '../../types';
|
2020-02-06 15:12:27 +01:00
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
|
export default defineComponent({
|
2020-02-06 15:12:27 +01:00
|
|
|
|
components: {
|
2020-10-17 13:12:00 +02:00
|
|
|
|
XPostForm,
|
|
|
|
|
MkButton,
|
2020-02-06 15:12:27 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-10-17 13:12:00 +02:00
|
|
|
|
INFO: {
|
2020-12-26 02:47:36 +01:00
|
|
|
|
title: this.$ts.share,
|
2020-11-03 12:36:12 +01:00
|
|
|
|
icon: faShareAlt
|
2020-10-17 13:12:00 +02:00
|
|
|
|
},
|
2021-02-12 17:28:20 +01:00
|
|
|
|
state: 'fetching' as 'fetching' | 'writing' | 'posted',
|
|
|
|
|
|
|
|
|
|
title: null as string | null,
|
|
|
|
|
initialText: null as string | null,
|
|
|
|
|
reply: null as any,
|
|
|
|
|
renote: null as any,
|
|
|
|
|
specified: null as any,
|
|
|
|
|
visibility: null as string | null,
|
|
|
|
|
files: null as any[] | null,
|
2020-02-08 05:06:09 +01:00
|
|
|
|
|
2020-02-06 15:12:27 +01:00
|
|
|
|
faShareAlt
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2021-02-12 17:28:20 +01:00
|
|
|
|
async created() {
|
2020-02-06 15:12:27 +01:00
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
2021-02-12 17:28:20 +01:00
|
|
|
|
|
2020-02-06 15:12:27 +01:00
|
|
|
|
this.title = urlParams.get('title');
|
2021-02-12 17:28:20 +01:00
|
|
|
|
const text = urlParams.get('text');
|
|
|
|
|
const url = urlParams.get('url');
|
|
|
|
|
|
|
|
|
|
let noteText = '';
|
|
|
|
|
if (this.title) noteText += `【${this.title}】\n`;
|
|
|
|
|
// titleとtext(またはtext. Googleニュースがこれを吐く)が同一であればtextを省略
|
|
|
|
|
if (text && this.title !== text && this.title !== `${text}.`) noteText += `${text}\n`;
|
|
|
|
|
if (url) noteText += `${url}`;
|
|
|
|
|
this.initialText = noteText.trim();
|
|
|
|
|
|
|
|
|
|
this.visibility = urlParams.get('visibility');
|
|
|
|
|
if (!noteVisibilities.includes(this.visibility)) this.visibility = null;
|
|
|
|
|
|
|
|
|
|
await Promise.all([(async () => {
|
|
|
|
|
const replyId = urlParams.get('replyId');
|
|
|
|
|
const replyUri = urlParams.get('replyUri');
|
|
|
|
|
if (replyId) {
|
|
|
|
|
this.reply = await os.api('notes/show', {
|
|
|
|
|
noteId: replyId
|
|
|
|
|
});
|
|
|
|
|
} else if (replyUri) {
|
|
|
|
|
const obj = await os.api('ap/show', {
|
|
|
|
|
uri: replyUri
|
|
|
|
|
}) as any;
|
|
|
|
|
if (obj.type === 'Note') {
|
|
|
|
|
this.reply = obj.object;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})(),(async () => {
|
|
|
|
|
const renoteId = urlParams.get('replyId');
|
|
|
|
|
const renoteUri = urlParams.get('replyUri');
|
|
|
|
|
if (renoteId) {
|
|
|
|
|
this.renote = await os.api('notes/show', {
|
|
|
|
|
noteId: renoteId
|
|
|
|
|
});
|
|
|
|
|
} else if (renoteUri) {
|
|
|
|
|
const obj = await os.api('ap/show', {
|
|
|
|
|
uri: renoteUri
|
|
|
|
|
}) as any;
|
|
|
|
|
if (obj.type === 'Note') {
|
|
|
|
|
this.renote = obj.object;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})(),(async () => {
|
|
|
|
|
const specifiedId = urlParams.get('specifiedId');
|
|
|
|
|
const specifiedUsername = urlParams.get('specifiedUsername');
|
|
|
|
|
if (specifiedId) {
|
|
|
|
|
this.specified = await os.api('users/show', {
|
|
|
|
|
userId: specifiedId
|
|
|
|
|
});
|
|
|
|
|
} else if (specifiedUsername) {
|
|
|
|
|
this.specified = await os.api('users/show', {
|
|
|
|
|
username: specifiedUsername
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})(),(async () => {
|
|
|
|
|
const fileIds = urlParams.get('fileIds');
|
|
|
|
|
if (fileIds) {
|
|
|
|
|
const promises = Promise.all(fileIds.split(',').map(fileId => os.api('drive/files/show', { fileId })));
|
|
|
|
|
promises.then(files => this.files = files).catch(() => console.error('invalid fileIds'));
|
|
|
|
|
}
|
|
|
|
|
})(),]);
|
|
|
|
|
|
|
|
|
|
this.state = 'writing';
|
2020-02-06 15:12:27 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
2020-02-08 05:06:09 +01:00
|
|
|
|
close() {
|
|
|
|
|
window.close()
|
2020-02-06 15:12:27 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
</style>
|