feat(guides): 新增通知图文教程与通用 Webhook Skill
- guides: 新增消息推送教程入口、固定目录、截图放大与技能下载 - docs/notifications: 补齐企微接入、业务适配、预览测试与发布验收图文 - skill: 固化跨平台配置体验,增加注册日报和充值通知示例及界面参考图 - scripts: 统一生成教程、原图标注和可重复验证的技能包 - README: 同步目录、入口和维护命令
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/** 接入教程沿用现有后台壳和超级管理员权限,只提供静态说明与安全的技能下载。 */
|
||||
const Layout = () => import("@/layout/index.vue");
|
||||
|
||||
/** 消息推送教程与数字人运营配置分开导航,不在 Admin 中保存运维平台凭据。 */
|
||||
export default {
|
||||
path: "/guides",
|
||||
name: "IntegrationGuides",
|
||||
component: Layout,
|
||||
redirect: "/guides/notifications",
|
||||
meta: { title: "接入文档", icon: "ep/reading", rank: 3 },
|
||||
children: [
|
||||
{
|
||||
path: "/guides/notifications",
|
||||
name: "NotificationIntegrationGuide",
|
||||
component: () => import("@/views/guides/notifications.vue"),
|
||||
meta: { title: "消息推送机器人", permission: "*" }
|
||||
}
|
||||
]
|
||||
} satisfies RouteConfigsTable;
|
||||
@@ -0,0 +1,480 @@
|
||||
<script setup lang="ts">
|
||||
/** 消息推送图文教程:共享内容源、截图来源、编号标注和技能下载,保持目录与阅读位置同步。 */
|
||||
import {
|
||||
nextTick,
|
||||
onActivated,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
ref,
|
||||
watch
|
||||
} from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import guide from "../../../docs/notifications/guide.json";
|
||||
import screenshotSizes from "../../../docs/notifications/screenshots.json";
|
||||
// 为懒加载截图预留真实比例,避免图片出现后章节位置发生跳动。
|
||||
const sizes = screenshotSizes as Record<
|
||||
string,
|
||||
{ width: number; height: number; source: string }
|
||||
>;
|
||||
const router = useRouter();
|
||||
const page = ref<HTMLElement>(),
|
||||
body = ref<HTMLElement>(),
|
||||
toc = ref<HTMLElement>();
|
||||
const activeId = ref(guide.steps[0].id);
|
||||
let frame = 0,
|
||||
observer: ResizeObserver | undefined;
|
||||
/** 正文是唯一阅读滚动容器,懒加载图片改变章节高度后也重新判定位置。 */
|
||||
function updateReadingPosition() {
|
||||
frame = 0;
|
||||
if (!page.value?.offsetWidth || !body.value) return;
|
||||
const available =
|
||||
window.innerHeight - page.value.getBoundingClientRect().top - 24;
|
||||
page.value.style.setProperty(
|
||||
"--guide-height",
|
||||
`${Math.max(360, available)}px`
|
||||
);
|
||||
const sections = Array.from(
|
||||
body.value.querySelectorAll<HTMLElement>(".guide-section")
|
||||
);
|
||||
const top = body.value.getBoundingClientRect().top + 24;
|
||||
let current = sections[0]?.id;
|
||||
for (const section of sections) {
|
||||
if (section.getBoundingClientRect().top <= top) current = section.id;
|
||||
else break;
|
||||
}
|
||||
// 最后一章可能不足一屏;滚到底部时仍须选中它。
|
||||
if (
|
||||
body.value.scrollTop + body.value.clientHeight >=
|
||||
body.value.scrollHeight - 2
|
||||
)
|
||||
current = sections.at(-1)?.id;
|
||||
if (current) activeId.value = current.replace(/^guide-/, "");
|
||||
}
|
||||
function scheduleUpdate() {
|
||||
if (!frame) frame = requestAnimationFrame(updateReadingPosition);
|
||||
}
|
||||
onMounted(() => {
|
||||
window.addEventListener("resize", scheduleUpdate);
|
||||
observer = new ResizeObserver(scheduleUpdate);
|
||||
if (page.value) observer.observe(page.value);
|
||||
if (body.value) {
|
||||
observer.observe(body.value);
|
||||
body.value
|
||||
.querySelectorAll(".guide-section")
|
||||
.forEach(section => observer!.observe(section));
|
||||
}
|
||||
scheduleUpdate();
|
||||
});
|
||||
onActivated(scheduleUpdate);
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("resize", scheduleUpdate);
|
||||
observer?.disconnect();
|
||||
cancelAnimationFrame(frame);
|
||||
});
|
||||
watch(activeId, async id => {
|
||||
await nextTick();
|
||||
const button = toc.value?.querySelector<HTMLElement>(
|
||||
`[data-section="${id}"]`
|
||||
);
|
||||
if (!button || !toc.value) return;
|
||||
const item = button.getBoundingClientRect(),
|
||||
menu = toc.value.getBoundingClientRect();
|
||||
// 仅移动目录内部,避免 scrollIntoView 带动后台外层容器。
|
||||
if (item.top < menu.top || item.bottom > menu.bottom)
|
||||
toc.value.scrollTop +=
|
||||
item.top - menu.top - toc.value.clientHeight / 2 + item.height / 2;
|
||||
});
|
||||
const images = guide.steps.flatMap(step =>
|
||||
(step.images ?? []).map(image => `/guides/notifications/${image}.svg`)
|
||||
);
|
||||
/** 在当前二级页内滚动,不修改hash路由,也不触发任何配置保存或消息投递。 */
|
||||
function jump(id: string) {
|
||||
const section = body.value?.querySelector<HTMLElement>(`#guide-${id}`);
|
||||
if (!section || !body.value) return;
|
||||
body.value.scrollTo({
|
||||
top:
|
||||
body.value.scrollTop +
|
||||
section.getBoundingClientRect().top -
|
||||
body.value.getBoundingClientRect().top,
|
||||
behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
? "instant"
|
||||
: "smooth"
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div ref="page" class="notification-guide">
|
||||
<header class="guide-heading">
|
||||
<div>
|
||||
<el-tag type="info">企微篇 · {{ images.length }} 张操作图</el-tag>
|
||||
<h1>{{ guide.title }}</h1>
|
||||
<p>{{ guide.intro }}</p>
|
||||
</div>
|
||||
<div class="guide-actions">
|
||||
<a
|
||||
class="guide-action"
|
||||
href="https://devops.mrzhan.top/settings?tab=notifications"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>打开通知配置 ↗</a
|
||||
>
|
||||
<a
|
||||
class="guide-action primary"
|
||||
href="/guides/notifications/wecom-notification-integration.zip"
|
||||
download
|
||||
>下载 Codex Skill</a
|
||||
>
|
||||
</div>
|
||||
</header>
|
||||
<el-alert :title="guide.notice" type="info" :closable="false" />
|
||||
<div class="guide-layout">
|
||||
<nav class="guide-toc" aria-label="教程目录">
|
||||
<strong>本页目录</strong>
|
||||
<div ref="toc" class="guide-links">
|
||||
<button
|
||||
v-for="step in guide.steps"
|
||||
:key="step.id"
|
||||
type="button"
|
||||
:data-section="step.id"
|
||||
:class="{ active: activeId === step.id }"
|
||||
:aria-current="activeId === step.id ? 'location' : undefined"
|
||||
@click="jump(step.id)"
|
||||
>
|
||||
{{ step.title }}
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
<article
|
||||
ref="body"
|
||||
class="guide-body"
|
||||
tabindex="0"
|
||||
aria-label="教程正文"
|
||||
@scroll="scheduleUpdate"
|
||||
>
|
||||
<section
|
||||
v-for="step in guide.steps"
|
||||
:id="`guide-${step.id}`"
|
||||
:key="step.id"
|
||||
class="guide-section"
|
||||
>
|
||||
<h2>{{ step.title }}</h2>
|
||||
<p class="guide-lead">{{ step.lead }}</p>
|
||||
<figure v-for="image in step.images ?? []" :key="image">
|
||||
<el-image
|
||||
:src="`/guides/notifications/${image}.svg`"
|
||||
:style="{
|
||||
aspectRatio: `${sizes[image].width} / ${sizes[image].height}`,
|
||||
maxWidth: `${sizes[image].width}px`
|
||||
}"
|
||||
:alt="`${step.title},${sizes[image].source}`"
|
||||
:preview-src-list="images"
|
||||
:initial-index="
|
||||
images.indexOf(`/guides/notifications/${image}.svg`)
|
||||
"
|
||||
preview-teleported
|
||||
lazy
|
||||
fit="contain"
|
||||
><template #error
|
||||
><div class="image-error">
|
||||
教程图片加载失败,请刷新重试。
|
||||
</div></template
|
||||
></el-image
|
||||
>
|
||||
<figcaption>
|
||||
{{ sizes[image].source }} · 点击放大<span
|
||||
v-if="guide.captions[image].length"
|
||||
>
|
||||
· 编号对应下方操作</span
|
||||
>
|
||||
</figcaption>
|
||||
<ol v-if="guide.captions[image].length" class="guide-callouts">
|
||||
<li v-for="note in guide.captions[image]" :key="note">
|
||||
{{ note }}
|
||||
</li>
|
||||
</ol>
|
||||
</figure>
|
||||
<ul>
|
||||
<li v-for="line in step.bullets" :key="line">{{ line }}</li>
|
||||
</ul>
|
||||
<pre v-if="'code' in step"><code>{{ step.code }}</code></pre>
|
||||
</section>
|
||||
<footer class="guide-footer">
|
||||
<h2>官方参考与维护</h2>
|
||||
<ul>
|
||||
<li v-for="reference in guide.references" :key="reference.url">
|
||||
<a :href="reference.url" target="_blank" rel="noopener noreferrer"
|
||||
>{{ reference.label }} ↗</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
教程更新:{{ guide.updated }}。网页与图文 README
|
||||
共用内容源,截图保留来源;配置操作和实际发送在运维平台完成。
|
||||
</p>
|
||||
<div class="guide-actions">
|
||||
<a
|
||||
class="guide-action primary"
|
||||
href="/guides/notifications/wecom-notification-integration.zip"
|
||||
download
|
||||
>下载 Codex Skill</a
|
||||
>
|
||||
<el-button @click="router.push('/digital/experiments/guide')"
|
||||
>实验操作指南</el-button
|
||||
>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.notification-guide {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 1440px;
|
||||
height: var(--guide-height, calc(100dvh - 134px));
|
||||
min-height: 360px;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.guide-heading {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.guide-heading h1 {
|
||||
margin: 12px 0;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.guide-heading p {
|
||||
max-width: 800px;
|
||||
line-height: 1.8;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.guide-layout {
|
||||
display: grid;
|
||||
flex: 1;
|
||||
grid-template-columns: 220px minmax(0, 1fr);
|
||||
gap: 32px;
|
||||
min-height: 0;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.guide-toc {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-height: 0;
|
||||
max-height: 100%;
|
||||
padding: 16px;
|
||||
overflow: hidden;
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.guide-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.guide-toc strong {
|
||||
flex-shrink: 0;
|
||||
padding: 4px 8px 12px;
|
||||
}
|
||||
|
||||
.guide-toc button {
|
||||
padding: 8px;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.guide-toc button.active {
|
||||
font-weight: 600;
|
||||
color: var(--el-color-primary);
|
||||
background: var(--el-color-primary-light-9);
|
||||
box-shadow: inset 3px 0 var(--el-color-primary);
|
||||
}
|
||||
|
||||
.guide-body {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.guide-body:focus-visible {
|
||||
outline: 2px solid var(--el-color-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.guide-toc button:hover {
|
||||
color: var(--el-color-primary);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.guide-toc button:focus-visible {
|
||||
outline: 2px solid var(--el-color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.guide-section {
|
||||
padding: 24px;
|
||||
margin-bottom: 24px;
|
||||
scroll-margin-top: 0;
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.guide-section h2 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 21px;
|
||||
}
|
||||
|
||||
.guide-lead {
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.guide-section figure {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.guide-section .el-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 100px;
|
||||
margin: 0 auto;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.guide-section figcaption {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.guide-section ul {
|
||||
padding-left: 22px;
|
||||
line-height: 1.9;
|
||||
}
|
||||
|
||||
.guide-section li {
|
||||
margin-bottom: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.guide-section pre {
|
||||
padding: 16px;
|
||||
overflow-x: auto;
|
||||
font-size: 12px;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.image-error {
|
||||
padding: 24px;
|
||||
color: var(--el-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.guide-footer {
|
||||
padding: 20px 0 32px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.guide-footer p {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
@media (width <= 900px) {
|
||||
.guide-layout {
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.guide-toc {
|
||||
max-height: 140px;
|
||||
}
|
||||
|
||||
.guide-heading {
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.guide-heading h1 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.guide-heading p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.guide-section {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.guide-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.guide-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 34px;
|
||||
padding: 7px 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--el-color-primary);
|
||||
text-decoration: none;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.guide-action.primary {
|
||||
color: white;
|
||||
background: var(--el-color-primary);
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.guide-action:hover {
|
||||
filter: brightness(0.95);
|
||||
}
|
||||
|
||||
.guide-action:focus-visible {
|
||||
outline: 2px solid var(--el-color-primary);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.guide-footer a:not(.guide-action) {
|
||||
color: var(--el-color-primary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user