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() { data() {
return { return {
posting: false, posting: false,

View File

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