feat: implement tenant-side creator audit feature and update related tests and documentation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,42 +1,61 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import Toast from "primevue/toast";
|
||||
import { useToast } from "primevue/usetoast";
|
||||
import { userApi } from "../../api/user";
|
||||
import { tenantPath } from "../../utils/tenant";
|
||||
|
||||
const toast = useToast();
|
||||
const route = useRoute();
|
||||
const tenantRoute = (path) => tenantPath(path, route);
|
||||
|
||||
const items = ref([
|
||||
{
|
||||
id: 4,
|
||||
title: "《霸王别姬》全本实录珍藏版",
|
||||
cover:
|
||||
"https://images.unsplash.com/photo-1514306191717-452ec28c7f31?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=60",
|
||||
author: "梅派传人小林",
|
||||
authorAvatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=Master1",
|
||||
type: "video",
|
||||
duration: "120:00",
|
||||
time: "昨天点赞",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
title: "京剧打击乐基础教程",
|
||||
cover:
|
||||
"https://images.unsplash.com/photo-1576014131795-d44019d02374?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=60",
|
||||
author: "戏曲学院官方",
|
||||
authorAvatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=School",
|
||||
type: "video",
|
||||
duration: "45:00",
|
||||
time: "3天前点赞",
|
||||
},
|
||||
]);
|
||||
const items = ref([]);
|
||||
const loading = ref(true);
|
||||
|
||||
const removeItem = (id) => {
|
||||
items.value = items.value.filter((i) => i.id !== id);
|
||||
toast.add({ severity: "success", summary: "已取消点赞", life: 2000 });
|
||||
const fetchLikes = async () => {
|
||||
try {
|
||||
const res = await userApi.getLikes();
|
||||
items.value = res || [];
|
||||
} catch (e) {
|
||||
toast.add({
|
||||
severity: "error",
|
||||
summary: "加载失败",
|
||||
detail: e.message,
|
||||
life: 3000,
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(fetchLikes);
|
||||
|
||||
const removeItem = async (id) => {
|
||||
try {
|
||||
await userApi.removeLike(id);
|
||||
items.value = items.value.filter((i) => i.id !== id);
|
||||
toast.add({ severity: "success", summary: "已取消点赞", life: 2000 });
|
||||
} catch (e) {
|
||||
toast.add({
|
||||
severity: "error",
|
||||
summary: "操作失败",
|
||||
detail: e.message,
|
||||
life: 3000,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeIcon = (type) => {
|
||||
if (type === "video") return "pi-play-circle";
|
||||
if (type === "audio") return "pi-volume-up";
|
||||
return "pi-book";
|
||||
};
|
||||
|
||||
const getTypeLabel = (type) => {
|
||||
if (type === "video") return "视频";
|
||||
if (type === "audio") return "音频";
|
||||
return "文章";
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -65,11 +84,8 @@ const removeItem = (id) => {
|
||||
<div
|
||||
class="absolute bottom-2 left-2 px-1.5 py-0.5 bg-black/60 text-white text-xs rounded flex items-center gap-1"
|
||||
>
|
||||
<i
|
||||
class="pi"
|
||||
:class="item.type === 'video' ? 'pi-play-circle' : 'pi-book'"
|
||||
></i>
|
||||
<span>{{ item.duration || "文章" }}</span>
|
||||
<i class="pi" :class="getTypeIcon(item.type)"></i>
|
||||
<span>{{ getTypeLabel(item.type) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -81,13 +97,19 @@ const removeItem = (id) => {
|
||||
{{ item.title }}
|
||||
</h3>
|
||||
<div class="flex items-center gap-2 text-xs text-slate-500 mb-3">
|
||||
<img :src="item.authorAvatar" class="w-5 h-5 rounded-full" />
|
||||
<span>{{ item.author }}</span>
|
||||
<img
|
||||
:src="
|
||||
item.author_avatar ||
|
||||
`https://api.dicebear.com/7.x/avataaars/svg?seed=${item.author_id}`
|
||||
"
|
||||
class="w-5 h-5 rounded-full"
|
||||
/>
|
||||
<span>{{ item.author_name }}</span>
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center justify-between text-xs text-slate-400 border-t border-slate-50 pt-3"
|
||||
>
|
||||
<span>{{ item.time }}</span>
|
||||
<span>{{ item.created_at }}</span>
|
||||
<button
|
||||
@click.stop="removeItem(item.id)"
|
||||
class="hover:text-primary-600 flex items-center gap-1 transition-colors"
|
||||
@@ -100,7 +122,7 @@ const removeItem = (id) => {
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-if="items.length === 0" class="text-center py-20">
|
||||
<div v-if="!loading && items.length === 0" class="text-center py-20">
|
||||
<div
|
||||
class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-slate-50 mb-4"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user