123 lines
4.2 KiB
HTML
123 lines
4.2 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>规则样张</title>
|
|
<style>
|
|
:root {
|
|
--bg: #f2f4f3; --panel: #fff; --line: #d8e2db;
|
|
--text: #1b2a23; --muted: #5b6f63; --accent: #237556; --accent-soft: #eef9f3;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
body {
|
|
margin: 0; height: 100vh; display: flex; flex-direction: column;
|
|
font: 14px/1.5 system-ui, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
color: var(--text); background: var(--bg);
|
|
}
|
|
header {
|
|
display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
|
|
padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
|
|
}
|
|
h1 { font-size: 15px; font-weight: 600; margin: 0; }
|
|
.group { display: flex; gap: 6px; align-items: center; }
|
|
.group-label { font-size: 12px; color: var(--muted); }
|
|
button {
|
|
font: inherit; font-size: 13px; padding: 5px 11px; cursor: pointer;
|
|
color: var(--text); background: #fff;
|
|
border: 1px solid var(--line); border-radius: 8px;
|
|
}
|
|
button:hover { border-color: var(--accent); }
|
|
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
|
|
.spacer { flex: 1; }
|
|
.note { font-size: 12px; color: var(--muted); }
|
|
main { flex: 1; overflow: auto; padding: 20px; }
|
|
.stage {
|
|
margin: 0 auto; background: #fff; overflow: hidden;
|
|
border: 1px solid var(--line); box-shadow: 0 14px 30px rgba(19, 61, 45, .09);
|
|
transform-origin: top left;
|
|
}
|
|
iframe { display: block; border: 0; background: #fff; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>规则样张</h1>
|
|
<div class="group" id="pages"></div>
|
|
<div class="spacer"></div>
|
|
<span class="note">宽度</span>
|
|
<div class="group" id="widths"></div>
|
|
<span class="note">缩放</span>
|
|
<div class="group" id="zooms"></div>
|
|
</header>
|
|
<main><div class="stage" id="stage"><iframe id="frame" title="样张页面"></iframe></div></main>
|
|
<script>
|
|
const pages = [
|
|
{ id: 'w1-list', file: 'w1-list.html', label: '桌面 · 任务列表', w: 1280, h: 820 },
|
|
{ id: 'w2-form', file: 'w2-form.html', label: '桌面 · 新建任务', w: 1280, h: 820 },
|
|
{ id: 'm1-list', file: 'm1-list.html', label: '手机 · 任务列表', w: 390, h: 844 },
|
|
{ id: 'm2-session', file: 'm2-session.html', label: '手机 · 学习会话', w: 390, h: 844 }
|
|
];
|
|
const widths = [360, 390, 768, 1024, 1280];
|
|
const zooms = [1, 1.5];
|
|
|
|
const frame = document.getElementById('frame');
|
|
const stage = document.getElementById('stage');
|
|
|
|
function readHash() {
|
|
const [id, w, z] = location.hash.slice(1).split('/');
|
|
const page = pages.find(p => p.id === id) || pages[0];
|
|
return {
|
|
page,
|
|
w: Number(w) || page.w,
|
|
zoom: Number(z) === 1.5 ? 1.5 : 1
|
|
};
|
|
}
|
|
|
|
let state = readHash();
|
|
|
|
function syncHash() {
|
|
history.replaceState(null, '', '#' + [state.page.id, state.w, state.zoom].join('/'));
|
|
}
|
|
|
|
function makeGroup(host, items, isActive, onPick, label) {
|
|
host.innerHTML = '';
|
|
items.forEach(item => {
|
|
const btn = document.createElement('button');
|
|
btn.type = 'button';
|
|
btn.textContent = label(item);
|
|
btn.setAttribute('aria-pressed', String(isActive(item)));
|
|
btn.addEventListener('click', () => { onPick(item); render(); });
|
|
host.appendChild(btn);
|
|
});
|
|
}
|
|
|
|
function render() {
|
|
const { page, w, zoom } = state;
|
|
|
|
makeGroup(document.getElementById('pages'), pages,
|
|
p => p.id === page.id, p => { state.page = p; state.w = p.w; },
|
|
p => p.label);
|
|
|
|
makeGroup(document.getElementById('widths'), widths,
|
|
v => v === w, v => { state.w = v; }, v => String(v));
|
|
|
|
makeGroup(document.getElementById('zooms'), zooms,
|
|
v => v === zoom, v => { state.zoom = v; }, v => Math.round(v * 100) + '%');
|
|
|
|
const src = page.file;
|
|
if (frame.getAttribute('src') !== src) frame.setAttribute('src', src);
|
|
frame.style.width = w + 'px';
|
|
frame.style.height = page.h + 'px';
|
|
stage.style.width = w * zoom + 'px';
|
|
stage.style.height = page.h * zoom + 'px';
|
|
stage.style.transform = 'scale(' + zoom + ')';
|
|
|
|
syncHash();
|
|
}
|
|
|
|
render();
|
|
</script>
|
|
</body>
|
|
</html>
|