feat: 前台新增积分来源明细弹窗与管理员后台入口判定
build / build (push) Successful in 4m11s

- SpaceSide:点击「积分」可查看积分来源明细(发布/评论逐条带分值,分页),
  4 个空间页(ModuleList/RecordDetail/RecordEdit/Timeline)传入 :points-userid
- api:新增 pointsSourceList(/PointsSourceList);ProfessionDetail 改注为纯读
  (阅读数由 VisitCreate 记足迹时 +1)
- layout/App:管理员判定改用 BoaUser.type(1 超管 / 2 学校管理员)或区局账号,
  后台管理入口落地栏目管理 #/module;App.vue 透传 user.type
- ModuleBar/profession-ui:栏目条 auto 外边距只对「更多」项生效(上级栏目组项
  的下拉包装层留在原位排队),项间距 6px→5px
- 页脚备案信息更新为 ©2024-2026 豫ICP
This commit is contained in:
lijing
2026-10-09 09:33:41 +08:00
parent e6decedae4
commit afa9cef808
12 changed files with 467 additions and 36 deletions
+318 -3
View File
@@ -6,6 +6,7 @@
* panel 2 = 本月概览(ov-grid 四色,仅 full 模式)
* panel 3 = 最近访客(visitors 圆字章:默认一排,超过一排显示「查看全部访客」就地展开全部)
* mode:full=栏目列表·个人空间/我的首页完整版;mini=发布编辑、记录详情精简版(无统计行/进度条/本月概览)。
* space-points 可点击 → 弹「积分来源」弹窗(发布/评论逐条带分值,合计口径同 MyPoints)。
*/
const props = withDefaults(
defineProps<{
@@ -29,11 +30,18 @@ const props = withDefaults(
overview?: Record<string, any> | null;
/** full=完整版侧栏;mini=精简版(发布/详情页) */
mode?: "full" | "mini";
/** 积分归属教师 id(他人空间传其 userid;不传 = 当前登录人) */
pointsUserid?: number | null;
}>(),
{ himWord: "我的", teacherName: "", points: 0, avatar: "", modules: () => [], visitors: () => [], visitorRowSize: 7, activeMouid: null, homeCurrent: false, overview: null, mode: "full" }
{ himWord: "我的", teacherName: "", points: 0, avatar: "", modules: () => [], visitors: () => [], visitorRowSize: 7, activeMouid: null, homeCurrent: false, overview: null, mode: "full", pointsUserid: null }
);
import { ref, watch } from "vue";
import { ref, computed, watch } from "vue";
import { useRouter } from "vue-router";
import { Message } from "view-ui-plus";
import { professionApi } from "@/api/module/profession";
const router = useRouter();
const emit = defineEmits<{
(e: "home"): void;
@@ -58,6 +66,59 @@ function pointsWidth(): number {
function firstChar(name?: string): string {
return (name || "?").replace(/\s/g, "").slice(0, 1) || "?";
}
/* ============ 积分来源弹窗(点击 space-points 打开,分页) ============ */
const ptsShow = ref(false);
const ptsLoading = ref(false);
const ptsData = ref<Record<string, any> | null>(null);
const ptsPage = ref(1);
const ptsPageSize = 8;
async function loadPoints() {
ptsLoading.value = true;
try {
ptsData.value =
(await professionApi.pointsSourceList(props.pointsUserid ?? undefined, ptsPage.value, ptsPageSize).send()) ||
{};
} catch (e: any) {
Message.error(e?.message || "获取积分来源失败");
ptsShow.value = false;
} finally {
ptsLoading.value = false;
}
}
/** 每次打开都重置到第一页重拉(积分随发布/评论实时变) */
watch(ptsShow, v => {
if (!v) return;
ptsPage.value = 1;
loadPoints();
});
const ptsRows = computed<any[]>(() => ptsData.value?.rows || []);
const ptsTotal = computed(() => Number(ptsData.value?.total ?? 0));
/** 与 ModuleList 同款页码序列:前 5 页 + 尾页(…) */
const ptsPages = computed(() => {
const tp = Math.max(1, Math.ceil(ptsTotal.value / ptsPageSize));
const arr: number[] = [];
for (let i = 1; i <= Math.min(tp, 5); i++) arr.push(i);
return { arr, tp, hasMore: tp > 5 };
});
function ptsGo(p: number) {
if (p < 1 || p > ptsPages.value.tp || p === ptsPage.value) return;
ptsPage.value = p;
loadPoints();
}
/** 评论内容摘要(去换行,截 40 字) */
function ptsExcerpt(s?: string): string {
const text = String(s || "").replace(/\s+/g, " ").trim();
return text.length > 40 ? text.slice(0, 40) + "…" : text;
}
function goRecord(recordId?: number) {
if (!recordId) return;
ptsShow.value = false;
router.push({ path: "/record/detail", query: { serid: recordId } });
}
</script>
<template>
@@ -68,7 +129,7 @@ function firstChar(name?: string): string {
<img v-if="avatar" class="space-avatar" :src="avatar" alt="" />
<div v-else class="space-avatar">{{ firstChar(teacherName) }}</div>
<div class="space-name">{{ teacherName || "—" }}</div>
<div class="space-points">积分 <b>{{ points || 0 }}</b> 分</div>
<a class="space-points" href="javascript:void(0)" title="查看积分来源" @click.prevent="ptsShow = true">积分 <b>{{ points || 0 }}</b> 分</a>
<a class="space-home-link" :class="{ current: homeCurrent }" href="javascript:void(0)" @click.prevent="emit('home')">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10.5L12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg>
{{ himWord }}首页
@@ -130,6 +191,66 @@ function firstChar(name?: string): string {
@click.prevent="visitorsOpen = !visitorsOpen"
>{{ visitorsOpen ? "收起访客 ▴" : `查看全部访客(${visitors.length})▾` }}</a>
</section>
<!-- ============ 积分来源弹窗(点击 space-points 打开;Teleport 挂 body 避侧栏 overflow 裁剪) ============ -->
<Teleport to="body">
<div v-if="ptsShow" class="pts-overlay" @click.self="ptsShow = false">
<div class="pts-modal">
<div class="pts-hd">
<h3>积分来源</h3>
<span class="pts-total"><b>{{ ptsData?.pointsnum ?? (points || 0) }}</b> 分</span>
<a class="pts-close" href="javascript:void(0)" @click.prevent="ptsShow = false">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>
</a>
</div>
<div class="pts-sub">
<span class="p-item"><i class="dot pub"></i>发布积分 <b>{{ ptsData?.sendPoints ?? 0 }}</b></span>
<span class="p-item"><i class="dot com"></i>评论积分 <b>{{ ptsData?.commPoints ?? 0 }}</b></span>
<span class="p-item hint">积分随发布与互动累积</span>
</div>
<div class="pts-body">
<div v-if="ptsLoading" class="pts-empty">加载中…</div>
<div v-else-if="!ptsRows.length" class="pts-empty">暂无积分来源,发布记录或参与互动即可累积积分</div>
<template v-else>
<div
v-for="r in ptsRows"
:key="r.type + '-' + r.id"
class="pts-row"
:title="'查看记录:' + r.title"
@click="goRecord(r.recordId)"
>
<span class="pts-tag" :class="r.type">{{ r.type === "publish" ? "发布" : "评论" }}</span>
<div class="pts-main">
<div class="pts-title">
{{ r.type === "publish" ? r.title : `评《${r.title}》:${ptsExcerpt(r.contents)}` }}
</div>
<div class="pts-meta">
<span v-if="r.type === 'publish' && r.moduleName" class="mod">{{ r.moduleName }}</span>
<span>{{ r.createTime }}</span>
</div>
</div>
<b class="pts-val">+{{ r.points ?? 0 }}</b>
</div>
</template>
</div>
<!-- 分页(复用全局 .pagination/.pbtn;仅超一页显示) -->
<div v-if="ptsPages.tp > 1" class="pagination pts-pager">
<span>共 {{ ptsTotal }} 条</span>
<span class="pbtn" @click="ptsGo(ptsPage - 1)">‹</span>
<span
v-for="p in ptsPages.arr"
:key="p"
class="pbtn"
:class="{ on: p === ptsPage }"
@click="ptsGo(p)"
>{{ p }}</span>
<span v-if="ptsPages.hasMore" class="pbtn">…</span>
<span v-if="ptsPages.hasMore" class="pbtn" :class="{ on: ptsPage === ptsPages.tp }" @click="ptsGo(ptsPages.tp)">{{ ptsPages.tp }}</span>
<span class="pbtn" @click="ptsGo(ptsPage + 1)">›</span>
</div>
</div>
</div>
</Teleport>
</aside>
</template>
@@ -164,4 +285,198 @@ function firstChar(name?: string): string {
font-size: 12px;
color: var(--muted, #8fa9c4);
}
/* 积分行可点击(查看积分来源):a 元素继承原 div 版式,hover 提亮 + 数字下划线示意可点 */
a.space-points {
display: block;
cursor: pointer;
}
a.space-points:hover {
color: #fff;
}
a.space-points:hover b {
text-decoration: underline;
text-underline-offset: 3px;
}
/* ============ 积分来源弹窗(方案D 规范:极细边线 + 极轻阴影 + 衬线数字) ============ */
.pts-overlay {
position: fixed;
inset: 0;
z-index: 1200;
background: rgba(28, 40, 60, 0.42);
display: grid;
place-items: center;
animation: pts-fade 0.18s var(--ease);
}
@keyframes pts-fade {
from { opacity: 0; }
}
.pts-modal {
width: 520px;
max-width: calc(100vw - 48px);
max-height: 74vh;
display: flex;
flex-direction: column;
background: var(--card);
border-radius: 14px;
box-shadow: 0 18px 50px rgba(16, 40, 80, 0.28);
overflow: hidden;
animation: pts-pop 0.22s var(--ease);
}
@keyframes pts-pop {
from { opacity: 0; transform: translateY(10px) scale(0.98); }
}
.pts-hd {
display: flex;
align-items: center;
gap: 10px;
padding: 16px 18px 12px;
border-bottom: 1px solid var(--line-2);
}
.pts-hd h3 {
font-size: 15px;
font-weight: 700;
color: var(--ink);
padding-left: 9px;
border-left: 3px solid var(--navy);
line-height: 1.2;
}
.pts-total {
margin-left: auto;
font-size: 12px;
color: var(--ink-2);
}
.pts-total b {
font-family: var(--font-d);
font-size: 19px;
color: var(--gold);
margin-right: 2px;
}
.pts-close {
color: var(--muted);
display: grid;
place-items: center;
width: 26px;
height: 26px;
border-radius: 7px;
transition: all 0.15s;
}
.pts-close:hover {
color: var(--navy);
background: var(--sky);
}
.pts-sub {
display: flex;
align-items: center;
gap: 14px;
padding: 10px 18px;
background: var(--bg);
border-bottom: 1px solid var(--line-2);
font-size: 12px;
color: var(--ink-2);
}
.pts-sub .p-item {
display: inline-flex;
align-items: center;
gap: 5px;
}
.pts-sub .p-item b {
font-family: var(--font-d);
font-size: 14px;
color: var(--navy);
}
.pts-sub .p-item.hint {
margin-left: auto;
color: var(--muted);
font-size: 11px;
}
.pts-sub .dot {
width: 7px;
height: 7px;
border-radius: 50%;
}
.pts-sub .dot.pub {
background: var(--navy);
}
.pts-sub .dot.com {
background: #21b8a6;
}
.pts-body {
overflow-y: auto;
padding: 6px 10px 12px;
}
/* 弹窗内分页条(全局 .pagination 的内嵌变体:贴底、细上边线) */
.pts-pager {
border-top: 1px solid var(--line-2);
padding: 10px 16px;
flex: none;
}
.pts-empty {
padding: 34px 16px;
text-align: center;
font-size: 13px;
color: var(--muted);
}
.pts-row {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 10px;
border-radius: 10px;
cursor: pointer;
transition: background 0.15s var(--ease);
}
.pts-row:hover {
background: var(--sky);
}
.pts-row + .pts-row {
margin-top: 2px;
}
.pts-tag {
flex: none;
width: 38px;
text-align: center;
font-size: 11px;
line-height: 20px;
border-radius: 6px;
background: var(--sky);
color: var(--navy-2);
}
.pts-tag.comment {
background: #e6f7f4;
color: #159a89;
}
.pts-main {
flex: 1;
min-width: 0;
}
.pts-title {
font-size: 13px;
color: var(--ink);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.pts-meta {
display: flex;
align-items: center;
gap: 8px;
margin-top: 2px;
font-size: 11px;
color: var(--muted);
}
.pts-meta .mod {
color: var(--navy-2);
background: var(--sky);
border-radius: 4px;
padding: 0 6px;
font-size: 10.5px;
line-height: 17px;
}
.pts-val {
flex: none;
font-family: var(--font-d);
font-size: 15px;
color: var(--gold);
}
</style>