2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-11-28 20:07:37 +09: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-16 21:31:09 +09:00
|
|
|
<MkButton primary class="avatarEdit" @click="changeAvatar">{{ i18n.locale._profile.changeAvatar }}</MkButton>
|
2020-11-29 00:18:54 +09:00
|
|
|
</div>
|
2022-01-16 21:31:09 +09:00
|
|
|
<MkButton primary class="bannerEdit" @click="changeBanner">{{ i18n.locale._profile.changeBanner }}</MkButton>
|
2021-11-28 20:07:37 +09:00
|
|
|
</div>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormInput v-model="profile.name" :max="30" manual-save class="_formBlock">
|
|
|
|
<template #label>{{ i18n.locale._profile.name }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormInput>
|
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormTextarea v-model="profile.description" :max="500" tall manual-save class="_formBlock">
|
|
|
|
<template #label>{{ i18n.locale._profile.description }}</template>
|
|
|
|
<template #caption>{{ i18n.locale._profile.youCanIncludeHashtags }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormTextarea>
|
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormInput v-model="profile.location" manual-save class="_formBlock">
|
|
|
|
<template #label>{{ i18n.locale.location }}</template>
|
2021-04-20 23:22:59 +09:00
|
|
|
<template #prefix><i class="fas fa-map-marker-alt"></i></template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormInput>
|
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormInput v-model="profile.birthday" type="date" manual-save class="_formBlock">
|
|
|
|
<template #label>{{ i18n.locale.birthday }}</template>
|
2021-04-20 23:22:59 +09:00
|
|
|
<template #prefix><i class="fas fa-birthday-cake"></i></template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormInput>
|
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormSelect v-model="profile.lang" class="_formBlock">
|
|
|
|
<template #label>{{ i18n.locale.language }}</template>
|
2021-11-19 19:36:12 +09:00
|
|
|
<option v-for="x in langs" :key="x[0]" :value="x[0]">{{ x[1] }}</option>
|
2021-02-13 12:28:26 +09:00
|
|
|
</FormSelect>
|
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
<FormSlot>
|
2022-01-16 21:31:09 +09:00
|
|
|
<MkButton @click="editMetadata">{{ i18n.locale._profile.metadataEdit }}</MkButton>
|
|
|
|
<template #caption>{{ i18n.locale._profile.metadataDescription }}</template>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSlot>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormSwitch v-model="profile.isCat" class="_formBlock">{{ i18n.locale.flagAsCat }}<template #caption>{{ i18n.locale.flagAsCatDescription }}</template></FormSwitch>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormSwitch v-model="profile.isBot" class="_formBlock">{{ i18n.locale.flagAsBot }}<template #caption>{{ i18n.locale.flagAsBotDescription }}</template></FormSwitch>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<FormSwitch v-model="profile.alwaysMarkNsfw" class="_formBlock">{{ i18n.locale.alwaysMarkSensitive }}</FormSwitch>
|
2021-11-28 20:07:37 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineComponent, reactive, watch } from 'vue';
|
2021-11-28 20:07:37 +09: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';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import { host, langs } from '@/config';
|
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-01-16 21:31:09 +09:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { $i } from '@/account';
|
|
|
|
|
|
|
|
const profile = reactive({
|
|
|
|
name: $i.name,
|
|
|
|
description: $i.description,
|
|
|
|
location: $i.location,
|
|
|
|
birthday: $i.birthday,
|
|
|
|
lang: $i.lang,
|
|
|
|
isBot: $i.isBot,
|
|
|
|
isCat: $i.isCat,
|
|
|
|
alwaysMarkNsfw: $i.alwaysMarkNsfw,
|
|
|
|
});
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
const additionalFields = reactive({
|
|
|
|
fieldName0: $i.fields[0] ? $i.fields[0].name : null,
|
|
|
|
fieldValue0: $i.fields[0] ? $i.fields[0].value : null,
|
|
|
|
fieldName1: $i.fields[1] ? $i.fields[1].name : null,
|
|
|
|
fieldValue1: $i.fields[1] ? $i.fields[1].value : null,
|
|
|
|
fieldName2: $i.fields[2] ? $i.fields[2].name : null,
|
|
|
|
fieldValue2: $i.fields[2] ? $i.fields[2].value : null,
|
|
|
|
fieldName3: $i.fields[3] ? $i.fields[3].name : null,
|
|
|
|
fieldValue3: $i.fields[3] ? $i.fields[3].value : null,
|
|
|
|
});
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
watch(() => profile, () => {
|
|
|
|
save();
|
|
|
|
}, {
|
|
|
|
deep: true,
|
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-01-16 21:31:09 +09: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,
|
|
|
|
alwaysMarkNsfw: !!profile.alwaysMarkNsfw,
|
|
|
|
});
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
function changeAvatar(ev) {
|
|
|
|
selectFile(ev.currentTarget || ev.target, i18n.locale.avatar).then(async (file) => {
|
|
|
|
const i = await os.apiWithDialog('i/update', {
|
|
|
|
avatarId: file.id,
|
|
|
|
});
|
|
|
|
$i.avatarId = i.avatarId;
|
|
|
|
$i.avatarUrl = i.avatarUrl;
|
|
|
|
});
|
|
|
|
}
|
2021-02-13 12:28:26 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
function changeBanner(ev) {
|
|
|
|
selectFile(ev.currentTarget || ev.target, i18n.locale.banner).then(async (file) => {
|
|
|
|
const i = await os.apiWithDialog('i/update', {
|
|
|
|
bannerId: file.id,
|
|
|
|
});
|
|
|
|
$i.bannerId = i.bannerId;
|
|
|
|
$i.bannerUrl = i.bannerUrl;
|
|
|
|
});
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-01-16 21:31:09 +09:00
|
|
|
async function editMetadata() {
|
|
|
|
const { canceled, result } = await os.form(i18n.locale._profile.metadata, {
|
|
|
|
fieldName0: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataLabel + ' 1',
|
|
|
|
default: additionalFields.fieldName0,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2022-01-16 21:31:09 +09:00
|
|
|
fieldValue0: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataContent + ' 1',
|
|
|
|
default: additionalFields.fieldValue0,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2022-01-16 21:31:09 +09:00
|
|
|
fieldName1: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataLabel + ' 2',
|
|
|
|
default: additionalFields.fieldName1,
|
2020-11-25 21:31:34 +09:00
|
|
|
},
|
2022-01-16 21:31:09 +09:00
|
|
|
fieldValue1: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataContent + ' 2',
|
|
|
|
default: additionalFields.fieldValue1,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2022-01-16 21:31:09 +09:00
|
|
|
fieldName2: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataLabel + ' 3',
|
|
|
|
default: additionalFields.fieldName2,
|
|
|
|
},
|
|
|
|
fieldValue2: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataContent + ' 3',
|
|
|
|
default: additionalFields.fieldValue2,
|
|
|
|
},
|
|
|
|
fieldName3: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataLabel + ' 4',
|
|
|
|
default: additionalFields.fieldName3,
|
|
|
|
},
|
|
|
|
fieldValue3: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale._profile.metadataContent + ' 4',
|
|
|
|
default: additionalFields.fieldValue3,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
additionalFields.fieldName0 = result.fieldName0;
|
|
|
|
additionalFields.fieldValue0 = result.fieldValue0;
|
|
|
|
additionalFields.fieldName1 = result.fieldName1;
|
|
|
|
additionalFields.fieldValue1 = result.fieldValue1;
|
|
|
|
additionalFields.fieldName2 = result.fieldName2;
|
|
|
|
additionalFields.fieldValue2 = result.fieldValue2;
|
|
|
|
additionalFields.fieldName3 = result.fieldName3;
|
|
|
|
additionalFields.fieldValue3 = result.fieldValue3;
|
|
|
|
|
|
|
|
const fields = [
|
|
|
|
{ name: additionalFields.fieldName0, value: additionalFields.fieldValue0 },
|
|
|
|
{ name: additionalFields.fieldName1, value: additionalFields.fieldValue1 },
|
|
|
|
{ name: additionalFields.fieldName2, value: additionalFields.fieldValue2 },
|
|
|
|
{ name: additionalFields.fieldName3, value: additionalFields.fieldValue3 },
|
|
|
|
];
|
|
|
|
|
|
|
|
os.api('i/update', {
|
|
|
|
fields,
|
|
|
|
}).then(i => {
|
|
|
|
os.success();
|
|
|
|
}).catch(err => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: err.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: i18n.locale.profile,
|
|
|
|
icon: 'fas fa-user',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-01-30 07:13:36 +09:00
|
|
|
.llvierxe {
|
2020-11-29 00:18:54 +09:00
|
|
|
position: relative;
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center;
|
2021-11-28 20:07:37 +09:00
|
|
|
border-radius: 10px;
|
|
|
|
overflow: clip;
|
2020-01-30 07:13:36 +09:00
|
|
|
|
2021-11-28 20:07:37 +09: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-29 00:18:54 +09:00
|
|
|
}
|
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
> .bannerEdit {
|
2020-11-29 00:18:54 +09:00
|
|
|
position: absolute;
|
2021-11-28 20:07:37 +09:00
|
|
|
top: 16px;
|
|
|
|
right: 16px;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|