2020-01-29 11:37:25 -08:00
|
|
|
<template>
|
2020-10-17 04:12:00 -07:00
|
|
|
<XModalWindow ref="dialog"
|
|
|
|
:with-ok-button="true"
|
|
|
|
:ok-button-disabled="selected == null"
|
|
|
|
@click="cancel()"
|
|
|
|
@close="cancel()"
|
|
|
|
@ok="ok()"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
>
|
2020-12-25 17:47:36 -08:00
|
|
|
<template #header>{{ $ts.selectUser }}</template>
|
2021-04-28 02:36:07 -07:00
|
|
|
<div class="tbhwbxda _monolithic_">
|
|
|
|
<div class="_section">
|
2021-08-07 00:12:42 -07:00
|
|
|
<div class="_inputSplit _inputNoTopMargin _inputNoBottomMargin">
|
2021-08-06 06:29:19 -07:00
|
|
|
<MkInput v-model="username" class="input" @update:modelValue="search" ref="username">
|
|
|
|
<template #label>{{ $ts.username }}</template>
|
|
|
|
<template #prefix>@</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="host" class="input" @update:modelValue="search">
|
|
|
|
<template #label>{{ $ts.host }}</template>
|
|
|
|
<template #prefix>@</template>
|
|
|
|
</MkInput>
|
2021-04-28 02:36:07 -07:00
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
2021-04-28 02:36:07 -07:00
|
|
|
<div class="_section result" v-if="username != '' || host != ''" :class="{ hit: users.length > 0 }">
|
|
|
|
<div class="users" v-if="users.length > 0">
|
|
|
|
<div class="user" v-for="user in users" :key="user.id" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
|
|
|
|
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
|
|
|
|
<div class="body">
|
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-28 02:36:07 -07:00
|
|
|
<div v-else class="empty">
|
|
|
|
<span>{{ $ts.noUsers }}</span>
|
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
2021-04-28 02:36:07 -07:00
|
|
|
<div class="_section recent" v-if="username == '' && host == ''">
|
|
|
|
<div class="users">
|
|
|
|
<div class="user" v-for="user in recentUsers" :key="user.id" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
|
|
|
|
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
|
|
|
|
<div class="body">
|
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
|
|
|
</div>
|
2020-11-07 19:40:56 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
</XModalWindow>
|
2020-01-29 11:37:25 -08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 04:12:00 -07:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 11:37:25 -08:00
|
|
|
import MkInput from './ui/input.vue';
|
2021-03-23 01:30:14 -07:00
|
|
|
import XModalWindow from '@client/components/ui/modal-window.vue';
|
|
|
|
import * as os from '@client/os';
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
export default defineComponent({
|
2020-01-29 11:37:25 -08:00
|
|
|
components: {
|
|
|
|
MkInput,
|
2020-10-17 04:12:00 -07:00
|
|
|
XModalWindow,
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
},
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
emits: ['ok', 'cancel', 'closed'],
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
username: '',
|
|
|
|
host: '',
|
2020-11-07 19:40:56 -08:00
|
|
|
recentUsers: [],
|
2020-01-29 11:37:25 -08:00
|
|
|
users: [],
|
|
|
|
selected: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-11-07 19:40:56 -08:00
|
|
|
async mounted() {
|
2020-01-29 11:37:25 -08:00
|
|
|
this.focus();
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.focus();
|
|
|
|
});
|
2020-11-07 19:40:56 -08:00
|
|
|
|
|
|
|
this.recentUsers = await os.api('users/show', {
|
2020-12-18 17:55:52 -08:00
|
|
|
userIds: this.$store.state.recentlyUsedUsers
|
2020-11-07 19:40:56 -08:00
|
|
|
});
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
search() {
|
|
|
|
if (this.username == '' && this.host == '') {
|
|
|
|
this.users = [];
|
|
|
|
return;
|
|
|
|
}
|
2020-10-17 04:12:00 -07:00
|
|
|
os.api('users/search-by-username-and-host', {
|
2020-01-29 11:37:25 -08:00
|
|
|
username: this.username,
|
|
|
|
host: this.host,
|
|
|
|
limit: 10,
|
|
|
|
detail: false
|
|
|
|
}).then(users => {
|
|
|
|
this.users = users;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
this.$refs.username.focus();
|
|
|
|
},
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
ok() {
|
|
|
|
this.$emit('ok', this.selected);
|
|
|
|
this.$refs.dialog.close();
|
2020-11-07 19:40:56 -08:00
|
|
|
|
|
|
|
// 最近使ったユーザー更新
|
2020-12-18 17:55:52 -08:00
|
|
|
let recents = this.$store.state.recentlyUsedUsers;
|
2020-11-07 19:40:56 -08:00
|
|
|
recents = recents.filter(x => x !== this.selected.id);
|
|
|
|
recents.unshift(this.selected.id);
|
2020-12-18 17:55:52 -08:00
|
|
|
this.$store.set('recentlyUsedUsers', recents.splice(0, 16));
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
cancel() {
|
|
|
|
this.$emit('cancel');
|
|
|
|
this.$refs.dialog.close();
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.tbhwbxda {
|
2021-04-28 02:36:07 -07:00
|
|
|
> ._section {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
overflow: auto;
|
|
|
|
height: 100%;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
&.result.hit {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2020-11-07 19:40:56 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
&.recent {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2020-11-07 19:40:56 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .users {
|
|
|
|
flex: 1;
|
|
|
|
overflow: auto;
|
|
|
|
padding: 8px 0;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 8px var(--root-margin);
|
|
|
|
font-size: 14px;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
&:hover {
|
|
|
|
background: var(--X7);
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
&.selected {
|
|
|
|
background: var(--accent);
|
|
|
|
color: #fff;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> * {
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .avatar {
|
|
|
|
width: 45px;
|
|
|
|
height: 45px;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .body {
|
|
|
|
padding: 0 8px;
|
|
|
|
min-width: 0;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .name {
|
|
|
|
display: block;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .acct {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2021-04-28 02:36:07 -07:00
|
|
|
> .empty {
|
|
|
|
opacity: 0.7;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2020-10-17 04:12:00 -07:00
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
</style>
|