2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2021-11-28 12:07:37 +01:00
|
|
|
<div class="llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
|
2022-07-17 22:03:39 +02:00
|
|
|
<div class="avatar">
|
2023-01-16 06:18:11 +01:00
|
|
|
<MkAvatar class="avatar" :user="$i" @click="changeAvatar"/>
|
2022-07-17 16:18:05 +02:00
|
|
|
<MkButton primary rounded class="avatarEdit" @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton>
|
2020-11-28 16:18:54 +01:00
|
|
|
</div>
|
2022-07-17 16:18:05 +02:00
|
|
|
<MkButton primary rounded class="bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton>
|
2021-11-28 12:07:37 +01:00
|
|
|
</div>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="profile.name" :max="30" manual-save>
|
2022-01-28 03:39:49 +01:00
|
|
|
<template #label>{{ i18n.ts._profile.name }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkTextarea v-model="profile.description" :max="500" tall manual-save>
|
2022-01-28 03:39:49 +01:00
|
|
|
<template #label>{{ i18n.ts._profile.description }}</template>
|
|
|
|
<template #caption>{{ i18n.ts._profile.youCanIncludeHashtags }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkTextarea>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="profile.location" manual-save>
|
2022-01-28 03:39:49 +01:00
|
|
|
<template #label>{{ i18n.ts.location }}</template>
|
2022-12-20 07:24:31 +01:00
|
|
|
<template #prefix><i class="ti ti-map-pin"></i></template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="profile.birthday" type="date" manual-save>
|
2022-01-28 03:39:49 +01:00
|
|
|
<template #label>{{ i18n.ts.birthday }}</template>
|
2022-12-20 07:24:31 +01:00
|
|
|
<template #prefix><i class="ti ti-cake"></i></template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkSelect v-model="profile.lang">
|
2022-01-28 03:39:49 +01:00
|
|
|
<template #label>{{ i18n.ts.language }}</template>
|
2022-02-26 07:13:44 +01:00
|
|
|
<option v-for="x in Object.keys(langmap)" :key="x" :value="x">{{ langmap[x].nativeName }}</option>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkSelect>
|
2021-02-13 04:28:26 +01:00
|
|
|
|
2023-01-05 13:04:56 +01:00
|
|
|
<FormSlot>
|
2023-01-09 01:41:25 +01:00
|
|
|
<MkFolder>
|
2022-12-20 07:24:31 +01:00
|
|
|
<template #icon><i class="ti ti-list"></i></template>
|
2022-02-20 08:53:06 +01:00
|
|
|
<template #label>{{ i18n.ts._profile.metadataEdit }}</template>
|
|
|
|
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 13:04:56 +01:00
|
|
|
<FormSplit v-for="(record, i) in fields" :min-width="250">
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="record.name" small>
|
2022-02-25 10:53:08 +01:00
|
|
|
<template #label>{{ i18n.ts._profile.metadataLabel }} #{{ i + 1 }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="record.value" small>
|
2022-02-25 10:53:08 +01:00
|
|
|
<template #label>{{ i18n.ts._profile.metadataContent }} #{{ i + 1 }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2022-02-25 10:53:08 +01:00
|
|
|
</FormSplit>
|
2023-01-05 13:04:56 +01:00
|
|
|
<div>
|
|
|
|
<MkButton :disabled="fields.length >= 16" inline style="margin-right: 8px;" @click="addField"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
|
|
|
<MkButton inline primary @click="saveFields"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
|
|
|
|
</div>
|
2022-02-20 08:53:06 +01:00
|
|
|
</div>
|
2023-01-09 01:41:25 +01:00
|
|
|
</MkFolder>
|
2022-01-28 03:39:49 +01:00
|
|
|
<template #caption>{{ i18n.ts._profile.metadataDescription }}</template>
|
2021-11-28 12:07:37 +01:00
|
|
|
</FormSlot>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2023-01-09 01:41:25 +01:00
|
|
|
<MkFolder>
|
2022-12-27 06:25:20 +01:00
|
|
|
<template #label>{{ i18n.ts.advancedSettings }}</template>
|
|
|
|
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-01-07 06:59:54 +01:00
|
|
|
<MkSwitch v-model="profile.isCat">{{ i18n.ts.flagAsCat }}<template #caption>{{ i18n.ts.flagAsCatDescription }}</template></MkSwitch>
|
|
|
|
<MkSwitch v-model="profile.isBot">{{ i18n.ts.flagAsBot }}<template #caption>{{ i18n.ts.flagAsBotDescription }}</template></MkSwitch>
|
2022-12-27 06:25:20 +01:00
|
|
|
</div>
|
2023-01-09 01:41:25 +01:00
|
|
|
</MkFolder>
|
2022-12-27 06:25:20 +01:00
|
|
|
|
2023-01-07 06:59:54 +01:00
|
|
|
<MkSwitch v-model="profile.showTimelineReplies">{{ i18n.ts.flagShowTimelineReplies }}<template #caption>{{ i18n.ts.flagShowTimelineRepliesDescription }} {{ i18n.ts.reflectMayTakeTime }}</template></MkSwitch>
|
2021-11-28 12:07:37 +01:00
|
|
|
</div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-16 13:31:09 +01:00
|
|
|
<script lang="ts" setup>
|
2022-06-11 08:45:44 +02:00
|
|
|
import { reactive, watch } from 'vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-07 07:09:46 +01:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
2023-01-07 06:59:54 +01:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2023-01-07 07:09:46 +01:00
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
2022-02-20 08:53:06 +01:00
|
|
|
import FormSplit from '@/components/form/split.vue';
|
2023-01-09 01:41:25 +01:00
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2021-11-28 12:07:37 +01:00
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2022-02-26 07:13:44 +01:00
|
|
|
import { host } from '@/config';
|
2021-11-11 18:02:25 +01:00
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as os from '@/os';
|
2022-01-16 13:31:09 +01:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { $i } from '@/account';
|
2022-02-26 07:13:44 +01:00
|
|
|
import { langmap } from '@/scripts/langmap';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2023-01-21 05:14:55 +01:00
|
|
|
import { claimAchievement } from '@/scripts/achievements';
|
2022-01-16 13:31:09 +01: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 08:02:48 +01:00
|
|
|
showTimelineReplies: $i.showTimelineReplies,
|
2022-01-16 13:31:09 +01:00
|
|
|
});
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-16 13:31:09 +01:00
|
|
|
watch(() => profile, () => {
|
|
|
|
save();
|
|
|
|
}, {
|
|
|
|
deep: true,
|
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-02-20 08:53:06 +01: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 13:31:09 +01: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 08:02:48 +01:00
|
|
|
showTimelineReplies: !!profile.showTimelineReplies,
|
2022-01-16 13:31:09 +01:00
|
|
|
});
|
2023-01-21 05:14:55 +01:00
|
|
|
claimAchievement('profileFilled');
|
|
|
|
if (profile.name === 'syuilo' || profile.name === 'しゅいろ') {
|
|
|
|
claimAchievement('setNameToSyuilo');
|
|
|
|
}
|
|
|
|
if (profile.isCat) {
|
|
|
|
claimAchievement('markedAsCat');
|
|
|
|
}
|
2022-01-16 13:31:09 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-16 13:31:09 +01:00
|
|
|
function changeAvatar(ev) {
|
2022-01-28 03:53:12 +01:00
|
|
|
selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
|
2022-06-11 08:45:44 +02:00
|
|
|
let originalOrCropped = file;
|
|
|
|
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
text: i18n.t('cropImageAsk'),
|
2023-02-10 02:45:32 +01:00
|
|
|
okText: i18n.ts.cropYes,
|
|
|
|
cancelText: i18n.ts.cropNo,
|
2022-06-11 08:45:44 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!canceled) {
|
|
|
|
originalOrCropped = await os.cropImage(file, {
|
|
|
|
aspectRatio: 1,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-16 13:31:09 +01:00
|
|
|
const i = await os.apiWithDialog('i/update', {
|
2022-06-11 08:45:44 +02:00
|
|
|
avatarId: originalOrCropped.id,
|
2022-01-16 13:31:09 +01:00
|
|
|
});
|
|
|
|
$i.avatarId = i.avatarId;
|
|
|
|
$i.avatarUrl = i.avatarUrl;
|
2023-01-21 05:14:55 +01:00
|
|
|
claimAchievement('profileFilled');
|
2022-01-16 13:31:09 +01:00
|
|
|
});
|
|
|
|
}
|
2021-02-13 04:28:26 +01:00
|
|
|
|
2022-01-16 13:31:09 +01:00
|
|
|
function changeBanner(ev) {
|
2022-01-28 03:53:12 +01:00
|
|
|
selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => {
|
2022-06-11 08:45:44 +02:00
|
|
|
let originalOrCropped = file;
|
|
|
|
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
text: i18n.t('cropImageAsk'),
|
2023-02-10 02:45:32 +01:00
|
|
|
okText: i18n.ts.cropYes,
|
|
|
|
cancelText: i18n.ts.cropNo,
|
2022-06-11 08:45:44 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!canceled) {
|
|
|
|
originalOrCropped = await os.cropImage(file, {
|
|
|
|
aspectRatio: 2,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-16 13:31:09 +01:00
|
|
|
const i = await os.apiWithDialog('i/update', {
|
2022-06-11 08:45:44 +02:00
|
|
|
bannerId: originalOrCropped.id,
|
2022-01-16 13:31:09 +01:00
|
|
|
});
|
|
|
|
$i.bannerId = i.bannerId;
|
|
|
|
$i.bannerUrl = i.bannerUrl;
|
|
|
|
});
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.profile,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-user',
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-12-27 10:29:39 +01:00
|
|
|
<style lang="scss" scoped>
|
2020-01-29 23:13:36 +01:00
|
|
|
.llvierxe {
|
2020-11-28 16:18:54 +01:00
|
|
|
position: relative;
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center;
|
2022-07-17 22:03:39 +02:00
|
|
|
border: solid 1px var(--divider);
|
2021-11-28 12:07:37 +01:00
|
|
|
border-radius: 10px;
|
2022-07-13 14:41:06 +02:00
|
|
|
overflow: clip;
|
2020-01-29 23:13:36 +01:00
|
|
|
|
2021-11-28 12:07:37 +01: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 16:18:54 +01:00
|
|
|
}
|
|
|
|
|
2021-11-28 12:07:37 +01:00
|
|
|
> .bannerEdit {
|
2020-11-28 16:18:54 +01:00
|
|
|
position: absolute;
|
2021-11-28 12:07:37 +01:00
|
|
|
top: 16px;
|
|
|
|
right: 16px;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|