This commit is contained in:
syuilo 2020-09-21 13:07:12 +09:00
parent c2a77d4eb7
commit 1345ee1b2c
2 changed files with 14 additions and 24 deletions

View File

@ -121,6 +121,8 @@ export default defineComponent({
}
},
emits: ['posted', 'done'],
data() {
return {
posting: false,

View File

@ -6,8 +6,8 @@
<div class="_title" v-if="title">{{ title }}</div>
<div class="_content">
<div>{{ text }}</div>
<mk-button @click="post()" v-if="!posted">{{ $t('post') }}</mk-button>
<mk-button primary @click="close()" v-else>{{ $t('close') }}</mk-button>
<x-post-form v-if="!posted" fixed :instant="true" :initial-text="initialText" @posted="posted = true"/>
<mk-button v-else primary @click="close()">{{ $t('close') }}</mk-button>
</div>
<div class="_footer" v-if="url">{{ url }}</div>
</section>
@ -17,8 +17,8 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
import PostFormDialog from '@/components/post-form-dialog.vue';
import MkButton from '@/components/ui/button.vue';
import XPostForm from '@/components/post-form.vue';
import * as os from '@/os';
export default defineComponent({
@ -29,7 +29,8 @@ export default defineComponent({
},
components: {
MkButton
XPostForm,
MkButton,
},
data() {
@ -37,6 +38,7 @@ export default defineComponent({
title: null,
text: null,
url: null,
initialText: null,
posted: false,
faShareAlt
@ -48,29 +50,15 @@ export default defineComponent({
this.title = urlParams.get('title');
this.text = urlParams.get('text');
this.url = urlParams.get('url');
},
mounted() {
this.post();
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: {
post() {
let text = '';
if (this.title) text += `${this.title}\n`;
if (this.text) text += `${this.text}\n`;
if (this.url) text += `${this.url}`;
os.modal(PostFormDialog, {
instant: true,
initialText: text.trim()
}).$once('posted', () => {
this.posted = true;
os.dialog({
type: 'success',
iconOnly: true, autoClose: true
});
});
},
close() {
window.close()
}