mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-10-24 10:14:51 +00:00
* wip * wip * wip * test * wip rollup pluginでsearchIndexの情報生成 * wip * SPDX * wip: markerIdを自動付与 * rollupでビルド時・devモード時に毎回uuidを生成するように * 開発サーバーでだけ必要な挙動は開発サーバーのみで * 条件が逆 * wip: childrenの生成 * update comment * update comment * rename auto generated file * hashをパスと行数から決定 * Update privacy.vue * Update privacy.vue * wip * Update general.vue * Update general.vue * wip * wip * Update SearchMarker.vue * wip * Update profile.vue * Update mute-block.vue * Update mute-block.vue * Update general.vue * Update general.vue * childrenがduplicate key errorを吐く問題をいったん解決 * マーカーの形を成形 * loggerを置きかえ * とりあえず省略記法に対応 * Refactor and Format codes * wip * Update settings-search-index.ts * wip * wip * とりあえず不確定要因の仮置きidを削除 * hashの生成を正規化(絶対パスになっていたのを緩和) * pathの入力を省略可能に * adminでもパス生成できるように * Update settings-search-index.ts * Update privacy.vue * wip * build searchIndex * wip * build * Update general.vue * build * Update sounds.vue * build * build * Update sounds.vue * 🎨 * 🎨 * Update privacy.vue * Update privacy.vue * Update security.vue * create-search-indexを多少改善 * build * Update 2fa.vue * wip * 必ずtransformCodeCacheを利用するように, キャッシュの明確な受け渡しを定義 * キャッシュはdevServerでなくても更新 * Revert "wip" This reverts commit 41bffd3a13f55618bf939dc1c9acb2a77ead4054. * inlining * wip * Update theme.vue * 🎨 * wip normalize * Update theme.vue * キャッシュのパス変換 * build * wip * wip * Update SearchMarker.vue * i18n.ts['key'] の形式が取り出せない問題のFix * build * 仮でpath入れ * 必ず絶対パスが使われるように * wip * 🎨 * storybookビルド時はcreateSearchIndexをしない * inliningの構造化 * format code * Update index.vue * wip * wip * 🎨 * wip * wip * wip * wip * wip * wip * wip * wip * clean up * wip * wip * wip * Update rollup-plugin-unwind-css-module-class-name.test.ts * Update navbar.vue * clean up * wip * wip * wip * wip * wip * Update preferences-backups.vue * Update common.ts * Update preferences.ts * wip * wip * wip * wip * Update MkPreferenceContainer.vue * Update MkPreferenceContainer.vue * Update MkPreferenceContainer.vue * enhance: 検索で上下矢印を使用することで検索結果を移動できるように * Update main-boot.ts * refactor * wip * Update sounds.vue * fix(frontend): PageWindowでSearchMarkerが動作するように * enhance(frontend): SearchMarkerの点滅を一定時間で止める * wip * lint fix * fix: 子要素監視が抜けていたのを修正 * アニメーションの回数はCSSで制御するように * refactor * enhance(frontend): 検索インデックス作成時のログを削減 * revert * fix * fix * Update preferences.ts * Update preferences.ts * wip * Update preferences.ts * wip * 🎨 * wip * Update MkPreferenceContainer.vue * wip * Update preferences.ts * wip * Update preferences.ts * Update preferences.ts * wip * wip * Update preferences.ts * wip * wip * Update preferences.ts * Update CHANGELOG.md * Update preferences.ts * Update deck-store.ts * deckStoreをdefaultStoreに統合 * wip * defaultStore -> store * Update profile.ts * wip * refactor * wip: plugin * plugin * plugin * plugin * Update plugin.ts * wip * Update plugin.vue * Update preferences.ts * Update main-boot.ts * wip * fix test * Update plugin.vue * Update plugin.vue * Update utility.ts * wip * wip * Update utility.ts * wip * wip * clean up * Update utility.ts --------- Co-authored-by: tai-cha <dev@taichan.site> Co-authored-by: taichan <40626578+tai-cha@users.noreply.github.com> Co-authored-by: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com>
234 lines
5.6 KiB
Vue
234 lines
5.6 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<MkModalWindow
|
|
ref="dialogEl"
|
|
:withOkButton="true"
|
|
:okButtonDisabled="selected == null"
|
|
@click="cancel()"
|
|
@close="cancel()"
|
|
@ok="ok()"
|
|
@closed="emit('closed')"
|
|
>
|
|
<template #header>{{ i18n.ts.selectUser }}</template>
|
|
<div>
|
|
<div :class="$style.form">
|
|
<MkInput v-if="computedLocalOnly" v-model="username" :autofocus="true" @update:modelValue="search">
|
|
<template #label>{{ i18n.ts.username }}</template>
|
|
<template #prefix>@</template>
|
|
</MkInput>
|
|
<FormSplit v-else :minWidth="170">
|
|
<MkInput v-model="username" :autofocus="true" @update:modelValue="search">
|
|
<template #label>{{ i18n.ts.username }}</template>
|
|
<template #prefix>@</template>
|
|
</MkInput>
|
|
<MkInput v-model="host" :datalist="[hostname]" @update:modelValue="search">
|
|
<template #label>{{ i18n.ts.host }}</template>
|
|
<template #prefix>@</template>
|
|
</MkInput>
|
|
</FormSplit>
|
|
</div>
|
|
<div v-if="username != '' || host != ''" :class="[$style.result, { [$style.hit]: users.length > 0 }]">
|
|
<div v-if="users.length > 0" :class="$style.users">
|
|
<div v-for="user in users" :key="user.id" class="_button" :class="[$style.user, { [$style.selected]: selected && selected.id === user.id }]" @click="selected = user" @dblclick="ok()">
|
|
<MkAvatar :user="user" :class="$style.avatar" indicator/>
|
|
<div :class="$style.userBody">
|
|
<MkUserName :user="user" :class="$style.userName"/>
|
|
<MkAcct :user="user" :class="$style.userAcct"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-else :class="$style.empty">
|
|
<span>{{ i18n.ts.noUsers }}</span>
|
|
</div>
|
|
</div>
|
|
<div v-if="username == '' && host == ''" :class="$style.recent">
|
|
<div :class="$style.users">
|
|
<div v-for="user in recentUsers" :key="user.id" class="_button" :class="[$style.user, { [$style.selected]: selected && selected.id === user.id }]" @click="selected = user" @dblclick="ok()">
|
|
<MkAvatar :user="user" :class="$style.avatar" indicator/>
|
|
<div :class="$style.userBody">
|
|
<MkUserName :user="user" :class="$style.userName"/>
|
|
<MkAcct :user="user" :class="$style.userAcct"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</MkModalWindow>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, ref, computed, shallowRef } from 'vue';
|
|
import * as Misskey from 'misskey-js';
|
|
import { host as currentHost, hostname } from '@@/js/config.js';
|
|
import MkInput from '@/components/MkInput.vue';
|
|
import FormSplit from '@/components/form/split.vue';
|
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
|
import { store } from '@/store.js';
|
|
import { i18n } from '@/i18n.js';
|
|
import { $i } from '@/account.js';
|
|
import { instance } from '@/instance.js';
|
|
|
|
const emit = defineEmits<{
|
|
(ev: 'ok', selected: Misskey.entities.UserDetailed): void;
|
|
(ev: 'cancel'): void;
|
|
(ev: 'closed'): void;
|
|
}>();
|
|
|
|
const props = withDefaults(defineProps<{
|
|
includeSelf?: boolean;
|
|
localOnly?: boolean;
|
|
}>(), {
|
|
includeSelf: false,
|
|
localOnly: false,
|
|
});
|
|
|
|
const computedLocalOnly = computed(() => props.localOnly || instance.federation === 'none');
|
|
|
|
const username = ref('');
|
|
const host = ref('');
|
|
const users = ref<Misskey.entities.UserLite[]>([]);
|
|
const recentUsers = ref<Misskey.entities.UserDetailed[]>([]);
|
|
const selected = ref<Misskey.entities.UserLite | null>(null);
|
|
const dialogEl = shallowRef<InstanceType<typeof MkModalWindow>>();
|
|
|
|
function search() {
|
|
if (username.value === '' && host.value === '') {
|
|
users.value = [];
|
|
return;
|
|
}
|
|
misskeyApi('users/search-by-username-and-host', {
|
|
username: username.value,
|
|
host: computedLocalOnly.value ? '.' : host.value,
|
|
limit: 10,
|
|
detail: false,
|
|
}).then(_users => {
|
|
users.value = _users.filter((u) => {
|
|
if (props.includeSelf) {
|
|
return true;
|
|
} else {
|
|
return u.id !== $i?.id;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
async function ok() {
|
|
if (selected.value == null) return;
|
|
|
|
const user = await misskeyApi('users/show', {
|
|
userId: selected.value.id,
|
|
});
|
|
emit('ok', user);
|
|
|
|
dialogEl.value?.close();
|
|
|
|
// 最近使ったユーザー更新
|
|
let recents = store.state.recentlyUsedUsers;
|
|
recents = recents.filter(x => x !== selected.value?.id);
|
|
recents.unshift(selected.value.id);
|
|
store.set('recentlyUsedUsers', recents.splice(0, 16));
|
|
}
|
|
|
|
function cancel() {
|
|
emit('cancel');
|
|
dialogEl.value?.close();
|
|
}
|
|
|
|
onMounted(() => {
|
|
misskeyApi('users/show', {
|
|
userIds: store.state.recentlyUsedUsers,
|
|
}).then(foundUsers => {
|
|
let _users = foundUsers;
|
|
_users = _users.filter((u) => {
|
|
if (computedLocalOnly.value) {
|
|
return u.host == null;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
_users = _users.filter((u) => {
|
|
if (props.includeSelf) {
|
|
return true;
|
|
} else {
|
|
return u.id !== $i?.id;
|
|
}
|
|
});
|
|
recentUsers.value = _users;
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
|
|
.form {
|
|
padding: calc(var(--root-margin) / 2) var(--root-margin);
|
|
}
|
|
|
|
.result,
|
|
.recent {
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: auto;
|
|
height: 100%;
|
|
|
|
&.result.hit {
|
|
padding: 0;
|
|
}
|
|
|
|
&.recent {
|
|
padding: 0;
|
|
}
|
|
}
|
|
|
|
.users {
|
|
flex: 1;
|
|
overflow: auto;
|
|
padding: 8px 0;
|
|
}
|
|
|
|
.user {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 8px var(--root-margin);
|
|
font-size: 14px;
|
|
|
|
&:hover {
|
|
background: light-dark(rgba(0, 0, 0, 0.05), rgba(255, 255, 255, 0.05));
|
|
}
|
|
|
|
&.selected {
|
|
background: var(--MI_THEME-accent);
|
|
color: #fff;
|
|
}
|
|
}
|
|
|
|
.userBody {
|
|
padding: 0 8px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.avatar {
|
|
width: 45px;
|
|
height: 45px;
|
|
}
|
|
|
|
.userName {
|
|
display: block;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.userAcct {
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.empty {
|
|
opacity: 0.7;
|
|
text-align: center;
|
|
padding: 16px;
|
|
}
|
|
</style>
|