This commit is contained in:
syuilo 2020-09-19 14:26:36 +09:00
parent 7f7fe3f94c
commit 3575b1ecd8
5 changed files with 25 additions and 29 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<x-window ref="window" :width="400" :height="450" :no-padding="true" @closed="() => { $emit('closed'); destroyDom(); }" :with-ok-button="true" :ok-button-disabled="false" @ok="ok()" :can-close="false"> <x-window ref="window" :width="400" :height="450" :no-padding="true" @close="$emit('done')" :with-ok-button="true" :ok-button-disabled="false" @ok="ok()" :can-close="false">
<template #header>{{ title || $t('generateAccessToken') }}</template> <template #header>{{ title || $t('generateAccessToken') }}</template>
<div class="ugkkpisj"> <div class="ugkkpisj">
<div v-if="information"> <div v-if="information">
@ -62,6 +62,8 @@ export default defineComponent({
} }
}, },
emits: ['done'],
data() { data() {
return { return {
name: this.initialName, name: this.initialName,
@ -73,11 +75,11 @@ export default defineComponent({
created() { created() {
if (this.initialPermissions) { if (this.initialPermissions) {
for (const kind of this.initialPermissions) { for (const kind of this.initialPermissions) {
Vue.set(this.permissions, kind, true); this.permissions[kind] = true;
} }
} else { } else {
for (const kind of this.kinds) { for (const kind of this.kinds) {
Vue.set(this.permissions, kind, false); this.permissions[kind] = false;
} }
} }
}, },

View File

@ -1,33 +1,26 @@
<template> <template>
<x-modal ref="modal" @closed="$emit('closed')" :can-close="canClose"> <div class="ebkgoccj" :class="{ noPadding }" @keydown="onKeydown" :style="{ width: `${width}px`, height: `${height}px` }">
<div class="ebkgoccj" :class="{ noPadding }" @keydown="onKeydown" :style="{ width: `${width}px`, height: `${height}px` }"> <div class="header">
<div class="header"> <button class="_button" v-if="withOkButton" @click="close()"><fa :icon="faTimes"/></button>
<button class="_button" v-if="withOkButton" @click="close()"><fa :icon="faTimes"/></button> <span class="title">
<span class="title"> <mk-avatar :user="avatar" v-if="avatar" class="avatar"/>
<mk-avatar :user="avatar" v-if="avatar" class="avatar"/> <slot name="header"></slot>
<slot name="header"></slot> </span>
</span> <button class="_button" v-if="!withOkButton" @click="close()"><fa :icon="faTimes"/></button>
<button class="_button" v-if="!withOkButton" @click="close()"><fa :icon="faTimes"/></button> <button class="_button" v-if="withOkButton" @click="$emit('ok')" :disabled="okButtonDisabled"><fa :icon="faCheck"/></button>
<button class="_button" v-if="withOkButton" @click="() => { $emit('ok'); close(); }" :disabled="okButtonDisabled"><fa :icon="faCheck"/></button>
</div>
<div class="body">
<slot></slot>
</div>
</div> </div>
</x-modal> <div class="body">
<slot></slot>
</div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { faTimes, faCheck } from '@fortawesome/free-solid-svg-icons'; import { faTimes, faCheck } from '@fortawesome/free-solid-svg-icons';
import XModal from './modal.vue';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
components: {
XModal,
},
props: { props: {
avatar: { avatar: {
type: Object, type: Object,
@ -65,6 +58,8 @@ export default defineComponent({
}, },
}, },
emits: ['close', 'ok'],
data() { data() {
return { return {
faTimes, faCheck faTimes, faCheck
@ -73,7 +68,7 @@ export default defineComponent({
methods: { methods: {
close() { close() {
this.$refs.modal.close(); this.$emit('close');
}, },
onKeydown(e) { onKeydown(e) {

View File

@ -452,7 +452,7 @@ export default defineComponent({
}, },
addPinUser() { addPinUser() {
os.modal(MkUserSelect, {}).$once('selected', user => { os.modal(MkUserSelect, {}).then(user => {
this.pinnedUsers = this.pinnedUsers.trim(); this.pinnedUsers = this.pinnedUsers.trim();
this.pinnedUsers += '\n@' + getAcct(user); this.pinnedUsers += '\n@' + getAcct(user);
this.pinnedUsers = this.pinnedUsers.trim(); this.pinnedUsers = this.pinnedUsers.trim();
@ -460,7 +460,7 @@ export default defineComponent({
}, },
chooseProxyAccount() { chooseProxyAccount() {
os.modal(MkUserSelect, {}).$once('selected', user => { os.modal(MkUserSelect, {}).then(user => {
this.proxyAccount = user; this.proxyAccount = user;
this.proxyAccountId = user.id; this.proxyAccountId = user.id;
this.save(true); this.save(true);

View File

@ -26,8 +26,7 @@ export default defineComponent({
}, },
methods: { methods: {
async generateToken() { async generateToken() {
os.modal(await import('@/components/token-generate-window.vue'), { os.modal(await import('@/components/token-generate-window.vue'), {}).then(async ({ name, permissions }) => {
}).$on('ok', async ({ name, permissions }) => {
const { token } = await os.api('miauth/gen-token', { const { token } = await os.api('miauth/gen-token', {
session: null, session: null,
name: name, name: name,

View File

@ -123,7 +123,7 @@ export default defineComponent({
information: this.$t('pluginTokenRequestedDescription'), information: this.$t('pluginTokenRequestedDescription'),
initialName: name, initialName: name,
initialPermissions: permissions initialPermissions: permissions
}).$on('ok', async ({ name, permissions }) => { }).then(async ({ name, permissions }) => {
const { token } = await os.api('miauth/gen-token', { const { token } = await os.api('miauth/gen-token', {
session: null, session: null,
name: name, name: name,