Browse Source

初始化项目

master
liangchan 6 months ago
commit
988a6b2c2e
  1. 772
      index.html
  2. BIN
      parking/.DS_Store
  3. BIN
      parking/image/.DS_Store
  4. BIN
      parking/image/01.gif
  5. BIN
      parking/image/1.png
  6. BIN
      parking/image/10.jpg
  7. BIN
      parking/image/11.jpg
  8. BIN
      parking/image/12.png
  9. BIN
      parking/image/13.png
  10. BIN
      parking/image/1322.png
  11. BIN
      parking/image/14.png
  12. BIN
      parking/image/15.png
  13. BIN
      parking/image/16.png
  14. BIN
      parking/image/17.png
  15. BIN
      parking/image/2.png
  16. BIN
      parking/image/20.png
  17. BIN
      parking/image/200.png
  18. BIN
      parking/image/201.png
  19. BIN
      parking/image/21.png
  20. BIN
      parking/image/22.png
  21. BIN
      parking/image/3.png
  22. BIN
      parking/image/3211.png
  23. BIN
      parking/image/3441.png
  24. BIN
      parking/image/4.png
  25. BIN
      parking/image/4411.gif
  26. BIN
      parking/image/5.png
  27. BIN
      parking/image/6.png
  28. BIN
      parking/image/6121.png
  29. BIN
      parking/image/6122.png
  30. BIN
      parking/image/6123.png
  31. BIN
      parking/image/6124.png
  32. BIN
      parking/image/6125.png
  33. BIN
      parking/image/6126.png
  34. BIN
      parking/image/6211.jpg
  35. BIN
      parking/image/6212.jpg
  36. BIN
      parking/image/6213.png
  37. BIN
      parking/image/6214.png
  38. BIN
      parking/image/6311.jpg
  39. BIN
      parking/image/7.png
  40. BIN
      parking/image/7211.png
  41. BIN
      parking/image/7212.png
  42. BIN
      parking/image/7213.png
  43. BIN
      parking/image/7221.png
  44. BIN
      parking/image/7222.png
  45. BIN
      parking/image/7223.png
  46. BIN
      parking/image/7311.png
  47. BIN
      parking/image/7312.png
  48. BIN
      parking/image/7313.png
  49. BIN
      parking/image/7411.png
  50. BIN
      parking/image/7421.png
  51. BIN
      parking/image/8.png
  52. BIN
      parking/image/821.png
  53. BIN
      parking/image/822.png
  54. BIN
      parking/image/9.png
  55. BIN
      parking/image/9221.png
  56. BIN
      parking/image/9222.png
  57. BIN
      parking/image/9231.png
  58. BIN
      parking/image/9232.png
  59. BIN
      parking/image/img.png
  60. BIN
      parking/image/img_1.png
  61. BIN
      parking/image/img_2.png
  62. BIN
      parking/image/img_3.png
  63. BIN
      parking/image/img_4.png
  64. 2543
      parking/智慧停车实施文档.md
  65. 90
      serve.py

772
index.html

