enhance: アカウント削除時のクライアントの挙動をいい感じにするなど (#10002)
* refreshAccounts Resolve #9322 * アカウント管理画面でリストを更新するように * Update packages/frontend/src/account.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * ✌️ * クライアント起動時は現在ログインしているアカウントのみリフレッシュする * clean up * なんかめっちゃ変えた * refactor * refactor * fix lint --------- Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
parent
a4ca127ebd
commit
c75afad64a
7 changed files with 149 additions and 94 deletions
|
@ -2,21 +2,12 @@
|
|||
<div class="">
|
||||
<FormSuspense :p="init">
|
||||
<div class="_gaps">
|
||||
<MkButton primary @click="addAccount"><i class="ti ti-plus"></i> {{ i18n.ts.addAccount }}</MkButton>
|
||||
|
||||
<div v-for="account in accounts" :key="account.id" class="_panel _button lcjjdxlm" @click="menu(account, $event)">
|
||||
<div class="avatar">
|
||||
<MkAvatar :user="account" class="avatar"/>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="name">
|
||||
<MkUserName :user="account"/>
|
||||
</div>
|
||||
<div class="acct">
|
||||
<MkAcct :user="account"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="_buttons">
|
||||
<MkButton primary @click="addAccount"><i class="ti ti-plus"></i> {{ i18n.ts.addAccount }}</MkButton>
|
||||
<MkButton @click="init"><i class="ti ti-refresh"></i> {{ i18n.ts.reloadAccountsList }}</MkButton>
|
||||
</div>
|
||||
|
||||
<MkUserCardMini v-for="user in accounts" :key="user.id" :user="user" :class="$style.user" @click.prevent="menu(user, $event)"/>
|
||||
</div>
|
||||
</FormSuspense>
|
||||
</div>
|
||||
|
@ -30,9 +21,11 @@ import * as os from '@/os';
|
|||
import { getAccounts, addAccount as addAccounts, removeAccount as _removeAccount, login, $i } from '@/account';
|
||||
import { i18n } from '@/i18n';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||
import type * as Misskey from 'misskey-js';
|
||||
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
||||
|
||||
const storedAccounts = ref<any>(null);
|
||||
const accounts = ref<any>(null);
|
||||
const accounts = ref<Misskey.entities.UserDetailed[]>([]);
|
||||
|
||||
const init = async () => {
|
||||
getAccounts().then(accounts => {
|
||||
|
@ -52,7 +45,7 @@ function menu(account, ev) {
|
|||
icon: 'ti ti-switch-horizontal',
|
||||
action: () => switchAccount(account),
|
||||
}, {
|
||||
text: i18n.ts.remove,
|
||||
text: i18n.ts.logout,
|
||||
icon: 'ti ti-trash',
|
||||
danger: true,
|
||||
action: () => removeAccount(account),
|
||||
|
@ -69,23 +62,25 @@ function addAccount(ev) {
|
|||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
function removeAccount(account) {
|
||||
_removeAccount(account.id);
|
||||
async function removeAccount(account) {
|
||||
await _removeAccount(account.id);
|
||||
accounts.value = accounts.value.filter(x => x.id !== account.id);
|
||||
}
|
||||
|
||||
function addExistingAccount() {
|
||||
os.popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {}, {
|
||||
done: res => {
|
||||
addAccounts(res.id, res.i);
|
||||
done: async res => {
|
||||
await addAccounts(res.id, res.i);
|
||||
os.success();
|
||||
init();
|
||||
},
|
||||
}, 'closed');
|
||||
}
|
||||
|
||||
function createAccount() {
|
||||
os.popup(defineAsyncComponent(() => import('@/components/MkSignupDialog.vue')), {}, {
|
||||
done: res => {
|
||||
addAccounts(res.id, res.i);
|
||||
done: async res => {
|
||||
await addAccounts(res.id, res.i);
|
||||
switchAccountWithToken(res.i);
|
||||
},
|
||||
}, 'closed');
|
||||
|
@ -111,32 +106,8 @@ definePageMetadata({
|
|||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.lcjjdxlm {
|
||||
display: flex;
|
||||
padding: 16px;
|
||||
|
||||
> .avatar {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
margin: 0 12px 0 0;
|
||||
|
||||
> .avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
> .body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: calc(100% - 62px);
|
||||
position: relative;
|
||||
|
||||
> .name {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
<style lang="scss" module>
|
||||
.user {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue