2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<div class="_formRoot">
|
|
|
|
<div class="llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
|
|
|
|
<div class="avatar _acrylic">
|
|
|
|
<MkAvatar class="avatar" :user="$i" :disable-link="true" @click="changeAvatar"/>
|
2022-01-28 04:39:49 +02:00
|
|
|
<MkButton primary class="avatarEdit" @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton>
|
2020-11-28 17:18:54 +02:00
|
|
|
</div>
|
2022-01-28 04:39:49 +02:00
|
|
|
<MkButton primary class="bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton>
|
2021-11-28 13:07:37 +02:00
|
|
|
</div>
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
<FormInput v-model="profile.name" :max="30" manual-save class="_formBlock">
|
2022-01-28 04:39:49 +02:00
|
|
|
<template #label>{{ i18n.ts._profile.name }}</template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormInput>
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
<FormTextarea v-model="profile.description" :max="500" tall manual-save class="_formBlock">
|
2022-01-28 04:39:49 +02:00
|
|
|
<template #label>{{ i18n.ts._profile.description }}</template>
|
|
|
|
<template #caption>{{ i18n.ts._profile.youCanIncludeHashtags }}</template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormTextarea>
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
<FormInput v-model="profile.location" manual-save class="_formBlock">
|
2022-01-28 04:39:49 +02:00
|
|
|
<template #label>{{ i18n.ts.location }}</template>
|
2021-04-20 17:22:59 +03:00
|
|
|
<template #prefix><i class="fas fa-map-marker-alt"></i></template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormInput>
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
<FormInput v-model="profile.birthday" type="date" manual-save class="_formBlock">
|
2022-01-28 04:39:49 +02:00
|
|
|
<template #label>{{ i18n.ts.birthday }}</template>
|
2021-04-20 17:22:59 +03:00
|
|
|
<template #prefix><i class="fas fa-birthday-cake"></i></template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormInput>
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
<FormSelect v-model="profile.lang" class="_formBlock">
|
2022-01-28 04:39:49 +02:00
|
|
|
<template #label>{{ i18n.ts.language }}</template>
|
2022-02-26 08:13:44 +02:00
|
|
|
<option v-for="x in Object.keys(langmap)" :key="x" :value="x">{{ langmap[x].nativeName }}</option>
|
2021-02-13 05:28:26 +02:00
|
|
|
</FormSelect>
|
|
|
|
|
2022-02-20 09:53:06 +02:00
|
|
|
<FormSlot class="_formBlock">
|
|
|
|
<FormFolder>
|
|
|
|
<template #icon><i class="fas fa-table-list"></i></template>
|
|
|
|
<template #label>{{ i18n.ts._profile.metadataEdit }}</template>
|
|
|
|
|
|
|
|
<div class="_formRoot">
|
2022-02-25 11:53:08 +02:00
|
|
|
<FormSplit v-for="(record, i) in fields" :min-width="250" class="_formBlock">
|
|
|
|
<FormInput v-model="record.name">
|
|
|
|
<template #label>{{ i18n.ts._profile.metadataLabel }} #{{ i + 1 }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="record.value">
|
|
|
|
<template #label>{{ i18n.ts._profile.metadataContent }} #{{ i + 1 }}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
2022-02-20 12:01:13 +02:00
|
|
|
<MkButton :disabled="fields.length >= 16" inline style="margin-right: 8px;" @click="addField"><i class="fas fa-plus"></i> {{ i18n.ts.add }}</MkButton>
|
|
|
|
<MkButton inline primary @click="saveFields"><i class="fas fa-check"></i> {{ i18n.ts.save }}</MkButton>
|
2022-02-20 09:53:06 +02:00
|
|
|
</div>
|
|
|
|
</FormFolder>
|
2022-01-28 04:39:49 +02:00
|
|
|
<template #caption>{{ i18n.ts._profile.metadataDescription }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSlot>
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2022-01-28 04:39:49 +02:00
|
|
|
<FormSwitch v-model="profile.isCat" class="_formBlock">{{ i18n.ts.flagAsCat }}<template #caption>{{ i18n.ts.flagAsCatDescription }}</template></FormSwitch>
|
2022-03-25 09:27:41 +02:00
|
|
|
<FormSwitch v-model="profile.showTimelineReplies" class="_formBlock">{{ i18n.ts.flagShowTimelineReplies }}<template #caption>{{ i18n.ts.flagShowTimelineRepliesDescription }} {{ i18n.ts.reflectMayTakeTime }}</template></FormSwitch>
|
2022-01-28 04:39:49 +02:00
|
|
|
<FormSwitch v-model="profile.isBot" class="_formBlock">{{ i18n.ts.flagAsBot }}<template #caption>{{ i18n.ts.flagAsBotDescription }}</template></FormSwitch>
|
2021-11-28 13:07:37 +02:00
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
<script lang="ts" setup>
|
2022-06-11 09:45:44 +03:00
|
|
|
import { reactive, watch } from 'vue';
|
2021-11-28 13:07:37 +02:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import FormInput from '@/components/form/input.vue';
|
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormSelect from '@/components/form/select.vue';
|
2022-02-20 09:53:06 +02:00
|
|
|
import FormSplit from '@/components/form/split.vue';
|
|
|
|
import FormFolder from '@/components/form/folder.vue';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2022-02-26 08:13:44 +02:00
|
|
|
import { host } from '@/config';
|
2021-11-11 19:02:25 +02:00
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as os from '@/os';
|
2022-01-16 14:31:09 +02:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { $i } from '@/account';
|
2022-02-26 08:13:44 +02:00
|
|
|
import { langmap } from '@/scripts/langmap';
|
2022-06-20 11:38:49 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-01-16 14:31:09 +02:00
|
|
|
|
|
|
|
const profile = reactive({
|
|
|
|
name: $i.name,
|
|
|
|
description: $i.description,
|
|
|
|
location: $i.location,
|
|
|
|
birthday: $i.birthday,
|
|
|
|
lang: $i.lang,
|
|
|
|
isBot: $i.isBot,
|
|
|
|
isCat: $i.isCat,
|
2022-02-06 09:02:48 +02:00
|
|
|
showTimelineReplies: $i.showTimelineReplies,
|
2022-01-16 14:31:09 +02:00
|
|
|
});
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
watch(() => profile, () => {
|
|
|
|
save();
|
|
|
|
}, {
|
|
|
|
deep: true,
|
|
|
|
});
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2022-02-20 09:53:06 +02:00
|
|
|
const fields = reactive($i.fields.map(field => ({ name: field.name, value: field.value })));
|
|
|
|
|
|
|
|
function addField() {
|
|
|
|
fields.push({
|
|
|
|
name: '',
|
|
|
|
value: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fields.length < 4) {
|
|
|
|
addField();
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveFields() {
|
|
|
|
os.apiWithDialog('i/update', {
|
|
|
|
fields: fields.filter(field => field.name !== '' && field.value !== ''),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
function save() {
|
|
|
|
os.apiWithDialog('i/update', {
|
|
|
|
name: profile.name || null,
|
|
|
|
description: profile.description || null,
|
|
|
|
location: profile.location || null,
|
|
|
|
birthday: profile.birthday || null,
|
|
|
|
lang: profile.lang || null,
|
|
|
|
isBot: !!profile.isBot,
|
|
|
|
isCat: !!profile.isCat,
|
2022-02-06 09:02:48 +02:00
|
|
|
showTimelineReplies: !!profile.showTimelineReplies,
|
2022-01-16 14:31:09 +02:00
|
|
|
});
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
function changeAvatar(ev) {
|
2022-01-28 04:53:12 +02:00
|
|
|
selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
|
2022-06-11 09:45:44 +03:00
|
|
|
let originalOrCropped = file;
|
|
|
|
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
text: i18n.t('cropImageAsk'),
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!canceled) {
|
|
|
|
originalOrCropped = await os.cropImage(file, {
|
|
|
|
aspectRatio: 1,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
const i = await os.apiWithDialog('i/update', {
|
2022-06-11 09:45:44 +03:00
|
|
|
avatarId: originalOrCropped.id,
|
2022-01-16 14:31:09 +02:00
|
|
|
});
|
|
|
|
$i.avatarId = i.avatarId;
|
|
|
|
$i.avatarUrl = i.avatarUrl;
|
|
|
|
});
|
|
|
|
}
|
2021-02-13 05:28:26 +02:00
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
function changeBanner(ev) {
|
2022-01-28 04:53:12 +02:00
|
|
|
selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => {
|
2022-06-11 09:45:44 +03:00
|
|
|
let originalOrCropped = file;
|
|
|
|
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
text: i18n.t('cropImageAsk'),
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!canceled) {
|
|
|
|
originalOrCropped = await os.cropImage(file, {
|
|
|
|
aspectRatio: 2,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-16 14:31:09 +02:00
|
|
|
const i = await os.apiWithDialog('i/update', {
|
2022-06-11 09:45:44 +03:00
|
|
|
bannerId: originalOrCropped.id,
|
2022-01-16 14:31:09 +02:00
|
|
|
});
|
|
|
|
$i.bannerId = i.bannerId;
|
|
|
|
$i.bannerUrl = i.bannerUrl;
|
|
|
|
});
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.profile,
|
|
|
|
icon: 'fas fa-user',
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-01-30 00:13:36 +02:00
|
|
|
.llvierxe {
|
2020-11-28 17:18:54 +02:00
|
|
|
position: relative;
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center;
|
2021-11-28 13:07:37 +02:00
|
|
|
border-radius: 10px;
|
2022-07-03 10:17:31 +03:00
|
|
|
overflow: hidden; overflow: clip;
|
2020-01-30 00:13:36 +02:00
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
> .avatar {
|
|
|
|
display: inline-block;
|
|
|
|
text-align: center;
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
display: inline-block;
|
|
|
|
width: 72px;
|
|
|
|
height: 72px;
|
|
|
|
margin: 0 auto 16px auto;
|
|
|
|
}
|
2020-11-28 17:18:54 +02:00
|
|
|
}
|
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
> .bannerEdit {
|
2020-11-28 17:18:54 +02:00
|
|
|
position: absolute;
|
2021-11-28 13:07:37 +02:00
|
|
|
top: 16px;
|
|
|
|
right: 16px;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|