fix: hide admin buttons when viewing course package via 试看 preview
"试看" (preview) from the storefront should show a read-only view without admin operations (编辑, 删除, 发布上架, 下架). Add preview=1 query param to distinguish preview from direct management navigation. Also limit previewable sections to first one in preview mode, consistent with non-owner experience. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -107,7 +107,7 @@ export default defineComponent({
|
||||
|
||||
const onPreview = (pkg: CoursePackage) => {
|
||||
if (isLoggedIn()) {
|
||||
router.push(`/course/course-package/detail?id=${pkg.id}`);
|
||||
router.push(`/course/course-package/detail?id=${pkg.id}&preview=1`);
|
||||
} else {
|
||||
showDialog({
|
||||
title: '提示',
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer" v-if="isOwner">
|
||||
<div class="footer" v-if="isOwner && !isPreview">
|
||||
<van-button v-if="!isActive" type="primary" @click="onEdit">编辑</van-button>
|
||||
<van-button v-if="!isActive" type="danger" @click="onDelete">删除</van-button>
|
||||
<van-button v-if="!isActive" type="success" @click="onPublish">发布上架</van-button>
|
||||
@@ -87,6 +87,7 @@ export default defineComponent({
|
||||
if (!pkg.value?.created_by || !userStore.current?.hty_id) return false;
|
||||
return pkg.value.created_by === userStore.current.hty_id;
|
||||
});
|
||||
const isPreview = computed(() => route.query.preview === '1');
|
||||
|
||||
const loadData = async () => {
|
||||
const id = route.query.id as string;
|
||||
@@ -173,7 +174,7 @@ export default defineComponent({
|
||||
|
||||
const isPreviewable = (section: CourseSection) => {
|
||||
if (!section.id) return false;
|
||||
if (isOwner.value) return true;
|
||||
if (isOwner.value && !isPreview.value) return true;
|
||||
return section.id === firstSectionId.value;
|
||||
};
|
||||
|
||||
@@ -192,7 +193,7 @@ export default defineComponent({
|
||||
onMounted(loadData);
|
||||
|
||||
return {
|
||||
pkg, courseGroups, loading, isActive, isPublished, isOwner, isLoggedIn,
|
||||
pkg, courseGroups, loading, isActive, isPublished, isOwner, isLoggedIn, isPreview,
|
||||
onEdit, onDelete, onPublish, onUnpublish, previewSection, goBack,
|
||||
isPreviewable, handleSectionClick,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user