Merge branch 'develop' into account_migration
This commit is contained in:
commit
ed02d089ed
|
@ -1,12 +1,12 @@
|
||||||
import { db } from '@/db/postgre.js';
|
import { db } from '@/db/postgre.js';
|
||||||
import { PageLike } from '@/models/entities/page-like.js';
|
import { PageLike } from '@/models/entities/page-like.js';
|
||||||
|
import type { User } from '@/models/entities/user.js';
|
||||||
import { Pages } from '../index.js';
|
import { Pages } from '../index.js';
|
||||||
import { User } from '@/models/entities/user.js';
|
|
||||||
|
|
||||||
export const PageLikeRepository = db.getRepository(PageLike).extend({
|
export const PageLikeRepository = db.getRepository(PageLike).extend({
|
||||||
async pack(
|
async pack(
|
||||||
src: PageLike['id'] | PageLike,
|
src: PageLike['id'] | PageLike,
|
||||||
me?: { id: User['id'] } | null | undefined
|
me?: { id: User['id'] } | null | undefined,
|
||||||
) {
|
) {
|
||||||
const like = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
|
const like = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ export const PageLikeRepository = db.getRepository(PageLike).extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
packMany(
|
packMany(
|
||||||
likes: any[],
|
likes: PageLike[],
|
||||||
me: { id: User['id'] }
|
me: { id: User['id'] },
|
||||||
) {
|
) {
|
||||||
return Promise.all(likes.map(x => this.pack(x, me)));
|
return Promise.all(likes.map(x => this.pack(x, me)));
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { db } from '@/db/postgre.js';
|
import { db } from '@/db/postgre.js';
|
||||||
import { Page } from '@/models/entities/page.js';
|
import { Page } from '@/models/entities/page.js';
|
||||||
import { Packed } from '@/misc/schema.js';
|
import type { Packed } from '@/misc/schema.js';
|
||||||
import { awaitAll } from '@/prelude/await-all.js';
|
import { awaitAll } from '@/prelude/await-all.js';
|
||||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
import type { DriveFile } from '@/models/entities/drive-file.js';
|
||||||
import { User } from '@/models/entities/user.js';
|
import type { User } from '@/models/entities/user.js';
|
||||||
import { Users, DriveFiles, PageLikes } from '../index.js';
|
import { Users, DriveFiles, PageLikes } from '../index.js';
|
||||||
|
|
||||||
export const PageRepository = db.getRepository(Page).extend({
|
export const PageRepository = db.getRepository(Page).extend({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import define from '../../../define.js';
|
|
||||||
import { GalleryPosts } from '@/models/index.js';
|
import { GalleryPosts } from '@/models/index.js';
|
||||||
|
import define from '../../../define.js';
|
||||||
import { makePaginationQuery } from '../../../common/make-pagination-query.js';
|
import { makePaginationQuery } from '../../../common/make-pagination-query.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -33,7 +33,7 @@ export const paramDef = {
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, paramDef, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`post.userId = :meId`, { meId: user.id });
|
.andWhere('post.userId = :meId', { meId: user.id });
|
||||||
|
|
||||||
const posts = await query
|
const posts = await query
|
||||||
.take(ps.limit)
|
.take(ps.limit)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import define from '../../define.js';
|
|
||||||
import { PageLikes } from '@/models/index.js';
|
import { PageLikes } from '@/models/index.js';
|
||||||
|
import define from '../../define.js';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -26,7 +26,7 @@ export const meta = {
|
||||||
ref: 'Page',
|
ref: 'Page',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export const paramDef = {
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, paramDef, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const query = makePaginationQuery(PageLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(PageLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`like.userId = :meId`, { meId: user.id })
|
.andWhere('like.userId = :meId', { meId: user.id })
|
||||||
.leftJoinAndSelect('like.page', 'page');
|
.leftJoinAndSelect('like.page', 'page');
|
||||||
|
|
||||||
const likes = await query
|
const likes = await query
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import define from '../../define.js';
|
|
||||||
import { Pages } from '@/models/index.js';
|
import { Pages } from '@/models/index.js';
|
||||||
|
import define from '../../define.js';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -33,7 +33,7 @@ export const paramDef = {
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, paramDef, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`page.userId = :meId`, { meId: user.id });
|
.andWhere('page.userId = :meId', { meId: user.id });
|
||||||
|
|
||||||
const pages = await query
|
const pages = await query
|
||||||
.take(ps.limit)
|
.take(ps.limit)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</header>
|
</header>
|
||||||
<p v-if="page.summary" :title="page.summary">{{ page.summary.length > 85 ? page.summary.slice(0, 85) + '…' : page.summary }}</p>
|
<p v-if="page.summary" :title="page.summary">{{ page.summary.length > 85 ? page.summary.slice(0, 85) + '…' : page.summary }}</p>
|
||||||
<footer>
|
<footer>
|
||||||
<img class="icon" :src="page.user.avatarUrl"/>
|
<img class="icon" :src="page.user.avatarUrl" aria-label="none"/>
|
||||||
<p>{{ userName(page.user) }}</p>
|
<p>{{ userName(page.user) }}</p>
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { userName } from '@/filters/user';
|
import { userName } from '@/filters/user';
|
||||||
import * as os from '@/os';
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineComponent, watch } from 'vue';
|
import { computed, defineComponent, watch, onMounted } from 'vue';
|
||||||
import { Virtual } from 'swiper';
|
import { Virtual } from 'swiper';
|
||||||
import { Swiper, SwiperSlide } from 'swiper/vue';
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||||
import MkFolder from '@/components/MkFolder.vue';
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
|
@ -137,6 +137,10 @@ function onSlideChange() {
|
||||||
function syncSlide(index) {
|
function syncSlide(index) {
|
||||||
swiperRef.slideTo(index);
|
swiperRef.slideTo(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
syncSlide(tabs.indexOf(swiperRef.activeIndex));
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -120,12 +120,7 @@ function like() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unlike() {
|
async function unlike() {
|
||||||
const confirm = await os.confirm({
|
os.api('gallery/posts/unlike', {
|
||||||
type: 'warning',
|
|
||||||
text: i18n.ts.unlikeConfirm,
|
|
||||||
});
|
|
||||||
if (confirm.canceled) return;
|
|
||||||
os.apiWithDialog('gallery/posts/unlike', {
|
|
||||||
postId: props.postId,
|
postId: props.postId,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
post.isLiked = false;
|
post.isLiked = false;
|
||||||
|
|
|
@ -153,12 +153,7 @@ function like() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unlike() {
|
async function unlike() {
|
||||||
const confirm = await os.confirm({
|
os.api('pages/unlike', {
|
||||||
type: 'warning',
|
|
||||||
text: i18n.ts.unlikeConfirm,
|
|
||||||
});
|
|
||||||
if (confirm.canceled) return;
|
|
||||||
os.apiWithDialog('pages/unlike', {
|
|
||||||
pageId: page.id,
|
pageId: page.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
page.isLiked = false;
|
page.isLiked = false;
|
||||||
|
|
|
@ -18,17 +18,19 @@
|
||||||
</div>
|
</div>
|
||||||
</swiper-slide>
|
</swiper-slide>
|
||||||
<swiper-slide>
|
<swiper-slide>
|
||||||
<div class="rknalgpo my">
|
<div class="rknalgpo liked">
|
||||||
<MkButton class="new" @click="create()"><i class="ph-plus-bold ph-lg"></i></MkButton>
|
<MkPagination v-slot="{items}" :pagination="likedPagesPagination">
|
||||||
<MkPagination v-slot="{items}" :pagination="myPagesPagination">
|
<MkPagePreview v-for="like in items" :key="like.page.id" class="ckltabjg" :page="like.page"/>
|
||||||
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/>
|
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
</div>
|
</div>
|
||||||
</swiper-slide>
|
</swiper-slide>
|
||||||
<swiper-slide>
|
<swiper-slide>
|
||||||
<div class="rknalgpo">
|
<div class="rknalgpo my">
|
||||||
<MkPagination v-slot="{items}" :pagination="likedPagesPagination">
|
<div class="buttoncontainer">
|
||||||
<MkPagePreview v-for="like in items" :key="like.page.id" class="ckltabjg" :page="like.page"/>
|
<MkButton class="new primary" @click="create()"><i class="ph-plus-bold ph-lg"></i> {{ i18n.ts._pages.newPage }}</MkButton>
|
||||||
|
</div>
|
||||||
|
<MkPagination v-slot="{items}" :pagination="myPagesPagination">
|
||||||
|
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/>
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
</div>
|
</div>
|
||||||
</swiper-slide>
|
</swiper-slide>
|
||||||
|
@ -55,20 +57,20 @@ import 'swiper/scss/virtual';
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
let tab = $ref('featured');
|
let tab = $ref('featured');
|
||||||
const tabs = ['featured', 'my', 'liked'];
|
const tabs = ['featured', 'liked', 'my'];
|
||||||
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
||||||
|
|
||||||
const featuredPagesPagination = {
|
const featuredPagesPagination = {
|
||||||
endpoint: 'pages/featured' as const,
|
endpoint: 'pages/featured' as const,
|
||||||
noPaging: true,
|
limit: 10,
|
||||||
};
|
|
||||||
const myPagesPagination = {
|
|
||||||
endpoint: 'i/pages' as const,
|
|
||||||
limit: 5,
|
|
||||||
};
|
};
|
||||||
const likedPagesPagination = {
|
const likedPagesPagination = {
|
||||||
endpoint: 'i/page-likes' as const,
|
endpoint: 'i/page-likes' as const,
|
||||||
limit: 5,
|
limit: 10,
|
||||||
|
};
|
||||||
|
const myPagesPagination = {
|
||||||
|
endpoint: 'i/pages' as const,
|
||||||
|
limit: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
|
@ -85,19 +87,19 @@ const headerTabs = $computed(() => [{
|
||||||
key: 'featured',
|
key: 'featured',
|
||||||
title: i18n.ts._pages.featured,
|
title: i18n.ts._pages.featured,
|
||||||
icon: 'ph-fire-simple-bold ph-lg',
|
icon: 'ph-fire-simple-bold ph-lg',
|
||||||
}, {
|
|
||||||
key: 'my',
|
|
||||||
title: i18n.ts._pages.my,
|
|
||||||
icon: 'ph-crown-simple-bold ph-lg',
|
|
||||||
}, {
|
}, {
|
||||||
key: 'liked',
|
key: 'liked',
|
||||||
title: i18n.ts._pages.liked,
|
title: i18n.ts._pages.liked,
|
||||||
icon: 'ph-heart-bold ph-lg',
|
icon: 'ph-heart-bold ph-lg',
|
||||||
|
}, {
|
||||||
|
key: 'my',
|
||||||
|
title: i18n.ts._pages.my,
|
||||||
|
icon: 'ph-crown-simple-bold ph-lg',
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
definePageMetadata(computed(() => ({
|
definePageMetadata(computed(() => ({
|
||||||
title: i18n.ts.pages,
|
title: i18n.ts.pages,
|
||||||
icon: 'ph-sticker-bold ph-lg',
|
icon: 'ph-file-text-bold ph-lg',
|
||||||
})));
|
})));
|
||||||
|
|
||||||
let swiperRef = null;
|
let swiperRef = null;
|
||||||
|
@ -122,6 +124,13 @@ onMounted(() => {
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.rknalgpo {
|
.rknalgpo {
|
||||||
|
|
||||||
|
> .buttoncontainer {
|
||||||
|
display: grid;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
&.my .ckltabjg:first-child {
|
&.my .ckltabjg:first-child {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue