fix: 编辑保存/取消/返回均回到列表页, 放大编辑框(min-height:60vh)

This commit is contained in:
ylhan
2026-09-21 21:43:46 +08:00
parent 67ada1980c
commit 7e7e7d10e5
+6 -8
View File
@@ -125,7 +125,7 @@ INDEX_HTML = r"""<!DOCTYPE html>
.editor label{display:block;font-weight:600;margin-bottom:6px}
.editor input[type=text]{width:100%;padding:10px 12px;border-radius:10px;border:1px solid var(--border);
background:var(--card);color:var(--text);font-size:15px}
.editor textarea{width:100%;min-height:320px;padding:12px;border-radius:10px;border:1px solid var(--border);
.editor textarea{width:100%;min-height:60vh;padding:12px;border-radius:10px;border:1px solid var(--border);
background:var(--card);color:var(--text);font-size:14px;font-family:ui-monospace,Consolas,monospace;line-height:1.6}
.drop{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px}
.bar-row{display:flex;gap:8px;flex-wrap:wrap}
@@ -167,7 +167,8 @@ function fmt(ts){ if(!ts)return ''; try{return new Date(ts).toLocaleString('zh-C
async function loadPages(){
state.pages = await api('/api/pages');
if(state.mode==='list') renderList();
state.mode='list';
renderList();
}
function renderList(){
$('#topActions').innerHTML = `<button class="primary" onclick="newPage()">+ 新建页面</button>`;
@@ -194,11 +195,8 @@ async function openPage(id){
}catch(e){ toast('打开失败: '+e.message); }
}
let editingId=null;
function newPage(){ editingId=null; state.content=''; startEdit(''); }
function editPage(id){ editingId=id; openPage(id).then(()=>{ state.content=''; startEdit(''); }); }
function startEdit(_){ // placeholder
beginEdit(editingId);
}
function newPage(){ editingId=null; beginEdit(null); }
function editPage(id){ editingId=id; beginEdit(id); }
function beginEdit(id){
(id? api('/api/pages/'+encodeURIComponent(id)):Promise.resolve({title:'',content:''})).then(p=>{
$('#topActions').innerHTML=`<button onclick="cancelEdit()">← 取消</button>
@@ -253,7 +251,7 @@ async function delPage(id){
try{ await api('/api/pages/'+encodeURIComponent(id),{method:'DELETE'}); toast('已删除'); loadPages(); }
catch(e){ toast('删除失败: '+e.message); }
}
function cancelEdit(){ state.mode='view'; loadPages().then(()=>{ /* keep list */ }); }
function cancelEdit(){ loadPages(); }
if(umarked){ document.addEventListener('DOMContentLoaded',()=>toast('Markdown 渲染库加载失败,回退为纯文本')); }
loadPages();