2022-12-09 23:28:50 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.moveTo }}</template>
|
2023-05-31 07:14:13 +02:00
|
|
|
<FormInfo warn class="_formBlock">{{
|
|
|
|
i18n.ts.moveAccountDescription
|
|
|
|
}}</FormInfo>
|
2023-04-08 02:01:42 +02:00
|
|
|
<FormInput v-model="moveToAccount" class="_formBlock">
|
2023-05-31 07:14:13 +02:00
|
|
|
<template #prefix
|
2023-10-17 03:57:20 +02:00
|
|
|
><i :class="icon('ph-airplane-takeoff')"></i
|
2023-05-31 07:14:13 +02:00
|
|
|
></template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<template #label>{{ i18n.ts.moveToLabel }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormButton primary danger @click="move(moveToAccount)">
|
|
|
|
{{ i18n.ts.moveAccount }}
|
|
|
|
</FormButton>
|
|
|
|
</FormSection>
|
2022-12-09 23:28:50 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.moveFrom }}</template>
|
2023-05-31 07:14:13 +02:00
|
|
|
<FormInfo warn class="_formBlock">{{
|
|
|
|
i18n.ts.moveFromDescription
|
|
|
|
}}</FormInfo>
|
|
|
|
<FormInput
|
|
|
|
v-for="(_, i) in accountAlias"
|
|
|
|
v-model="accountAlias[i]"
|
|
|
|
class="_formBlock"
|
|
|
|
>
|
|
|
|
<template #prefix
|
2023-10-17 03:57:20 +02:00
|
|
|
><i :class="icon('ph-airplane-landing')"></i
|
2023-05-31 07:14:13 +02:00
|
|
|
></template>
|
|
|
|
<template #label>{{
|
|
|
|
`#${i + 1} ${i18n.ts.moveFromLabel}`
|
|
|
|
}}</template>
|
2023-04-08 02:01:42 +02:00
|
|
|
</FormInput>
|
2023-05-31 07:14:13 +02:00
|
|
|
<FormButton
|
|
|
|
class="button"
|
|
|
|
:disabled="accountAlias.length >= 10"
|
|
|
|
inline
|
|
|
|
style="margin-right: 8px"
|
|
|
|
@click="add"
|
2023-10-17 03:57:20 +02:00
|
|
|
><i :class="icon('ph-plus')"></i> {{ i18n.ts.add }}</FormButton
|
2023-05-31 07:14:13 +02:00
|
|
|
>
|
2023-05-31 05:10:12 +02:00
|
|
|
<FormButton class="button" inline primary @click="save">
|
2023-10-17 03:57:20 +02:00
|
|
|
<i :class="icon('ph-floppy-disk-back')"></i>
|
2023-04-08 02:01:42 +02:00
|
|
|
{{ i18n.ts.save }}
|
|
|
|
</FormButton>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2022-12-09 23:28:50 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-08-12 02:44:46 +02:00
|
|
|
import { ref } from "vue";
|
|
|
|
|
2023-09-02 01:27:33 +02:00
|
|
|
import { toString } from "firefish-js/built/acct";
|
2023-04-08 02:01:42 +02:00
|
|
|
import FormSection from "@/components/form/section.vue";
|
|
|
|
import FormInput from "@/components/form/input.vue";
|
|
|
|
import FormButton from "@/components/MkButton.vue";
|
2023-05-31 05:10:12 +02:00
|
|
|
import FormInfo from "@/components/MkInfo.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import * as os from "@/os";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
2023-10-22 23:29:46 +02:00
|
|
|
import { $i } from "@/reactiveAccount";
|
2023-10-17 03:57:20 +02:00
|
|
|
import icon from "@/scripts/icon";
|
2022-12-09 23:28:50 +01:00
|
|
|
|
2023-09-02 01:16:23 +02:00
|
|
|
const moveToAccount = ref("");
|
|
|
|
const accountAlias = ref([""]);
|
2022-12-09 23:28:50 +01:00
|
|
|
|
2023-05-31 05:10:12 +02:00
|
|
|
await init();
|
|
|
|
|
|
|
|
async function init() {
|
|
|
|
if ($i?.alsoKnownAs && $i.alsoKnownAs.length > 0) {
|
2023-05-31 07:14:13 +02:00
|
|
|
const aka = await os.api("users/show", { userIds: $i.alsoKnownAs });
|
2023-08-12 02:44:46 +02:00
|
|
|
accountAlias.value =
|
2023-05-31 07:14:13 +02:00
|
|
|
aka && aka.length > 0
|
|
|
|
? aka.map((user) => `@${toString(user)}`)
|
|
|
|
: [""];
|
|
|
|
} else {
|
2023-08-12 02:44:46 +02:00
|
|
|
accountAlias.value = [""];
|
2023-05-31 05:10:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function save(): Promise<void> {
|
2023-05-31 07:14:13 +02:00
|
|
|
const i = await os.apiWithDialog("i/known-as", {
|
2023-08-12 02:44:46 +02:00
|
|
|
alsoKnownAs: accountAlias.value
|
|
|
|
.map((e) => e.trim())
|
|
|
|
.filter((e) => e !== ""),
|
2022-12-12 01:42:40 +01:00
|
|
|
});
|
2023-05-31 05:10:12 +02:00
|
|
|
$i.alsoKnownAs = i.alsoKnownAs;
|
|
|
|
await init();
|
|
|
|
}
|
|
|
|
|
|
|
|
function add(): void {
|
2023-08-12 02:44:46 +02:00
|
|
|
accountAlias.value.push("");
|
2022-12-09 23:28:50 +01:00
|
|
|
}
|
|
|
|
|
2022-12-12 02:33:45 +01:00
|
|
|
async function move(account): Promise<void> {
|
2022-12-12 02:28:11 +01:00
|
|
|
const confirm = await os.confirm({
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "warning",
|
|
|
|
text: i18n.t("migrationConfirm", { account: account.toString() }),
|
2022-12-12 02:28:11 +01:00
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
2023-04-08 02:01:42 +02:00
|
|
|
os.apiWithDialog("i/move", {
|
2022-12-12 02:33:45 +01:00
|
|
|
moveToAccount: account,
|
2022-12-09 23:28:50 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.security,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-lock")}`,
|
2022-12-09 23:28:50 +01:00
|
|
|
});
|
|
|
|
</script>
|