init local code
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { themePreviewUrl } from "@/api/module/cms";
|
||||
import { FormModelValue } from "@/utils/themeParamForm";
|
||||
|
||||
/**
|
||||
* 主题预览框(方案 §5.5/§6.3):iframe 加载 /api/theme/preview(同源 CAS 会话,
|
||||
* no-store),参数变更由父级 debounce 后更新 src。内容源站点不存在时提示。
|
||||
*/
|
||||
const props = defineProps<{
|
||||
/** 预览内容源站点编码(取该站栏目/文章/轮播渲染) */
|
||||
siteCode?: string;
|
||||
theme?: string;
|
||||
themeParams?: FormModelValue;
|
||||
}>();
|
||||
|
||||
const src = computed(() => {
|
||||
if (!props.siteCode || !props.theme) return "";
|
||||
return themePreviewUrl(props.siteCode, props.theme, props.themeParams || {});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="theme-preview">
|
||||
<template v-if="!siteCode || !theme">
|
||||
<div class="preview-empty">
|
||||
无可用内容源站点 —— 预览需要借用一个已有站点的内容
|
||||
<p class="hint">请先创建/启用一个站点(或初始化演示数据)后再预览</p>
|
||||
</div>
|
||||
</template>
|
||||
<iframe
|
||||
v-else
|
||||
:key="src"
|
||||
:src="src"
|
||||
class="preview-frame"
|
||||
title="主题预览"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.theme-preview {
|
||||
width: 100%;
|
||||
background: #f0f2f5;
|
||||
border: 1px solid #e5e6eb;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.preview-frame {
|
||||
width: 100%;
|
||||
height: 560px;
|
||||
border: 0;
|
||||
display: block;
|
||||
}
|
||||
.preview-empty {
|
||||
height: 200px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #888;
|
||||
font-size: 13px;
|
||||
.hint {
|
||||
margin-top: 6px;
|
||||
color: #bbb;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user