@ -0,0 +1,772 @@ @@ -0,0 +1,772 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>文档管理系统</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background: #f8fafc;
color: #1e293b;
line-height: 1.6;
padding: 24px;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
.container {
max-width: 1200px;
margin: 0 auto;
background: #ffffff;
border-radius: 16px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
padding: 32px 40px 48px;
position: relative;
}
.breadcrumb {
font-size: 14px;
color: #64748b;
margin-bottom: 24px;
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.breadcrumb a { color: #2563eb; }
.breadcrumb .sep { color: #94a3b8; }
.doc-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
margin-top: 12px;
}
.doc-card {
background: #f1f5f9;
border-radius: 12px;
padding: 20px 24px;
border: 1px solid #e2e8f0;
transition: background 0.2s, transform 0.1s;
display: block;
text-decoration: none;
color: inherit;
}
.doc-card:hover {
background: #e6edf6;
transform: translateY(-2px);
border-color: #bfdbfe;
}
.doc-card .name {
font-size: 18px;
font-weight: 600;
color: #0f172a;
display: flex;
align-items: center;
gap: 8px;
}
.doc-card .desc {
font-size: 14px;
color: #475569;
margin-top: 4px;
}
.doc-card .meta {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 10px;
font-size: 13px;
color: #64748b;
}
.doc-card .meta span {
background: #ffffffcc;
padding: 2px 12px;
border-radius: 20px;
border: 1px solid #d1d5db;
}
.badge {
display: inline-block;
font-size: 12px;
background: #dbeafe;
color: #1d4ed8;
padding: 2px 12px;
border-radius: 20px;
font-weight: 500;
}
/* ----- 搜索框 ----- */
.search-box {
margin: 16px 0 24px;
width: 100%;
max-width: 400px;
padding: 10px 16px;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 16px;
outline: none;
transition: border-color 0.2s;
}
.search-box:focus {
border-color: #3b82f6;
}
.search-box::placeholder {
color: #94a3b8;
}
.search-results-count {
font-size: 14px;
color: #64748b;
margin-left: 8px;
}
/* ----- 文档阅读页:左侧目录 + 右侧正文布局 ----- */
.doc-layout {
display: flex;
gap: 30px;
margin-top: 8px;
}
.doc-sidebar {
flex: 0 0 240px;
position: sticky;
top: 24px;
max-height: calc(100vh - 80px);
overflow-y: auto;
padding-right: 12px;
border-right: 1px solid #e2e8f0;
display: none; /* 默认隐藏,在宽屏显示 */
}
.doc-sidebar h4 {
font-size: 14px;
color: #475569;
margin-bottom: 12px;
font-weight: 600;
}
.doc-sidebar ul {
list-style: none;
padding-left: 0;
}
.doc-sidebar li {
margin: 4px 0;
}
.doc-sidebar a {
display: block;
font-size: 13px;
color: #475569;
padding: 4px 8px;
border-radius: 4px;
transition: background 0.2s, color 0.2s;
text-decoration: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.doc-sidebar a:hover {
background: #eef2f6;
color: #1e293b;
}
.doc-sidebar a.active {
color: #2563eb;
background: #dbeafe;
}
.doc-sidebar .level-2 { padding-left: 16px; font-size: 12px; }
.doc-sidebar .level-3 { padding-left: 32px; font-size: 12px; color: #94a3b8; }
.doc-main {
flex: 1;
min-width: 0; /* 防止 Flex 溢出 */
}
@media (min-width: 1024px) {
.doc-sidebar { display: block; }
}
@media (max-width: 1024px) {
.doc-layout { flex-direction: column; }
.doc-sidebar {
position: static;
max-height: none;
border-right: none;
border-bottom: 1px solid #e2e8f0;
margin-bottom: 16px;
padding-bottom: 12px;
display: block; /* 在窄屏依然显示,但改为水平排列 */
}
.doc-sidebar ul {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.doc-sidebar li { margin: 0; }
.doc-sidebar a { white-space: nowrap; }
.doc-sidebar .level-2, .doc-sidebar .level-3 { padding-left: 0; }
}
.markdown-body {
font-size: 16px;
color: #1e293b;
}
.markdown-body h1 {
font-size: 28px;
font-weight: 700;
margin: 0 0 12px 0;
padding-bottom: 8px;
border-bottom: 2px solid #e2e8f0;
}
.markdown-body h2 {
font-size: 22px;
font-weight: 600;
margin: 28px 0 12px 0;
}
.markdown-body h3 {
font-size: 18px;
font-weight: 600;
margin: 20px 0 10px 0;
}
.markdown-body p { margin: 12px 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0 8px 24px; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote {
border-left: 4px solid #3b82f6;
padding: 8px 16px;
background: #f1f5f9;
margin: 16px 0;
border-radius: 0 8px 8px 0;
}
.markdown-body code {
background: #f1f5f9;
padding: 2px 8px;
border-radius: 4px;
font-size: 14px;
}
.markdown-body pre {
background: #1e293b;
color: #e2e8f0;
padding: 16px;
border-radius: 10px;
overflow-x: auto;
margin: 16px 0;
}
.markdown-body pre code {
background: transparent;
padding: 0;
color: inherit;
}
.markdown-body img {
max-width: 100%;
height: auto;
border-radius: 10px;
margin: 16px 0;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
display: block;
}
.markdown-body table {
width: 100%;
border-collapse: collapse;
margin: 16px 0;
font-size: 14px;
}
.markdown-body th, .markdown-body td {
border: 1px solid #e2e8f0;
padding: 8px 12px;
text-align: left;
}
.markdown-body th { background: #f1f5f9; font-weight: 600; }
.loading { text-align: center; padding: 60px 0; color: #64748b; }
.error { text-align: center; padding: 40px 0; color: #ef4444; }
.text-muted { color: #64748b; font-size: 14px; }
/* ----- 回到顶部按钮 ----- */
.back-to-top {
position: fixed;
bottom: 30px;
right: 30px;
width: 44px;
height: 44px;
background: #2563eb;
color: #ffffff;
border: none;
border-radius: 50%;
font-size: 20px;
cursor: pointer;
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
transition: opacity 0.3s, transform 0.2s;
opacity: 0;
visibility: hidden;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
text-decoration: none;
}
.back-to-top.show {
opacity: 1;
visibility: visible;
}
.back-to-top:hover {
transform: translateY(-2px);
background: #1d4ed8;
}
@media (max-width: 640px) {
.back-to-top {
bottom: 20px;
right: 20px;
width: 40px;
height: 40px;
font-size: 18px;
}
}
/* ----- 搜索结果高亮 ----- */
.highlight { background-color: #fef08a; padding: 0 2px; }
</style>
</head>
<body>
<div class="container" id="app">
<div class="loading">⏳ 加载中...</div>
</div>
<!-- 回到顶部按钮(HTML结构直接放在 body 内) -->
<a href="#" class="back-to-top" id="backToTopBtn" title="回到顶部">↑</a>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js">
</script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js">
</script>
<script>
// ============================================================
// 1. Mermaid 初始化(深色主题美化版)
// ============================================================
mermaid.initialize({
startOnLoad: false,
theme: 'base',
flowchart: {
useMaxWidth: true,
curve: 'basis',
padding: 20,
htmlLabels: true
},
themeVariables: {
// ---------- 全局背景 ----------
'background': '#1e293b', // 整体背景(深灰蓝,接近您截图)
// ---------- 流程图样式 ----------
'lineColor': '#93c5fd', // 线条颜色(亮蓝色,清晰)
'lineWidth': '2px',
'edgeLabelBackground': '#1e293b', // 连线标签背景(与背景同色,挡住线)
'nodeBorder': '#93c5fd', // 节点边框(亮蓝色)
'mainBkg': '#334155', // 节点背景(比整体背景稍亮)
'nodeTextColor': '#f8fafc', // 节点文字(白色)
'tertiaryColor': '#475569', // 次要颜色(子图背景等)
// ---------- 时序图样式 ----------
'actorBkg': '#1e293b', // 参与者背景(与整体背景一致)
'actorBorder': '#93c5fd', // 参与者边框(亮蓝色)
'actorTextColor': '#f8fafc', // 参与者文字(白色)
'actorLineColor': '#94a3b8', // 参与者竖线(浅灰)
'signalColor': '#93c5fd', // 消息线颜色(亮蓝色)
'signalTextColor': '#f8fafc', // 消息文字颜色(白色)
'loopTextColor': '#f8fafc', // 循环/备注文字
'loopBorder': '#64748b', // 循环边框
'loopLineColor': '#64748b', // 循环线颜色
'noteBkgColor': '#334155', // 备注背景(与节点背景一致)
'noteBorderColor': '#64748b', // 备注边框
'noteTextColor': '#f8fafc' // 备注文字
}
});
// ============================================================
// 2. 全局变量 & 工具函数
// ============================================================
const app = document.getElementById('app');
const backToTopBtn = document.getElementById('backToTopBtn');
function getPath() { return window.location.pathname; }
function getDocNameFromPath(path) {
const match = path.match(/^\/view\/(.+)$/);
return match ? match[1] : null;
}
function viewLink(filename) { return '/view/' + encodeURIComponent(filename); }
// 滚动回到顶部按钮逻辑
function handleScroll() {
if (window.scrollY > 300) {
backToTopBtn.classList.add('show');
} else {
backToTopBtn.classList.remove('show');
}
}
window.addEventListener('scroll', handleScroll);
backToTopBtn.addEventListener('click', function(e) {
e.preventDefault();
window.scrollTo({ top: 0, behavior: 'smooth' });
});
// ============================================================
// 3. API 调用
// ============================================================
async function fetchDocList() {
const res = await fetch('/api/list');
if (!res.ok) throw new Error('获取文档列表失败 (状态码: ' + res.status + ')');
return res.json();
}
async function fetchDocContent(filename) {
if (!filename || filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
throw new Error('文件名不合法');
}
const res = await fetch('/api/read/' + encodeURIComponent(filename));
if (!res.ok) {
let errorDetail = '';
try {
errorDetail = await res.text();
} catch (e) {}
throw new Error(`读取文档失败 (状态码: ${res.status}) ${errorDetail}`);
}
return res.text();
}
// ============================================================
// 4. 渲染函数
// ============================================================
// 4.1 首页(带搜索框)
function renderHome(docs) {
// 按模块分组
const grouped = {};
docs.forEach(doc => {
const module = doc.module || '通用文档';
if (!grouped[module]) {
grouped[module] = [];
}
grouped[module].push(doc);
});
// 自定义模块顺序(可在此调整)
const customOrder = ['智慧车行', '智慧人行', '智慧安防'];
let html = `
<div class="breadcrumb"><span>🏠 文档中心</span></div>
<h1 style="font-size:26px; font-weight:700; margin-bottom:4px;">📚 服务实施文档</h1>
<p class="text-muted" style="margin-bottom:8px;">点击文档查看详细内容 · 支持图片 &amp; GIF</p>
<!-- 搜索框 -->
<input type="text" id="docSearchInput" class="search-box" placeholder="🔍 搜索文档名称或模块..." />
<span id="searchResultsCount" class="search-results-count"></span>
<div id="docListContainer">
`;
if (Object.keys(grouped).length === 0) {
html += `<p style="text-align:center; color:#94a3b8; padding:40px 0;">📭 未找到 .md 文档</p>`;
}
// 先渲染自定义顺序的模块
for (const moduleName of customOrder) {
if (grouped[moduleName]) {
const files = grouped[moduleName];
html += renderModule(moduleName, files);
delete grouped[moduleName];
}
}
// 剩下的模块按字母顺序渲染
const remainingModules = Object.keys(grouped).sort();
for (const moduleName of remainingModules) {
const files = grouped[moduleName];
html += renderModule(moduleName, files);
}
html += `
</div>
<hr style="margin:32px 0 16px;" />
<div class="text-muted" style="font-size:13px;">
⚡ 图片引用格式:<code>![alt](image/文件名.gif)</code> &nbsp;·&nbsp; 建议将图片放在对应模块的 <code>image/</code> 目录下
</div>
`;
app.innerHTML = html;
// 绑定搜索事件(使用事件委托)
const searchInput = document.getElementById('docSearchInput');
if (searchInput) {
searchInput.addEventListener('input', function(e) {
const keyword = e.target.value.trim().toLowerCase();
filterDocuments(keyword);
});
}
// 初始显示搜索结果数量
updateSearchCount();
}
// 渲染单个模块
function renderModule(moduleName, files) {
let html = `
<div class="module-group" data-module="${moduleName}">
<h2 style="font-size:20px; font-weight:600; margin-top:16px; margin-bottom:12px; padding:8px 0; border-bottom:2px solid #e2e8f0;">
📁 ${moduleName}
</h2>
<div class="doc-grid">
`;
files.forEach(doc => {
let serviceName = doc.name || doc.filename.replace('.md', '').replace('实施文档', '').trim() || '文档';
html += `
<a href="${viewLink(doc.filename)}" class="doc-card" data-search="${serviceName} ${moduleName} ${doc.filename}">
<div class="name"><span>📄</span> ${serviceName}</div>
<div class="desc">${doc.filename}</div>
<div class="meta"><span>📁 ${moduleName}</span><span class="badge">.md</span></div>
</a>
`;
});
html += `</div></div>`;
return html;
}
// 搜索过滤函数
function filterDocuments(keyword) {
const cards = document.querySelectorAll('.doc-card');
const modules = document.querySelectorAll('.module-group');
let visibleCount = 0;
cards.forEach(card => {
const searchText = card.getAttribute('data-search').toLowerCase();
const match = searchText.includes(keyword);
card.style.display = match ? 'block' : 'none';
if (match) visibleCount++;
});
// 隐藏空模块
modules.forEach(module => {
const visibleCards = module.querySelectorAll('.doc-card[style*="display: block"]');
const allCards = module.querySelectorAll('.doc-card');
if (visibleCards.length === 0) {
module.style.display = 'none';
} else {
module.style.display = 'block';
}
});
updateSearchCount(visibleCount);
}
function updateSearchCount(count) {
const countEl = document.getElementById('searchResultsCount');
if (!countEl) return;
const totalCards = document.querySelectorAll('.doc-card').length;
if (count === undefined) {
count = totalCards;
}
countEl.textContent = count === totalCards ? '' : `显示 ${count} / ${totalCards} 个文档`;
}
// 4.2 文档阅读页(带侧边栏目录)
function renderDocView(filename, content) {
// 解码文件名
let decodedFilename = filename;
try {
decodedFilename = decodeURIComponent(filename);
if (decodedFilename.includes('%')) {
decodedFilename = decodeURIComponent(decodedFilename);
}
} catch (e) {}
// 解析 Markdown
let rawHtml = '';
try {
rawHtml = marked.parse(content);
} catch (e) {
renderError('Markdown解析失败: ' + e.message);
return;
}
// 处理 DOM(图片路径 + 标题锚点)
const parser = new DOMParser();
const doc = parser.parseFromString(rawHtml, 'text/html');
const images = doc.querySelectorAll('img');
const docDir = decodedFilename.includes('/') ? decodedFilename.substring(0, decodedFilename.lastIndexOf('/') + 1) : '';
images.forEach(img => {
let src = img.getAttribute('src');
if (src && src.startsWith('image/')) {
img.setAttribute('src', '/' + docDir + src);
}
});
const headings = doc.querySelectorAll('h1, h2, h3, h4, h5, h6');
headings.forEach(h => {
const rawText = h.textContent.trim();
if (rawText) {
const slug = rawText.toLowerCase()
.replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-')
.replace(/^-+|-+$/g, '');
h.id = slug;
}
});
const htmlContent = doc.body.innerHTML;
// 提取服务名
let serviceName = decodedFilename
.replace(/\.md$/i, '')
.replace(/实施文档$/i, '')
.replace(/模块实施文档$/i, '')
.replace(/模块文档$/i, '')
.replace(/文档$/i, '')
.trim();
if (!serviceName) serviceName = '文档';
// 构建侧边栏目录(扫描已生成的 HTML 中的标题)
// 我们先把 HTML 插进去,再扫描,这样更可靠
const breadcrumb = `
<div class="breadcrumb">
<a href="/">🏠 首页</a>
<span class="sep">›</span>
<span style="font-weight:500;">${serviceName}</span>
</div>
`;
const footer = `
<div style="margin-top:32px; border-top:1px solid #e2e8f0; padding-top:16px; font-size:13px; color:#94a3b8;">
📄 文档:${decodedFilename} &nbsp;·&nbsp; 图片目录:<code>/${docDir}image/</code>
<br /><a href="/" style="display:inline-block; margin-top:6px;">← 返回文档列表</a>
</div>
`;
// 使用 doc-layout 布局
app.innerHTML = `
${breadcrumb}
<div class="doc-layout">
<div class="doc-sidebar" id="tocSidebar">
<h4>📖 目录</h4>
<ul id="tocList"></ul>
</div>
<div class="doc-main">
<div class="markdown-body">${htmlContent}</div>
${footer}
</div>
</div>
`;
// 生成目录
const tocList = document.getElementById('tocList');
if (tocList) {
const mainBody = document.querySelector('.doc-main .markdown-body');
if (mainBody) {
const headingsInBody = mainBody.querySelectorAll('h1, h2, h3');
let tocHtml = '';
headingsInBody.forEach(h => {
const level = parseInt(h.tagName[1]);
const text = h.textContent.trim();
const id = h.id;
if (id) {
const className = `level-${level}`;
tocHtml += `<li><a href="#${id}" class="${className}">${text}</a></li>`;
}
});
tocList.innerHTML = tocHtml;
// 点击目录链接时平滑滚动,并高亮当前项
tocList.querySelectorAll('a').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetEl = document.getElementById(targetId);
if (targetEl) {
targetEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
// 高亮当前目录项
tocList.querySelectorAll('a').forEach(a => a.classList.remove('active'));
this.classList.add('active');
}
});
});
}
}
// 渲染 Mermaid
if (typeof mermaid !== 'undefined') {
try {
const mermaidBlocks = document.querySelectorAll('.markdown-body pre code.language-mermaid, .markdown-body pre code.mermaid');
if (mermaidBlocks.length > 0) {
mermaid.run({ nodes: mermaidBlocks });
}
} catch (e) {
console.warn('Mermaid 渲染失败:', e);
}
}
// 滚动监听:高亮当前可见的目录项(可选增强)
const tocLinks = document.querySelectorAll('#tocList a');
if (tocLinks.length > 0) {
const headings = document.querySelectorAll('.doc-main .markdown-body h1, .doc-main .markdown-body h2, .doc-main .markdown-body h3');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const id = entry.target.id;
const link = document.querySelector(`#tocList a[href="#${id}"]`);
if (link) {
tocLinks.forEach(l => l.classList.remove('active'));
link.classList.add('active');
}
}
});
}, { rootMargin: '0px 0px -40% 0px' });
headings.forEach(h => observer.observe(h));
}
}
function renderError(msg) {
app.innerHTML = `
<div class="breadcrumb"><a href="/">🏠 首页</a></div>
<div class="error">
<p style="font-size:48px; margin-bottom:8px;">⚠️</p>
<h2 style="color:#ef4444;">${msg}</h2>
<p class="text-muted" style="margin-top:12px;"><a href="/">返回首页</a></p>
</div>
`;
}
// ============================================================
// 5. 路由
// ============================================================
async function router() {
const path = getPath();
if (path === '/' || path === '/index.html' || path === '') {
try {
const docs = await fetchDocList();
renderHome(docs);
} catch (err) {
renderError('无法加载文档列表: ' + err.message);
}
return;
}
if (path.startsWith('/view/')) {
const filename = getDocNameFromPath(path);
if (!filename) { renderError('无效的文档路径'); return; }
try {
const content = await fetchDocContent(filename);
renderDocView(filename, content);
} catch (err) {
renderError('无法加载文档: ' + err.message);
}
return;
}
renderError('页面未找到: ' + path);
}
// ============================================================
// 6. 启动
// ============================================================
window.addEventListener('popstate', router);
window.addEventListener('DOMContentLoaded', router);
document.addEventListener('click', function(e) {
const link = e.target.closest('a');
if (!link) return;
const href = link.getAttribute('href');
if (!href) return;
if (href.startsWith('/') && !href.startsWith('//') && !href.startsWith('/image/')) {
e.preventDefault();
if (window.location.pathname !== href) {
window.history.pushState({}, '', href);
router();
}
}
});
</script>
</body>
</html>

BIN
parking/.DS_Store vendored

Binary file not shown.

BIN
parking/image/.DS_Store vendored

Binary file not shown.

BIN
parking/image/01.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 MiB

BIN
parking/image/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

BIN
parking/image/10.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

BIN
parking/image/11.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

BIN
parking/image/12.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
parking/image/13.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
parking/image/1322.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

BIN
parking/image/14.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
parking/image/15.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

BIN
parking/image/16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
parking/image/17.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
parking/image/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
parking/image/20.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
parking/image/200.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
parking/image/201.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
parking/image/21.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
parking/image/22.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
parking/image/3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

BIN
parking/image/3211.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
parking/image/3441.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
parking/image/4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
parking/image/4411.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

BIN
parking/image/5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
parking/image/6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
parking/image/6121.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
parking/image/6122.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
parking/image/6123.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
parking/image/6124.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

BIN
parking/image/6125.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

BIN
parking/image/6126.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
parking/image/6211.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

BIN
parking/image/6212.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

BIN
parking/image/6213.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
parking/image/6214.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
parking/image/6311.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

BIN
parking/image/7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
parking/image/7211.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
parking/image/7212.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
parking/image/7213.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
parking/image/7221.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
parking/image/7222.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
parking/image/7223.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

BIN
parking/image/7311.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

BIN
parking/image/7312.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 KiB

BIN
parking/image/7313.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

BIN
parking/image/7411.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
parking/image/7421.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
parking/image/8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
parking/image/821.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

BIN
parking/image/822.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
parking/image/9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
parking/image/9221.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

BIN
parking/image/9222.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

BIN
parking/image/9231.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

BIN
parking/image/9232.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
parking/image/img.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
parking/image/img_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
parking/image/img_2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

BIN
parking/image/img_3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
parking/image/img_4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

2543
parking/智慧停车实施文档.md

File diff suppressed because it is too large Load Diff

90
serve.py

@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
#!/usr/bin/env python3
import os
import json
import urllib.parse
from http.server import HTTPServer, SimpleHTTPRequestHandler
PORT = 8000
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
class DocHandler(SimpleHTTPRequestHandler):
def do_GET(self):
parsed = urllib.parse.urlparse(self.path)
path = parsed.path
# ---------- 1. API 接口 ----------
if path == '/api/list':
self.send_response(200)
self.send_header('Content-Type', 'application/json; charset=utf-8')
self.end_headers()
modules = []
for root, dirs, files in os.walk(BASE_DIR):
dirs[:] = [d for d in dirs if not d.startswith('.') and d not in ['__pycache__']]
for f in files:
if f.endswith('.md') and not f.startswith('.'):
rel_path = os.path.relpath(os.path.join(root, f), BASE_DIR)
module_name = '通用文档' if root == BASE_DIR else os.path.basename(root)
modules.append({
'filename': rel_path,
'name': f.replace('.md', '').replace('实施文档', '').strip() or f.replace('.md', ''),
'module': module_name
})
modules.sort(key=lambda x: (x['module'], x['filename']))
self.wfile.write(json.dumps(modules, ensure_ascii=False).encode('utf-8'))
return
if path.startswith('/api/read/'):
raw_filename = path[10:]
filename = urllib.parse.unquote(urllib.parse.unquote(raw_filename))
if '..' in filename or filename.startswith('/') or filename.startswith('\\'):
self.send_response(403)
self.end_headers()
self.wfile.write(b'Forbidden')
return
filepath = os.path.join(BASE_DIR, filename)
if not os.path.exists(filepath) or not filepath.endswith('.md'):
self.send_response(404)
self.end_headers()
self.wfile.write(f'文件不存在: {filename}'.encode('utf-8'))
return
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
self.send_response(200)
self.send_header('Content-Type', 'text/plain; charset=utf-8')
self.end_headers()
self.wfile.write(content.encode('utf-8'))
except Exception as e:
self.send_response(500)
self.end_headers()
self.wfile.write(f'服务器错误: {str(e)}'.encode('utf-8'))
return
# ---------- 2. 静态文件检查(修复图片无法显示的关键) ----------
# 拼接完整的本地路径
full_path = os.path.join(BASE_DIR, path.lstrip('/'))
# 如果文件真实存在,直接提供文件
if os.path.exists(full_path) and os.path.isfile(full_path):
self.path = path
return super().do_GET()
# ---------- 3. SPA 回退(所有其他请求返回 index.html) ----------
# 这样前端路由可以接管 /view/ 等路径
self.path = '/index.html'
return super().do_GET()
if __name__ == '__main__':
server_address = ('', PORT)
httpd = HTTPServer(server_address, DocHandler)
print(f'🚀 文档管理系统已启动!')
print(f'📂 工作目录: {BASE_DIR}')
print(f'🌐 访问地址: http://localhost:{PORT}')
print(f'📄 按 Ctrl+C 停止服务\n')
try:
httpd.serve_forever()
except KeyboardInterrupt:
print('\n🛑 服务已停止')
httpd.shutdown()
Loading…
Cancel
Save