Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ declare module 'vue' {
NButtonGroup: typeof import('naive-ui')['NButtonGroup']
NCard: typeof import('naive-ui')['NCard']
NCarousel: typeof import('naive-ui')['NCarousel']
NCode: typeof import('naive-ui')['NCode']
NCollapse: typeof import('naive-ui')['NCollapse']
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
Expand Down
52 changes: 35 additions & 17 deletions src/components/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,54 @@
* @Description: _(:з」∠)_
-->
<script setup lang="ts">
import store from '@/utils/store';
import VerifiedFilled from '@vicons/material/VerifiedFilled';
import { User } from '@/utils/types';
import { PropType } from 'vue';
import store from "@/utils/store";
import VerifiedFilled from "@vicons/material/VerifiedFilled";
import { User } from "@/utils/types";
import { PropType } from "vue";

type AvatarUser = Omit<User, "identity"> & {
identity?: User["identity"] | null;
};

const props = defineProps({
user: {
type: Object as PropType<User>,
required: true
type: Object as PropType<AvatarUser>,
required: true,
},
round: {
type: Boolean,
default: false
default: false,
},
size: {
type: Number,
default: 42
default: 42,
},
preview: {
type: Boolean,
default: false
}
})
default: false,
},
});
</script>

<template>
<div style="font-size:0;position:relative;">
<n-image :width="props.size" :height="props.size" :src="props.user.avatar.low_url" lazy object-fit="fill"
:img-props="{ style: props.round ? 'border-radius:50%;' : 'border-radius:5%;' }" :preview-disabled="!props.preview" />
<n-icon v-if="props.user.identity.color" :component="VerifiedFilled" :size="0.42 * props.size"
:color="props.user.identity.color" style="position:absolute;right:0;bottom:0;" />
<div style="font-size: 0; position: relative">
<n-image
:width="props.size"
:height="props.size"
:src="props.user?.avatar?.low_url ?? ''"
lazy
object-fit="fill"
:img-props="{
style: props.round ? 'border-radius:50%;' : 'border-radius:5%;',
}"
:preview-disabled="!props.preview"
/>
<n-icon
v-if="props.user.identity && props.user.identity.color"
:component="VerifiedFilled"
:size="0.42 * props.size"
:color="props.user.identity.color"
style="position: absolute; right: 0; bottom: 0"
/>
</div>
</template>
</template>
15 changes: 13 additions & 2 deletions src/components/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<script setup lang="ts">
import http from '@/utils/request';
import { h, onMounted, reactive } from 'vue';
import { FormatTime } from '@/utils/tools';
import { FormatTime, GetBlockedUserIds } from '@/utils/tools';
import { onBeforeRouteLeave } from 'vue-router';
import { Comment, CommentList as ICommentList, User } from '@/utils/types';
import RenderLink from './RenderLink.vue';
import ImageViewer from "@/components/ImageViewer/ImageViewer.vue"
import CommentList from './CommentList.vue';
import CommentEdit from './CommentEdit.vue';

import store from '@/utils/store';

const props = defineProps(['obj', 'rate'])

Expand Down Expand Up @@ -61,6 +61,7 @@ function LoadComments(obj: string, cmts: any) {
page: cmts.page,
}
}).then(res => {
FilterComments(res.data);
if (res.data.length == 0) cmts.end = true;
else {
cmts.list = cmts.list.concat(res.data);
Expand All @@ -70,6 +71,16 @@ function LoadComments(obj: string, cmts: any) {
}).catch(() => { cmts.loading = false; })
}

function FilterComments(data: Comment[]) {
for (let i = data.length - 1; i >= 0; i--) {
if (data[i].sub && data[i].sub.length > 0) {
FilterComments(data[i].sub);
}
if ((data[i].user.id && GetBlockedUserIds().includes(data[i].user.id)) || (store.block_policy=="strict" && data[i].reply_user && GetBlockedUserIds().includes(data[i].reply_user.id))) {
data.splice(i, 1);
}
}
}

function OpenSubComments(parent: any) {
sub_comment_list.parent = parent;
Expand Down
14 changes: 13 additions & 1 deletion src/components/Posters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import http from '@/utils/request';
import { PropType, onMounted, reactive, ref, watch } from 'vue';
import { Poster } from '@/utils/types';
import { FormatTime, OpenLink } from '@/utils/tools';
import { FormatTime, OpenLink, GetBlockedUserIds } from '@/utils/tools';
import ErrorOutlined from '@vicons/material/ErrorOutlined'
import Avatar from '@/components/Avatar.vue';
import ImageViewer from '@/components/ImageViewer/ImageViewer.vue';
import store from '@/utils/store';

export interface PostersStatus {
mode: 'recommend' | 'search' | 'follow' | 'hot';
Expand Down Expand Up @@ -52,6 +53,8 @@ function LoadPosters() {
}).then(res => {
// 状态更新后可能之前的请求还没完成 得加上时间戳保证更新的是最新的
if (refresh_time != posters.refresh_time) return;
// 屏蔽用户过滤
FilterPosters(res.data);
if (res.data.length == 0) posters.end = true;
else {
posters.list = posters.list.concat(res.data);
Expand All @@ -61,6 +64,15 @@ function LoadPosters() {
}).catch(() => { posters.loading = false; })
}

function FilterPosters(data: Poster[]) {
for (let i = data.length - 1; i >= 0; i--) {
if (GetBlockedUserIds().includes(data[i].user.id)) {
console.log("已屏蔽用户发布的内容", data[i]);
data.splice(i, 1);
}
}
}

const load_more_observer = ref(null as any);
onMounted(() => {
LoadPosters();
Expand Down
2 changes: 2 additions & 0 deletions src/utils/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const store = reactive({
theme_mode: x.theme_mode || "auto", // auto dark light
grade_query: x.grade_query || {},
last_draft: x.last_draft ?? {},
blocked_users: x.blocked_users || [],
block_policy: x.block_policy || "normal", // normal: 屏蔽画廊、一二级评论、paper strict: normal + 回复该用户的评论
hide_bot: x.hide_bot ?? false,
})

Expand Down
8 changes: 7 additions & 1 deletion src/utils/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import http from "@/utils/request";
import { encryptPassword } from "./EncryptPassword";
import useClipboard from "vue-clipboard3";
import router from "@/router";
import store from "./store";

//一言
const hitokoto = ref("");
Expand Down Expand Up @@ -220,4 +221,9 @@ function GetObjUrl(obj: string) {
return "";
}

export { hitokoto, FormatTime, webvpn, WebvpnVerify, WebvpnVerify2, Clip, GetObjName, GetObjUrl };
// 获取屏蔽用户id列表
function GetBlockedUserIds(): number[] {
return store.blocked_users.map((x) => x.id);
}

export { hitokoto, FormatTime, webvpn, WebvpnVerify, WebvpnVerify2, Clip, GetObjName, GetObjUrl, GetBlockedUserIds };
2 changes: 1 addition & 1 deletion src/views/CourseUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const course = reactive({
msg: ""
})

const is_removed = {};
const is_removed:{ [key: string]: boolean } = {};
function customRequest({
file,
onFinish,
Expand Down
1 change: 1 addition & 0 deletions src/views/Paper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import router from '@/router';
import http from '@/utils/request';
import { FormatTime } from '@/utils/tools';
import { onMounted, reactive } from 'vue';
import store from '@/utils/store';

const papers = reactive({
search: "",
Expand Down
Loading