117 lines
4.4 KiB
HTML
117 lines
4.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-TW">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Momentry API Docs</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; }
|
|
#app { display: flex; min-height: 100vh; }
|
|
.sidebar { width: 260px; background: #fff; border-right: 1px solid #ddd; padding: 20px; display: flex; flex-direction: column; }
|
|
.sidebar h1 { font-size: 18px; margin-bottom: 16px; }
|
|
.sidebar a { display: block; padding: 6px 0; color: #0066cc; text-decoration: none; font-size: 14px; cursor: pointer; }
|
|
.sidebar a:hover { color: #003d80; }
|
|
.sidebar .active { font-weight: 600; color: #003d80; }
|
|
.sidebar .logout { margin-top: auto; padding-top: 16px; border-top: 1px solid #eee; }
|
|
.sidebar .logout a { font-size: 12px; color: #999; cursor: pointer; }
|
|
.sidebar .logout a:hover { color: #cc0000; }
|
|
.content { flex: 1; padding: 40px; max-width: 960px; }
|
|
.content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
|
|
.content th, .content td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; }
|
|
.content th { background: #f0f0f0; font-weight: 600; }
|
|
.content code { background: #f0f0f0; padding: 2px 6px; border-radius: 3px; font-size: 13px; }
|
|
.content pre { background: #f8f8f8; border: 1px solid #ddd; border-radius: 6px; padding: 12px; overflow-x: auto; margin: 12px 0; }
|
|
.content pre code { background: none; padding: 0; }
|
|
.content h1 { font-size: 24px; margin: 24px 0 12px; }
|
|
.content h2 { font-size: 20px; margin: 20px 0 10px; color: #222; }
|
|
.content h3 { font-size: 16px; margin: 16px 0 8px; color: #444; }
|
|
.content p { line-height: 1.6; margin: 8px 0; }
|
|
.content a { color: #0066cc; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<script src="/doc-wasm/pkg/md_wasm.js"></script>
|
|
<div id="app">
|
|
<div class="sidebar">
|
|
<h1>Momentry Docs</h1>
|
|
<div id="module-list"></div>
|
|
<div class="logout">
|
|
<a id="logout-btn">Logout</a>
|
|
</div>
|
|
</div>
|
|
<div class="content" id="content">
|
|
<p>Loading WASM...</p>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const MODULES = [
|
|
["01_auth","安全認證","Authentication"],
|
|
["02_health","健康檢查","Health"],
|
|
["03_register","檔案註冊","File Registration"],
|
|
["04_lookup","檔案屬性查詢","File Lookup"],
|
|
["05_process","處理流程","Processing"],
|
|
["06_search","搜尋功能","Search"],
|
|
["07_identity","身份識別","Identity"],
|
|
["08_identity_agent","智能身份綁定","Smart Identity Binding"],
|
|
["08_media","串流與截圖","Streaming & Thumbnails"],
|
|
["09_tmdb","TMDb 整合","TMDb Integration"],
|
|
["10_pipeline","生產線","Pipeline"],
|
|
["12_agent","智慧代理","AI Agents"],
|
|
];
|
|
|
|
const el = document.getElementById('content');
|
|
let wasm = null;
|
|
|
|
async function loadDoc(name) {
|
|
el.innerHTML = '<p>Loading...</p>';
|
|
try {
|
|
const resp = await fetch('/doc-wasm/modules/' + name + '.md');
|
|
if (!resp.ok) throw new Error('HTTP ' + resp.status);
|
|
const md = await resp.text();
|
|
if (!wasm) throw new Error('WASM not initialized');
|
|
el.innerHTML = wasm.render(md);
|
|
document.querySelectorAll('.sidebar a.module-link').forEach(a => a.classList.remove('active'));
|
|
const link = document.querySelector('.sidebar a[data-module="' + name + '"]');
|
|
if (link) link.classList.add('active');
|
|
history.pushState(null, '', '#' + name);
|
|
} catch(e) {
|
|
el.innerHTML = '<p style="color:red">Error: ' + e.message + '</p>';
|
|
}
|
|
}
|
|
|
|
async function init() {
|
|
try {
|
|
el.innerHTML = '<p>Initializing WASM...</p>';
|
|
wasm = await wasm_bindgen();
|
|
el.innerHTML = '<p>Loading modules...</p>';
|
|
const listEl = document.getElementById('module-list');
|
|
MODULES.forEach(function(m) {
|
|
var a = document.createElement('a');
|
|
a.className = 'module-link';
|
|
a.setAttribute('data-module', m[0]);
|
|
a.textContent = m[0] + ' ' + m[1];
|
|
a.onclick = function(e) { e.preventDefault(); loadDoc(m[0]); };
|
|
listEl.appendChild(a);
|
|
});
|
|
document.getElementById('logout-btn').onclick = async function(e) {
|
|
await fetch('/api/v1/auth/logout', {method:'POST'});
|
|
window.location.reload();
|
|
};
|
|
var hash = location.hash.slice(1);
|
|
loadDoc(hash || '01_auth');
|
|
} catch(e) {
|
|
el.innerHTML = '<p style="color:red">Init error: ' + e.message + '</p>';
|
|
}
|
|
}
|
|
|
|
window.onpopstate = function() {
|
|
var hash = location.hash.slice(1);
|
|
if (hash) loadDoc(hash);
|
|
};
|
|
|
|
init();
|
|
</script>
|
|
</body>
|
|
</html>
|