ui: center canvas and refine project layout
Verify and deploy production / verify-and-deploy (push) Successful in 2m50s

This commit is contained in:
2026-10-05 15:36:39 +08:00
parent 99e7a16a47
commit 7e7e26d869
3 changed files with 34 additions and 40 deletions
+24 -31
View File
@@ -7,10 +7,7 @@ a { color: inherit; text-decoration: none; }
/* Kling-inspired project home */
.kling-shell { min-height: 100vh; background: #f6f6f7; }
.kling-windowbar { position: fixed; z-index: 20; inset: 0 0 auto 0; height: 34px; display: flex; align-items: center; gap: 18px; padding: 0 7px; background: #fff; border-bottom: 1px solid #e5e5e7; }
.kling-windowbar strong { width: 142px; font-size: 13px; }
.kling-windowbar button { width: 30px; height: 30px; display: grid; place-items: center; background: transparent; color: #777; }
.kling-sidebar { position: fixed; z-index: 15; left: 0; top: 34px; bottom: 0; width: 76px; display: flex; flex-direction: column; align-items: center; padding: 15px 7px 10px; background: #fff; border-right: 1px solid #e8e8ea; }
.kling-sidebar { position: fixed; z-index: 15; left: 0; top: 0; bottom: 0; width: 76px; display: flex; flex-direction: column; align-items: center; padding: 15px 7px 10px; background: #fff; border-right: 1px solid #e8e8ea; }
.kling-logo { width: 32px; height: 32px; display: grid; place-items: center; margin-bottom: 18px; border: 2px solid var(--red); border-radius: 13px 13px 13px 5px; color: var(--red); font-size: 17px; font-weight: 900; transform: rotate(-8deg); }
.kling-sidebar nav, .side-footer { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.kling-sidebar nav > i { width: 36px; height: 1px; margin: 3px 0; background: #ececef; }
@@ -69,8 +66,8 @@ a { color: inherit; text-decoration: none; }
.project-categories button { padding: 0; background: transparent; color: #696971; font-size: 13px; }
.project-categories button.active { color: var(--red); font-weight: 700; }
.project-masonry { columns: 5 210px; column-gap: 8px; }
.project-tile { display: inline-block; width: 100%; break-inside: avoid; margin-bottom: 15px; overflow: hidden; border-radius: 9px; background: #fff; box-shadow: 0 0 0 1px #e9e9ec; transition: transform .18s, box-shadow .18s; }
.project-masonry { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); align-items: start; gap: 15px 10px; }
.project-tile { display: block; min-width: 0; overflow: hidden; border-radius: 9px; background: #fff; box-shadow: 0 0 0 1px #e9e9ec; transition: transform .18s, box-shadow .18s; }
.project-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,.09); }
.project-cover { position: relative; min-height: 160px; max-height: 345px; overflow: hidden; background: linear-gradient(140deg, #ececef, #dddde1); }
.project-cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
@@ -95,8 +92,8 @@ a { color: inherit; text-decoration: none; }
.dashboard-toast button { background: transparent; color: #999; }
/* Image project editor */
.image-editor-shell { height: 100vh; min-width: 1100px; overflow: hidden; display: grid; grid-template: 56px 1fr / 164px minmax(520px, 1fr) 304px; background: #ededf0; }
.editor-topbar { grid-column: 1 / 4; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; padding: 0 14px; border-bottom: 1px solid #e1e1e4; background: #fff; }
.image-editor-shell { position: relative; height: 100vh; min-width: 980px; overflow: hidden; display: grid; grid-template-rows: 56px 1fr; background: #ededf0; }
.editor-topbar { grid-row: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; padding: 0 14px; border-bottom: 1px solid #e1e1e4; background: #fff; }
.editor-brand { display: flex; align-items: center; min-width: 0; gap: 9px; }
.editor-back { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; color: #555; }
.editor-back:hover { background: #f0f0f2; }
@@ -110,32 +107,26 @@ a { color: inherit; text-decoration: none; }
.ghost-control { border: 1px solid #dddde1; background: #fff; color: #45454a; }
.save-control { background: var(--red); color: #fff; font-weight: 600; }
.save-control:disabled { opacity: .55; }
.editor-filmstrip { grid-row: 2; padding: 13px 11px; overflow-y: auto; border-right: 1px solid #dedee2; background: #f8f8f9; }
.filmstrip-title { display: flex; justify-content: space-between; padding: 0 3px 10px; font-size: 12px; font-weight: 600; }
.filmstrip-title small { color: #999; font-weight: 400; }
.filmstrip-list { display: flex; flex-direction: column; gap: 10px; }
.filmstrip-item { position: relative; width: 100%; height: 118px; padding: 5px; overflow: hidden; border: 2px solid transparent; border-radius: 9px; background: #eeeef0; }
.filmstrip-item.active { border-color: var(--red); background: #fff; }
.filmstrip-item > span { position: absolute; z-index: 2; left: 7px; top: 7px; width: 19px; height: 19px; display: grid; place-items: center; border-radius: 6px; background: rgba(20,20,22,.7); color: #fff; font-size: 9px; }
.filmstrip-item img { width: 100%; height: 100%; display: block; border-radius: 5px; object-fit: cover; }
.filmstrip-add { width: 100%; height: 35px; margin-top: 10px; border: 1px dashed #ccc; border-radius: 8px; background: transparent; color: #888; }
.editor-workspace { position: relative; grid-row: 2; min-width: 0; display: grid; grid-template-rows: 43px 1fr 48px; overflow: hidden; background: #e9e9ec; }
.canvas-toolbar { display: flex; align-items: center; justify-content: center; gap: 6px; border-bottom: 1px solid #dddde1; background: #f8f8f9; }
.canvas-toolbar button { height: 29px; padding: 0 10px; border-radius: 7px; background: transparent; color: #66666d; font-size: 11px; }
.canvas-toolbar button:hover { background: #ececef; }
.canvas-toolbar i { width: 1px; height: 18px; margin: 0 5px; background: #ddd; }
.canvas-toolbar span { margin-right: 5px; color: #86868e; font-size: 10px; }
.canvas-viewport { min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 28px; background-image: radial-gradient(#d0d0d4 .7px, transparent .7px); background-size: 16px 16px; }
.canvas-page { position: relative; height: min(66vh, 680px); max-width: 82%; aspect-ratio: var(--canvas-ratio); overflow: hidden; box-shadow: 0 12px 42px rgba(20,20,24,.18); touch-action: none; user-select: none; }
.editor-workspace { position: relative; grid-row: 2; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) 126px; overflow: hidden; background: #e9e9ec; }
.canvas-viewport { min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 26px 320px 22px 40px; background-image: radial-gradient(#d0d0d4 .7px, transparent .7px); background-size: 16px 16px; }
.canvas-page { position: relative; height: min(68vh, 680px); max-width: 84%; aspect-ratio: var(--canvas-ratio); overflow: hidden; box-shadow: 0 16px 50px rgba(20,20,24,.2); touch-action: none; user-select: none; }
.canvas-page > img { width: 100%; height: 100%; display: block; transform-origin: center; pointer-events: none; }
.canvas-selection { position: absolute; inset: 0; border: 1px solid rgba(255,36,66,.75); pointer-events: none; }
.handle { position: absolute; width: 7px; height: 7px; border: 1px solid var(--red); background: #fff; }
.handle.nw { left: -4px; top: -4px; }.handle.ne { right: -4px; top: -4px; }.handle.sw { left: -4px; bottom: -4px; }.handle.se { right: -4px; bottom: -4px; }
.editor-pagination { display: flex; align-items: center; justify-content: center; gap: 13px; border-top: 1px solid #dddde1; background: #f7f7f8; }
.editor-pagination button { width: 28px; height: 28px; border-radius: 7px; background: #fff; color: #555; }
.editor-pagination button:disabled { color: #c5c5c8; }
.editor-pagination span { color: #6f6f76; font-size: 11px; }
.editor-inspector { grid-row: 2; overflow-y: auto; border-left: 1px solid #dddde1; background: #fff; }
.editor-carousel { position: relative; z-index: 4; display: flex; align-items: center; justify-content: center; gap: 13px; padding-right: 300px; border-top: 1px solid rgba(210,210,214,.8); background: rgba(248,248,249,.92); backdrop-filter: blur(14px); }
.carousel-track { height: 112px; display: flex; align-items: center; justify-content: center; gap: 3px; min-width: 390px; perspective: 700px; }
.carousel-slide { position: relative; width: 57px; height: 73px; flex: 0 0 auto; padding: 3px; overflow: hidden; border: 2px solid transparent; border-radius: 8px; background: #fff; box-shadow: 0 6px 17px rgba(0,0,0,.13); transition: transform .2s, opacity .2s; }
.carousel-slide img { width: 100%; height: 100%; display: block; border-radius: 4px; object-fit: cover; }
.carousel-slide span { position: absolute; left: 5px; bottom: 5px; width: 16px; height: 16px; display: grid; place-items: center; border-radius: 5px; background: rgba(20,20,22,.7); color: #fff; font-size: 8px; }
.carousel-slide.active { width: 79px; height: 98px; z-index: 3; border-color: var(--red); transform: translateY(-5px); }
.carousel-slide.left { transform: rotateY(18deg) rotate(-5deg) scale(.9); transform-origin: right center; }
.carousel-slide.right { transform: rotateY(-18deg) rotate(5deg) scale(.9); transform-origin: left center; }
.carousel-slide.far { opacity: .48; transform: scale(.72); }
.carousel-arrow { width: 31px; height: 31px; border-radius: 50%; background: #fff; color: #555; box-shadow: 0 4px 14px rgba(0,0,0,.1); font-size: 20px; }
.carousel-arrow:disabled { opacity: .3; }
.carousel-add { width: 48px; height: 64px; flex: 0 0 auto; border: 1px dashed #bbb; border-radius: 8px; background: rgba(255,255,255,.45); color: #888; }
.editor-inspector { position: absolute; z-index: 8; top: 76px; right: 18px; bottom: 22px; width: 286px; overflow-y: auto; border: 1px solid rgba(215,215,219,.95); border-radius: 14px; background: rgba(255,255,255,.96); box-shadow: 0 16px 45px rgba(25,25,30,.16); backdrop-filter: blur(16px); }
.inspector-tabs { height: 44px; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid #e5e5e8; }
.inspector-tabs button { position: relative; background: transparent; color: #929298; font-size: 12px; }
.inspector-tabs button.active { color: #26262a; font-weight: 600; }
@@ -164,5 +155,7 @@ a { color: inherit; text-decoration: none; }
.quick-tools { grid-template-columns: repeat(4, 1fr); }
.quick-tool:last-child { display: none; }
.project-search { width: 270px; }
.image-editor-shell { grid-template-columns: 140px minmax(480px, 1fr) 280px; }
.canvas-viewport { padding-right: 288px; }
.editor-carousel { padding-right: 270px; }
.editor-inspector { width: 260px; right: 12px; }
}
+10 -8
View File
@@ -107,6 +107,7 @@ export default function ImageEditor({ projectId }: { projectId: string }) {
borderRadius: `${selected.settings.borderRadius}px`,
} as CSSProperties;
const ratioStyle = { "--canvas-ratio": `${project.canvas.width} / ${project.canvas.height}`, background: project.canvas.background } as CSSProperties;
const selectedIndex = project.slides.findIndex((item) => item.id === selected.id);
return <main className="image-editor-shell">
<header className="editor-topbar">
@@ -116,21 +117,22 @@ export default function ImageEditor({ projectId }: { projectId: string }) {
<input ref={fileInput} hidden type="file" accept="image/png,image/jpeg,image/webp" multiple onChange={(event) => void addImages(event.target.files)} />
</header>
<aside className="editor-filmstrip">
<div className="filmstrip-title"><span>页面</span><small>{project.slides.length}</small></div>
<div className="filmstrip-list">{project.slides.map((slide, index) => <button key={slide.id} className={`filmstrip-item ${selected.id === slide.id ? "active" : ""}`} onClick={() => setSelectedId(slide.id)}><span>{index + 1}</span><img src={imageUrl(project.id, slide.fileName)} alt={slide.originalName} /></button>)}</div>
<button className="filmstrip-add" onClick={() => fileInput.current?.click()}>+</button>
</aside>
<section className="editor-workspace">
<div className="canvas-toolbar"><button>↖ 选择</button><button>✋ 移动</button><i /><span>{project.canvas.width} × {project.canvas.height}</span><button onClick={() => updateSettings({ scale: 100, offsetX: 0, offsetY: 0, rotation: 0 })}>重置视图</button></div>
<div className="canvas-viewport">
<div className="canvas-page" style={ratioStyle} onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp}>
<img draggable={false} src={imageUrl(project.id, selected.fileName)} alt={selected.originalName} style={style} />
<div className="canvas-selection"><i className="handle nw"/><i className="handle ne"/><i className="handle sw"/><i className="handle se"/></div>
</div>
</div>
<div className="editor-pagination"><button disabled={project.slides[0].id === selected.id} onClick={() => setSelectedId(project.slides[Math.max(0, project.slides.findIndex((item) => item.id === selected.id) - 1)].id)}>‹</button><span>{project.slides.findIndex((item) => item.id === selected.id) + 1} / {project.slides.length}</span><button disabled={project.slides.at(-1)?.id === selected.id} onClick={() => setSelectedId(project.slides[Math.min(project.slides.length - 1, project.slides.findIndex((item) => item.id === selected.id) + 1)].id)}>›</button></div>
<div className="editor-carousel">
<button className="carousel-arrow" disabled={selectedIndex === 0} onClick={() => setSelectedId(project.slides[Math.max(0, selectedIndex - 1)].id)}>‹</button>
<div className="carousel-track">{project.slides.map((slide, index) => {
const offset = index - selectedIndex;
if (Math.abs(offset) > 2) return null;
return <button key={slide.id} className={`carousel-slide ${offset === 0 ? "active" : offset < 0 ? "left" : "right"} ${Math.abs(offset) === 2 ? "far" : ""}`} onClick={() => setSelectedId(slide.id)}><img src={imageUrl(project.id, slide.fileName)} alt={slide.originalName} /><span>{index + 1}</span></button>;
})}<button className="carousel-add" onClick={() => fileInput.current?.click()}>+</button></div>
<button className="carousel-arrow" disabled={selectedIndex === project.slides.length - 1} onClick={() => setSelectedId(project.slides[Math.min(project.slides.length - 1, selectedIndex + 1)].id)}>›</button>
</div>
</section>
<aside className="editor-inspector">
-1
View File
@@ -63,7 +63,6 @@ export default function Studio() {
const visibleProjects = projects.filter((project) => project.name.toLowerCase().includes(query.trim().toLowerCase()));
return <main className="kling-shell">
<header className="kling-windowbar"><strong>首页</strong><button aria-label="新建"><Icon name="plus" size={18} /></button></header>
<aside className="kling-sidebar">
<div className="kling-logo">R</div>
<nav>