feat: 展开运维导航并迁移通知接入文档
- 在顶部导航展示发布、项目接入、成员、设置和文档 - 提供舌吻运营后台返回入口和项目名称编辑
This commit is contained in:
@@ -141,6 +141,7 @@ function accountLabel() {
|
||||
|
||||
<template>
|
||||
<main class="login-page">
|
||||
<a class="text-link system-return" href="https://admin.dev.mrzhan.top/">切回舌吻运营后台</a>
|
||||
<section class="login-panel">
|
||||
<div class="login-copy">
|
||||
<ElIcon><Monitor /></ElIcon>
|
||||
@@ -242,6 +243,7 @@ function accountLabel() {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.system-return { position: absolute; top: 20px; right: 24px; }
|
||||
.login-page {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
|
||||
@@ -0,0 +1,478 @@
|
||||
<script setup lang="ts">
|
||||
/** 消息推送图文教程:共享内容源、截图来源、编号标注和技能下载,保持目录与阅读位置同步。 */
|
||||
import { ElImage } from "element-plus";
|
||||
import {
|
||||
nextTick,
|
||||
onActivated,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
ref,
|
||||
watch
|
||||
} from "vue";
|
||||
|
||||
import guide from "../content/notifications/guide.json";
|
||||
import screenshotSizes from "../content/notifications/screenshots.json";
|
||||
// 为懒加载截图预留真实比例,避免图片出现后章节位置发生跳动。
|
||||
const sizes = screenshotSizes as Record<
|
||||
string,
|
||||
{ width: number; height: number; source: string }
|
||||
>;
|
||||
|
||||
const page = ref<HTMLElement>(),
|
||||
body = ref<HTMLElement>(),
|
||||
toc = ref<HTMLElement>();
|
||||
const captions: Record<string, string[]> = guide.captions;
|
||||
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: string | undefined = 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="/settings?tab=notifications"
|
||||
>打开通知配置 ↗</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">
|
||||
<ElImage
|
||||
: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
|
||||
></ElImage
|
||||
>
|
||||
<figcaption>
|
||||
{{ sizes[image].source }} · 点击放大<span
|
||||
v-if="captions[image].length"
|
||||
>
|
||||
· 编号对应下方操作</span
|
||||
>
|
||||
</figcaption>
|
||||
<ol v-if="captions[image].length" class="guide-callouts">
|
||||
<li v-for="note in 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
|
||||
>
|
||||
|
||||
</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>
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search, Refresh } from '@element-plus/icons-vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { devopsApi } from '../services/devopsApi'
|
||||
import { usePlatformStore } from '../stores/platform'
|
||||
import { useSessionStore } from '../stores/session'
|
||||
import type { ProjectConfig } from '../types/devops'
|
||||
@@ -37,6 +38,29 @@ const hasDiagnostics = computed(() =>
|
||||
function openProject(project: ProjectConfig) {
|
||||
selectedKey.value = project.key
|
||||
}
|
||||
async function renameProject(project: ProjectConfig) {
|
||||
let name: string
|
||||
try {
|
||||
const result = await ElMessageBox.prompt('输入新的项目显示名称', '修改项目名称', {
|
||||
inputValue: project.name,
|
||||
inputValidator: (value) => Boolean(value?.trim()) && value.trim().length <= 100
|
||||
? true
|
||||
: '请输入 1 至 100 个字符',
|
||||
})
|
||||
name = result.value.trim()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const saved = await devopsApi.renameProject(project.key, name)
|
||||
const current = platform.projects.find((item) => item.key === project.key)
|
||||
if (current) current.name = saved.name
|
||||
ElMessage.success('项目名称已保存')
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '保存项目名称失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function diagnose() {
|
||||
diagnosing.value = true
|
||||
diagnosisError.value = ''
|
||||
@@ -137,6 +161,9 @@ async function diagnose() {
|
||||
@close="selectedKey = ''"
|
||||
>
|
||||
<template v-if="selected">
|
||||
<ElButton v-if="session.role === 'super_admin'" @click="renameProject(selected)">
|
||||
修改项目名称
|
||||
</ElButton>
|
||||
<dl class="project-details">
|
||||
<dt>代码仓库</dt>
|
||||
<dd>
|
||||
|
||||
@@ -492,6 +492,7 @@ function resetAuditFilters() {
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>系统配置</h1>
|
||||
<a class="text-link" href="https://admin.dev.mrzhan.top/">切回舌吻运营后台</a>
|
||||
<p>按需查看接入状态、通知投递和操作审计。</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -666,6 +667,7 @@ function resetAuditFilters() {
|
||||
<section v-if="activeTab === 'notifications' && session.role === 'super_admin'" class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>通知 outbox</h2>
|
||||
<RouterLink class="text-link" to="/guides/notifications">通知接入文档</RouterLink>
|
||||
<span
|
||||
>{{ filteredNotificationOutbox.length }} /
|
||||
{{ platform.notificationOutbox.length }} 条</span
|
||||
|
||||
Reference in New Issue
Block a user