spec(profile): 相互リンクバナーのサイズ変更・ID付与 (MisskeyIO#696)

This commit is contained in:
まっちゃとーにゅ 2024-08-14 13:20:07 +09:00 committed by GitHub
parent 2896ff3130
commit 4c6e594ff0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 9 deletions

View File

@ -49,6 +49,7 @@ export class MiUserProfile {
public mutualLinkSections: { public mutualLinkSections: {
name: string | null; name: string | null;
mutualLinks: { mutualLinks: {
id: string;
fileId: MiDriveFile['id']; fileId: MiDriveFile['id'];
description: string | null; description: string | null;
imgSrc: string; imgSrc: string;

View File

@ -397,12 +397,13 @@ export const packedUserDetailedNotMeOnlySchema = {
items: { items: {
type: 'object', type: 'object',
properties: { properties: {
id: { type: 'string', format: 'misskey:id' },
url: { type: 'string' }, url: { type: 'string' },
fileId: { type: 'string', format: 'misskey:id' }, fileId: { type: 'string', format: 'misskey:id' },
description: { type: 'string', nullable: true }, description: { type: 'string', nullable: true },
imgSrc: { type: 'string' }, imgSrc: { type: 'string' },
}, },
required: ['url', 'fileId'], required: ['id', 'url', 'fileId'],
}, },
}, },
}, },

View File

@ -35,6 +35,7 @@ import { AvatarDecorationService } from '@/core/AvatarDecorationService.js';
import { notificationRecieveConfig } from '@/models/json-schema/user.js'; import { notificationRecieveConfig } from '@/models/json-schema/user.js';
import { ApiLoggerService } from '../../ApiLoggerService.js'; import { ApiLoggerService } from '../../ApiLoggerService.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { IdService } from "@/core/IdService.js";
export const meta = { export const meta = {
tags: ['account'], tags: ['account'],
@ -268,6 +269,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.pagesRepository) @Inject(DI.pagesRepository)
private pagesRepository: PagesRepository, private pagesRepository: PagesRepository,
private idService: IdService,
private userEntityService: UserEntityService, private userEntityService: UserEntityService,
private driveFileEntityService: DriveFileEntityService, private driveFileEntityService: DriveFileEntityService,
private globalEventService: GlobalEventService, private globalEventService: GlobalEventService,
@ -377,6 +379,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} }
return { return {
id: this.idService.gen(),
url: mutualLink.url, url: mutualLink.url,
fileId: file.id, fileId: file.id,
imgSrc: this.driveFileEntityService.getPublicUrl(file), imgSrc: this.driveFileEntityService.getPublicUrl(file),

View File

@ -183,7 +183,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, reactive, ref, watch, defineAsyncComponent, Ref } from 'vue'; import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
@ -202,7 +202,6 @@ import { defaultStore } from '@/store.js';
import { globalEvents } from '@/events.js'; import { globalEvents } from '@/events.js';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import * as Misskey from "misskey-js";
const $i = signinRequired(); const $i = signinRequired();
@ -225,7 +224,7 @@ watch(() => profile, () => {
deep: true, deep: true,
}); });
const mutualLinkSections = ref($i.mutualLinkSections ?? []) as Ref<Misskey.entities.UserDetailed['mutualLinkSections']>; const mutualLinkSections = ref($i.mutualLinkSections.map(section => ({ ...section, id: Math.random().toString(), none: !section.name })) ?? []);
const fields = ref($i.fields.map(field => ({ id: Math.random().toString(), name: field.name, value: field.value })) ?? []); const fields = ref($i.fields.map(field => ({ id: Math.random().toString(), name: field.name, value: field.value })) ?? []);
const fieldEditMode = ref(false); const fieldEditMode = ref(false);
const mutualLinkSectionEditMode = ref(false); const mutualLinkSectionEditMode = ref(false);
@ -240,6 +239,7 @@ function addField() {
function addMutualLinks(index:number) { function addMutualLinks(index:number) {
mutualLinkSections.value[index].mutualLinks.push({ mutualLinkSections.value[index].mutualLinks.push({
id: Math.random().toString(),
fileId: '', fileId: '',
url: '', url: '',
imgSrc: '', imgSrc: '',
@ -249,7 +249,9 @@ function addMutualLinks(index:number) {
function addMutualLinkSections() { function addMutualLinkSections() {
mutualLinkSections.value.push({ mutualLinkSections.value.push({
id: Math.random().toString(),
name: 'New Section', name: 'New Section',
none: false,
mutualLinks: [], mutualLinks: [],
}); });
} }
@ -495,8 +497,8 @@ definePageMetadata(() => ({
} }
.mutualLinkImg { .mutualLinkImg {
max-width: 150px; max-width: 200px;
max-height: 30px; max-height: 40px;
object-fit: contain; object-fit: contain;
} }

View File

@ -84,7 +84,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div v-for="(section, index) in user?.mutualLinkSections" :key="index" :class="$style.mutualLinkSections"> <div v-for="(section, index) in user?.mutualLinkSections" :key="index" :class="$style.mutualLinkSections">
<span v-if="section.name">{{ section.name }}</span> <span v-if="section.name">{{ section.name }}</span>
<div :class="$style.mutualLinks"> <div :class="$style.mutualLinks">
<div v-for="(mutualLink, i) in section.mutualLinks" :key="i"> <div v-for="mutualLink in section.mutualLinks" :key="mutualLink.id">
<MkLink :hideIcon="true" :url="mutualLink.url"> <MkLink :hideIcon="true" :url="mutualLink.url">
<img :class="$style.mutualLinkImg" :src="mutualLink.imgSrc" :alt="mutualLink.description"/> <img :class="$style.mutualLinkImg" :src="mutualLink.imgSrc" :alt="mutualLink.description"/>
</MkLink> </MkLink>
@ -832,7 +832,7 @@ onUnmounted(() => {
} }
.mutualLinkImg { .mutualLinkImg {
max-width: 150px; max-width: 200px;
max-height: 30px; max-height: 40px;
} }
</style> </style>

View File

@ -3845,6 +3845,8 @@ export type components = {
mutualLinkSections: ({ mutualLinkSections: ({
name: string | null; name: string | null;
mutualLinks: ({ mutualLinks: ({
/** Format: misskey:id */
id: string;
url: string; url: string;
/** Format: misskey:id */ /** Format: misskey:id */
fileId: string; fileId: string;