画廊添加

This commit is contained in:
2026-08-08 16:06:36 +08:00
parent 989ad91b69
commit b21043e3b8
17 changed files with 1008 additions and 170 deletions
+25
View File
@@ -0,0 +1,25 @@
import {useEffect, useRef, useState} from 'react';
import {amis_fetcher} from './amis_fetcher';
import {embed_amis} from './amis_runtime';
type Amis_Schema = Record<string, unknown>;
interface Amis_Panel_Props {
schema: Amis_Schema;
className?: string;
}
export default function AmisPanel({schema, className = ''}: Amis_Panel_Props) {
const container = useRef<HTMLDivElement>(null);
const [error, set_error] = useState('');
useEffect(() => {
if(!container.current) {
return;
}
set_error('');
try {
const scoped = embed_amis(container.current, schema, amis_fetcher);
return () => scoped.unmount();
} catch(reason) {
set_error(reason instanceof Error ? reason.message : String(reason));
}
}, [schema]);
return <div className={`amis-panel ${className}`}>{error ? <div className="inline-error">{error}</div> : <div ref={container} className="amis-runtime" />}</div>;
}
+474 -94
View File
@@ -1,118 +1,498 @@
.app-shell {
width: min(1320px, calc(100% - 32px));
margin: 32px auto;
width: min(1540px, calc(100% - 32px));
margin: 24px auto 48px;
}
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
margin-bottom: 16px;
.hero {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 32px;
padding: 28px 32px;
border: 1px solid #dbe4f0;
border-radius: 18px;
background: linear-gradient(135deg, #ffffff 0%, #f7faff 58%, #eef5ff 100%);
box-shadow: 0 14px 42px rgba(15, 23, 42, 0.07);
}
.app-header h1 {
margin: 0 0 8px;
font-size: 28px;
.hero h1 {
margin: 4px 0 10px;
font-size: clamp(28px, 4vw, 46px);
line-height: 1.08;
letter-spacing: -0.04em;
}
.app-header p {
margin: 0;
color: #6b7280;
.hero p {
max-width: 900px;
margin: 0;
color: #64748b;
line-height: 1.7;
}
.app-header button {
flex: none;
padding: 9px 16px;
border: 1px solid #2563eb;
border-radius: 6px;
color: #fff;
background: #2563eb;
cursor: pointer;
.eyebrow {
color: #2563eb;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.16em;
}
.app-header button:disabled {
cursor: default;
opacity: 0.6;
.hero button {
flex: none;
padding: 10px 17px;
border: 1px solid #1d4ed8;
border-radius: 10px;
color: #fff;
background: #2563eb;
box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24);
cursor: pointer;
}
.demo-notes {
display: flex;
gap: 8px;
margin-bottom: 16px;
padding: 12px 16px;
border: 1px solid #bfdbfe;
border-radius: 8px;
background: #eff6ff;
.hero button:disabled {
cursor: default;
opacity: 0.55;
}
.amis-region {
min-height: 320px;
padding: 20px;
border: 1px solid #e5e7eb;
border-radius: 10px;
background: #fff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
.workspace {
display: grid;
grid-template-columns: 210px minmax(0, 1fr);
gap: 20px;
margin-top: 20px;
}
.sidebar {
align-self: start;
position: sticky;
top: 18px;
display: grid;
gap: 7px;
padding: 14px;
border: 1px solid #dbe4f0;
border-radius: 16px;
background: #fff;
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}
.side-title {
padding: 7px 10px 10px;
color: #94a3b8;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.12em;
}
.sidebar button {
display: grid;
gap: 2px;
width: 100%;
padding: 10px 11px;
border: 1px solid transparent;
border-radius: 10px;
text-align: left;
color: #334155;
background: transparent;
cursor: pointer;
}
.sidebar button span {
color: #94a3b8;
font-size: 12px;
}
.sidebar button.active {
border-color: #bfdbfe;
color: #1d4ed8;
background: #eff6ff;
}
.content {
min-width: 0;
padding: 22px;
border: 1px solid #dbe4f0;
border-radius: 16px;
background: #fff;
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
margin-bottom: 18px;
padding-bottom: 16px;
border-bottom: 1px solid #e2e8f0;
}
.section-head span {
color: #64748b;
font-size: 12px;
}
.section-head h2 {
margin: 2px 0 0;
font-size: 26px;
}
.protocol-tags {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
}
.protocol-tags span {
padding: 5px 8px;
border: 1px solid #dbeafe;
border-radius: 999px;
color: #1d4ed8;
background: #f8fbff;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.state-message {
padding: 32px;
text-align: center;
color: #6b7280;
padding: 24px;
border: 1px dashed #cbd5e1;
border-radius: 12px;
color: #64748b;
text-align: center;
}
.state-message.error {
color: #b91c1c;
.state-message.error,
.inline-error {
color: #b91c1c;
background: #fef2f2;
}
@media (max-width: 700px) {
.app-header {
align-items: stretch;
flex-direction: column;
}
.demo-notes {
flex-direction: column;
}
.intro-panel,
.explain-box,
.demo-block {
margin-bottom: 18px;
padding: 18px;
border: 1px solid #dbe4f0;
border-radius: 14px;
background: #fbfdff;
}
.adminive-status-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
.intro-panel h3,
.demo-block h3,
.endpoint-panel h3,
.protocol-panel h3 {
margin: 0 0 8px;
}
.adminive-status-grid > div {
display: flex;
flex-direction: column;
gap: 4px;
padding: 12px;
border: 1px solid #e5e7eb;
border-radius: 6px;
background: #f9fafb;
.intro-panel p,
.explain-box p {
margin: 4px 0 0;
color: #64748b;
line-height: 1.65;
}
.adminive-status-grid strong {
color: #6b7280;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
.layer-flow {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10px;
margin-top: 18px;
}
.adminive-status-grid span {
color: #111827;
font-size: 16px;
.layer-flow div {
display: grid;
align-content: start;
min-height: 126px;
padding: 13px;
border: 1px solid #e2e8f0;
border-radius: 12px;
background: #fff;
}
@media (max-width: 800px) {
.adminive-status-grid {
.layer-flow div > span {
display: grid;
place-items: center;
width: 26px;
height: 26px;
margin-bottom: 10px;
border-radius: 8px;
color: #fff;
background: #2563eb;
font-weight: 800;
}
.layer-flow small {
margin-top: 6px;
color: #64748b;
line-height: 1.45;
}
.capability-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
gap: 12px;
}
@media (max-width: 520px) {
.adminive-status-grid {
grid-template-columns: 1fr;
}
.capability-card {
padding: 16px;
border: 1px solid #e2e8f0;
border-radius: 12px;
}
.adminive-object-status {
min-width: 300px;
padding: 4px 0;
.capability-card h3 {
margin: 0 0 10px;
font-size: 15px;
}
.adminive-object-status-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 8px 4px;
border-bottom: 1px solid #e5e7eb;
.badge-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.adminive-object-status-row:last-child {
border-bottom: 0;
.badge-list span {
padding: 4px 7px;
border-radius: 7px;
color: #475569;
background: #f1f5f9;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 12px;
}
.adminive-object-status-label {
color: #64748b;
.amis-panel {
min-width: 0;
margin-bottom: 16px;
}
.amis-runtime {
min-width: 0;
}
.inline-error {
padding: 12px;
border: 1px solid #fecaca;
border-radius: 10px;
}
.frontend-horizontal {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
}
.frontend-vertical {
display: grid;
gap: 10px;
}
.slot-demo {
height: 100%;
margin: 0;
padding: 13px;
border: 1px solid #dbeafe;
border-radius: 12px;
background: #fff;
}
.native-list {
border: 1px solid #e2e8f0;
border-radius: 12px;
overflow: hidden;
}
.native-list article {
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
align-items: center;
gap: 12px;
padding: 13px 14px;
border-bottom: 1px solid #e2e8f0;
}
.native-list article:last-child {
border-bottom: 0;
}
.native-list small,
.native-card-head small {
display: block;
margin-top: 3px;
color: #64748b;
}
.color-dot {
width: 12px;
height: 12px;
border-radius: 999px;
}
.state-pill {
padding: 4px 8px;
border-radius: 999px;
color: #64748b;
background: #f1f5f9;
font-size: 12px;
}
.state-pill.enabled {
color: #047857;
background: #ecfdf5;
}
.native-cards {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
}
.native-cards article {
position: relative;
overflow: hidden;
padding: 16px;
border: 1px solid #e2e8f0;
border-radius: 13px;
background: #fff;
}
.card-accent {
position: absolute;
inset: 0 0 auto;
height: 4px;
}
.native-card-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-top: 4px;
}
.native-card-head > span {
font-size: 28px;
font-weight: 800;
}
.meter {
height: 6px;
margin-top: 18px;
border-radius: 999px;
background: #e2e8f0;
overflow: hidden;
}
.meter i {
display: block;
height: 100%;
}
.native-cards p {
margin: 10px 0 0;
color: #64748b;
font-size: 13px;
}
.native-table-wrap {
overflow-x: auto;
border: 1px solid #e2e8f0;
border-radius: 12px;
}
.native-table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
}
.native-table th,
.native-table td {
padding: 11px 12px;
border-bottom: 1px solid #e2e8f0;
text-align: left;
white-space: nowrap;
}
.native-table th {
color: #475569;
background: #f8fafc;
}
.native-table tbody tr:last-child td {
border-bottom: 0;
}
.color-chip {
display: inline-flex;
align-items: center;
gap: 6px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.color-chip i {
width: 11px;
height: 11px;
border-radius: 3px;
}
.mode-switch {
display: inline-flex;
gap: 5px;
margin-bottom: 16px;
padding: 4px;
border: 1px solid #dbe4f0;
border-radius: 10px;
background: #f8fafc;
}
.mode-switch button {
padding: 7px 14px;
border: 0;
border-radius: 7px;
color: #64748b;
background: transparent;
cursor: pointer;
}
.mode-switch button.active {
color: #1d4ed8;
background: #fff;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.json-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.json-panel {
min-width: 0;
border: 1px solid #dbe4f0;
border-radius: 12px;
background: #0f172a;
overflow: hidden;
}
.json-panel summary {
padding: 12px 14px;
color: #dbeafe;
background: #172033;
cursor: pointer;
font-weight: 700;
}
.json-panel pre,
.protocol-panel pre {
max-height: 560px;
margin: 0;
padding: 15px;
overflow: auto;
color: #dbeafe;
background: #0f172a;
font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.doc-layout {
display: grid;
grid-template-columns: 0.85fr 1.65fr;
gap: 14px;
margin-bottom: 16px;
}
.endpoint-panel,
.protocol-panel {
min-width: 0;
padding: 16px;
border: 1px solid #e2e8f0;
border-radius: 13px;
}
.endpoint-panel code {
display: block;
margin-top: 7px;
padding: 7px 9px;
border-radius: 7px;
color: #334155;
background: #f1f5f9;
font-size: 12px;
overflow-wrap: anywhere;
}
.protocol-panel select {
width: 100%;
margin-bottom: 10px;
padding: 8px 10px;
border: 1px solid #cbd5e1;
border-radius: 8px;
background: #fff;
}
.protocol-panel pre {
border-radius: 9px;
}
@media (max-width: 1120px) {
.layer-flow {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.frontend-horizontal,
.native-cards {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 820px) {
.app-shell {
width: min(100% - 18px, 1540px);
margin-top: 10px;
}
.hero,
.section-head {
align-items: stretch;
flex-direction: column;
}
.workspace {
grid-template-columns: 1fr;
}
.sidebar {
position: static;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.side-title {
grid-column: 1 / -1;
}
.layer-flow,
.capability-grid,
.frontend-horizontal,
.native-cards,
.json-grid,
.doc-layout {
grid-template-columns: 1fr;
}
.protocol-tags {
justify-content: flex-start;
}
}
+84 -39
View File
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
interface Json_Panel_Props {
title: string;
value: unknown;
open?: boolean;
}
export default function JsonPanel({title, value, open = false}: Json_Panel_Props) {
return <details className="json-panel" open={open}><summary>{title}</summary><pre>{JSON.stringify(value, null, 2)}</pre></details>;
}
+20
View File
@@ -0,0 +1,20 @@
import type {Amis_Request} from './types';
type Amis_Fetcher = (request: Amis_Request) => Promise<unknown>;
export interface Amis_Scoped {
unmount(): void;
}
interface Amis_Embed_Module {
embed(container: HTMLElement | string, schema: Record<string, unknown>, props?: Record<string, unknown>, env?: Record<string, unknown>): Amis_Scoped;
}
declare global {
interface Window {
amisRequire?: (name: string) => unknown;
}
}
export function embed_amis(container: HTMLElement, schema: Record<string, unknown>, fetcher: Amis_Fetcher): Amis_Scoped {
if(!window.amisRequire) {
throw new Error('AMIS SDK runtime is not loaded');
}
const module = window.amisRequire('amis/embed') as Amis_Embed_Module;
return module.embed(container, schema, {}, {fetcher, theme: 'cxd'});
}
+12 -11
View File
@@ -1,18 +1,19 @@
:root {
font-family: Inter, "Microsoft YaHei", sans-serif;
color: #1f2937;
background: #f3f4f6;
font-synthesis: none;
text-rendering: optimizeLegibility;
font-family: Inter, "Microsoft YaHei", "PingFang SC", sans-serif;
color: #0f172a;
background: #f1f5f9;
font-synthesis: none;
text-rendering: optimizeLegibility;
}
* {
box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
min-width: 320px;
min-height: 100vh;
margin: 0;
min-width: 320px;
min-height: 100vh;
}
button {
font: inherit;
button,
select {
font: inherit;
}