2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-05-08 08:29:19 +00:00
|
|
|
<template>
|
|
|
|
<div class="_gaps">
|
|
|
|
<MkInfo>{{ i18n.ts._initialAccountSetting.theseSettingsCanEditLater }}</MkInfo>
|
|
|
|
|
|
|
|
<FormSlot>
|
|
|
|
<template #label>{{ i18n.ts.avatar }}</template>
|
|
|
|
<div v-adaptive-bg :class="$style.avatarSection" class="_panel">
|
|
|
|
<MkAvatar :class="$style.avatar" :user="$i" @click="setAvatar"/>
|
|
|
|
<div style="margin-top: 16px;">
|
|
|
|
<MkButton primary rounded inline @click="setAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</FormSlot>
|
|
|
|
|
2023-05-19 04:58:09 +00:00
|
|
|
<MkInput v-model="name" :max="30" manualSave data-cy-user-setup-user-name>
|
2023-05-08 08:29:19 +00:00
|
|
|
<template #label>{{ i18n.ts._profile.name }}</template>
|
|
|
|
</MkInput>
|
|
|
|
|
2023-05-19 04:58:09 +00:00
|
|
|
<MkTextarea v-model="description" :max="500" tall manualSave data-cy-user-setup-user-description>
|
2023-05-08 08:29:19 +00:00
|
|
|
<template #label>{{ i18n.ts._profile.description }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
|
|
|
|
<MkInfo>{{ i18n.ts._initialAccountSetting.youCanEditMoreSettingsInSettingsPageLater }}</MkInfo>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, ref, watch } from 'vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { instance } from '@/instance.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2023-05-08 08:29:19 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
|
|
|
import MkInfo from '@/components/MkInfo.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { chooseFileFromPc } from '@/scripts/select-file.js';
|
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { $i } from '@/account.js';
|
2023-05-08 08:29:19 +00:00
|
|
|
|
2023-05-14 00:44:57 +00:00
|
|
|
const name = ref($i.name ?? '');
|
|
|
|
const description = ref($i.description ?? '');
|
2023-05-08 08:29:19 +00:00
|
|
|
|
|
|
|
watch(name, () => {
|
|
|
|
os.apiWithDialog('i/update', {
|
|
|
|
// 空文字列をnullにしたいので??は使うな
|
|
|
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
|
|
name: name.value || null,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(description, () => {
|
|
|
|
os.apiWithDialog('i/update', {
|
|
|
|
// 空文字列をnullにしたいので??は使うな
|
|
|
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
|
|
description: description.value || null,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function setAvatar(ev) {
|
|
|
|
chooseFileFromPc(false).then(async (files) => {
|
|
|
|
const file = files[0];
|
|
|
|
|
|
|
|
let originalOrCropped = file;
|
|
|
|
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
text: i18n.t('cropImageAsk'),
|
|
|
|
okText: i18n.ts.cropYes,
|
|
|
|
cancelText: i18n.ts.cropNo,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!canceled) {
|
|
|
|
originalOrCropped = await os.cropImage(file, {
|
|
|
|
aspectRatio: 1,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const i = await os.apiWithDialog('i/update', {
|
|
|
|
avatarId: originalOrCropped.id,
|
|
|
|
});
|
|
|
|
$i.avatarId = i.avatarId;
|
|
|
|
$i.avatarUrl = i.avatarUrl;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.avatarSection {
|
|
|
|
text-align: center;
|
|
|
|
padding: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.avatar {
|
|
|
|
width: 100px;
|
|
|
|
height: 100px;
|
|
|
|
}
|
|
|
|
</style>
|