|
SHANG GAO
www.shanggao.net
© 2000-2026 SHANG GAO. All rights reserved. Unauthorized commercial use is prohibited.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Read 546
UI Design System & GuidelinesWebsite Design Reference v1.1.0 1. Introduction介绍 Purpose · 目的
Reference Standards · 参考标准
Scope · 适用范围This document applies to the current website (Home Page + Content Pages + existing styles). Future product plans are out of scope. 本规范适用于当前网站(主页 + 内容页 + 现有样式)。未来的产品计划不在本规范范围内。 2. Design Principles设计原则 Five core principles · 五大核心原则:
3. Terminology术语对照 Page-Level · 页面级
Interactive Components · 交互组件
Layout Units · 布局单位
Navigation · 导航
States · 状态
4. Typography System字号系统
Base: Token Definitions
Responsive Scaling · 缩放/* Desktop: 100% (default) */
html { font-size: 100%; }
/* Tablet ≤ 900px */
@media (max-width: 900px) {
html { font-size: 90%; }
}
/* Mobile ≤ 640px */
@media (max-width: 640px) {
html { font-size: 85%; }
}
Effect · 效果:
Font Weight
Line Height
5. Spacing System间距系统 Base: 4px grid
Applications · 应用场景
6. Color System色彩系统 Site Theme (Dark) · 站点主题--bg
#0c148b
--bg-alt / --card
#0a1069
--text
#ffffff
--muted
#c3ceff
--accent
#66d9ff
--accent-hover
#8ae6ff
--border
#3d4fd8
--yellow
#ffd83d
Document Theme (Light) · 文档主题Used on content pages (articles, docs) for readability. 用于内容页(文章、文档),确保可读性。 --doc-bg
#ffffff
--doc-text
#1a1a2e
--doc-muted
#4b5568
--doc-accent
#2563eb
--doc-accent-soft
#dbeafe
--doc-card
#f9fafb
--doc-border
#e5e7eb
Status Colors · 状态色--success
#10b981
--warn
#ef4444
--gold
#f59e0b
Contrast (WCAG AA)
7. Radius & Shadow圆角与阴影 Radius
Shadow
8. Layout Structure布局结构 Page Hierarchy · 页面层级┌─────────────────────────────────┐
│ Header │
├─────────────────────────────────┤
│ │
│ Main Content │
│ │
│ ┌───────────────────────┐ │
│ │ Section │ │
│ │ ┌───────────┐ │ │
│ │ │ Card │ │ │
│ │ └───────────┘ │ │
│ └───────────────────────┘ │
│ │
├─────────────────────────────────┤
│ Footer │
└─────────────────────────────────┘
Container Width
9. Header顶部 Structure (Desktop)┌─────────────────────────────────────────┐
│ [Logo] [Clock] [Nav Items...] [☰] │
└─────────────────────────────────────────┘
Dimensions
Mobile (≤900px)
Mobile Header Height@media (max-width: 640px) {
:root { --header-height: 64px; }
}
10. Section区块 StructureSection Title
Section Subtitle
[Card] [Card] [Card]
Dimensions
Note · 注意
Section 副标题末尾不加句号。Section subtitles do NOT end with a period. 11. Card卡片 Structure┌───────────────────────────┐
│ [Icon] │
│ Card Title │
│ Sub-label: Body Text │
└───────────────────────────┘
Dimensions
States
12. Button按钮 Types
Dimensions
States
13. Form表单 StructureLabel
[Input field]
Label
[Textarea]
[Button] [Button]
Dimensions
States
14. Modal弹窗 Structure▒▒▒▒▒ Overlay ▒▒▒▒▒
┌─────────────────────┐
│ Modal Header [X] │
├─────────────────────┤
│ Countdown │
│ Modal Body │
│ ... │
├─────────────────────┤
│ Modal Footer │
└─────────────────────┘
Dimensions
15. Footer页脚 StructureFooter Trust Label
Client List
─────────────────────
[Col 1] [Col 2] [Col 3] [Col 4]
─────────────────────
Copyright (centered)
Dimensions
Changed in v1.1
移除了页脚时钟。版权信息改为居中显示,字号统一为 16. Content Page Structure内容页结构 All content (articles, milestones, projects, courses) follows a unified directory and URL structure. 所有内容(文章、里程碑、项目、课程)遵循统一的目录与 URL 结构。 Directory Structure · 目录结构{category}/
└── YYMMDDNN-slug/
├── index.php ← 正文
├── meta.php ← 元数据
└── assets/
└── index.php ← 安全跳转
Directory Naming · 目录命名
Examples · 示例: 26091300-Professional-Website-Design
26091301-专业网站首页设计
26091400-Second-Milestone
Parsing Rule · 解析规则
前 6 位是日期 URL Structure · URL 结构https://www.shanggao.net/{category}/{YYMMDDNN-slug}/
Example:
https://www.shanggao.net/milestones/26091300-Professional-Website-Design/
Reserved Categories · 预留分类
17. Content Page Header内容页头部 Content pages use a 3-column header. Height matches the main site header. 内容页采用三栏头部,高度与主站一致。 Structure — Desktop┌──────────────────────────────────────────────┐
│ [Logo] [Category Name] [Back] │
└──────────────────────────────────────────────┘
Structure — Mobile (≤640px)┌──────────────────────────────┐
│ [Logo] [📋] [←] │
└──────────────────────────────┘
Elements
Why a 📋 icon on mobile?
手机隐藏中间分类名后,会失去"回列表"入口。 Dimensions
Filter Button (List Page)List page header has an additional search box (desktop) / search icon (mobile). 列表页头部另有搜索框(桌面)/ 搜索图标(手机)。 18. Content Listing Page列表页
The listing page ( Structure┌─────────────────────────────────────────────────┐
│ Professional Website Design 1 Shang Gao · │
│ 2026-09-13 │
│ Completed the design and implementation... │
│ [web] [design] [php] [css] │
└─────────────────────────────────────────────────┘
Card Layout
Mobile (≤640px)
Content Sources
Posts are loaded via the shared $items = load_posts('milestones', null, dirname(__DIR__));
Sorting · 排序
By Home Page Block
The home page shows the latest 5 posts per category, with a "Coming soon ..." placeholder if fewer than 5.
主页每个分类区块显示最新 5 条;不足 5 条时补一条 19. Content Detail Page正文页 Structure┌──────────────────────────────────────────┐
│ [PDF / Print] [★ ★ ★ ★ ★] │ ← Actions
├──────────────────────────────────────────┤
│ Professional Website Design 1 │
│ 专业网站首页设计 │
│ Shang Gao · 2026-09-13 │
├──────────────────────────────────────────┤
│ ┌────────────────┬────────────────┐ │
│ │ What Was Built │ What Was Learned│ │
│ │ │ │ │
│ │ ... │ ... │ │
│ └────────────────┴────────────────┘ │
│ │
│ [Comparison Table] │
│ │
│ [Next Steps Cards] │
└──────────────────────────────────────────┘
Actions Bar
Document Header
Two-Column Grid
桌面双列( 20. Print & PDF打印与 PDF Strategy · 策略
Print Layout · 打印版式
Page Header & Footer
Print header and footer are rendered via a <table class="print-table">
<thead>...页眉...</thead>
<tbody>...正文...</tbody>
<tfoot>...页脚...</tfoot>
</table>
Header Content · 页眉内容Shang Gao www.shanggao.net
© 2000-2026 Shang Gao. All rights reserved. 未经书面许可,不得用于商业用途。
Print CSS Rules
关键:卡片允许拆分
禁止打印 · Print Disabled
当 @media print {
body * { display: none !important; }
body::after {
content: "This content is for online viewing only.";
display: block;
padding: 80mm 20mm;
}
}
21. Meta Referencemeta 字段
Every post directory contains a base meta file ( Both files return an array. The base meta is loaded first, then the language file is merged on top. 两个文件都返回数组。先加载基础 meta,再合并语言文件。 Base Meta ·
|
| Field | Type | Description |
|---|---|---|
index | string | 当天序号 NN(00–99) |
author | string | 作者名 |
version | string | 语义化版本号,如 1.0.0 |
created | string | 创建时间,12 位 YYMMDDhhmmss |
updated | string | 更新时间,12 位 YYMMDDhhmmss |
tags | array | 标签数组,如 ['php', 'css'] |
visibility | string | public / members / private / draft |
allow_print | bool | 是否允许打印,默认 true |
allow_pdf | bool | 是否允许下载 PDF,默认 true |
pdf | string | PDF 文件路径(可选,默认空字符串) |
category
文章 meta 中不再包含 category 字段。
分类由文章所在目录自动推断({category}/YYMMDDNN-slug/ 的 {category} 部分)。
这是冗余字段,无需在每篇文章中重复声明。
Language Meta · meta-{lang}.php
Language-specific text. Merged on top of the base meta at load time. 语言相关文本。加载时合并到基础 meta 之上。
| Field | Type | Description |
|---|---|---|
title | string | 标题 |
subtitle | string | 副标题 |
summary | string | 摘要(用于列表卡片与 <meta name="description">) |
基础字段(作者、日期、可见性)与语言无关;title / subtitle / summary 需要按语言提供。
目前只提供 meta-en.php;meta-zh.php 将在后续添加。
Example · meta.php
Example · meta-en.php
Both files check a load constant before returning data.
meta.php uses ALLOW_META_LOAD;
meta-{lang}.php uses ALLOW_META_TRANS_LOAD.
Direct URL access returns 404.
22. Visibility & Permissions
可见性与权限
Visibility Levels
| Value | 列表页 / 主页 | 正文页 |
|---|---|---|
public |
显示 | 所有人可访问 |
members |
显示(将来按登录状态) | 登录会员可访问 |
private |
不显示 | 404(不暴露存在) |
draft |
不显示 | 404 |
PDF / Print Permissions
| allow_pdf | allow_print | 行为 |
|---|---|---|
true |
(忽略) | 显示 PDF 下载(如果 pdf 文件存在) |
false |
true |
显示 window.print() 按钮 |
false |
false |
按钮禁用 + 打印时整页空白 |
权限检查必须在服务端(PHP)进行,不能只靠前端隐藏。private 文章即使被猜到 URL 也必须返回 404。
23. Security Guidelines
安全规范
Core Rule · 核心规则
任何权限限制必须在服务端检查。前端隐藏只是"不显示",不是"禁止访问"。
Implementation · 实施
- 列表页 / 主页:过滤显示(跳过
private) - 正文页:独立再做一次检查(404)
- 错误响应:用
404 Not Found(不用 403,避免暴露存在)
Error Responses
| 场景 | 响应 |
|---|---|
| 权限不足 | 404(不暴露) |
| 配置缺失 | 500 |
| 方法不允许(表单) | 405 |
Future · 未来
- 用户系统:注册、登录、会话
- 会员检查:登录状态 + 会员等级
- 私有 assets:图片、PDF 访问控制
- 水印 PDF:给会员 PDF 加"会员 ID 水印"(追踪泄露来源)
- 审计日志:谁访问了什么
- Rate limiting:防垃圾邮件 / DoS
24. File Protection
文件保护
敏感文件通过"加载常量"保护:只有被可信脚本 require 时才能执行。
直接访问 → 404。
Protected Files
| File | Constant |
|---|---|
config.php | ALLOW_CONFIG_LOAD |
meta.php | ALLOW_META_LOAD |
includes/functions.php | ALLOW_FUNCTIONS_LOAD |
includes/site.php | ALLOW_SITE_LOAD |
Pattern
被保护文件的开头:
调用方:
assets/ Protection
assets/index.php 做跳转,防止目录浏览:
assets/index.php 只防止"目录浏览",不防止"直接访问具体文件"(如 assets/cover.jpg)。敏感资源的保护需要在服务器层或将来 CMS 中处理。
25. Breakpoints
断点
| Name | Range | Device |
|---|---|---|
| Mobile | ≤ 640px | 手机 |
| Tablet | 641–900px | 平板 |
| Desktop | ≥ 901px | 电脑 |
Media Queries
使用三个命名断点:Mobile / Tablet / Desktop。Desktop 用默认样式(无媒体查询)。
26. Mobile-First Strategy
移动优先
Flow · 流程
- 先设计 320px —— 最小手机
- 扩展到 640px —— 大手机
- 扩展到 900px —— 平板
- 扩展到 1320px —— 桌面
Key Techniques · 关键技巧
- 用 rem —— 基于 html 基准字号
- 移动端缩放 —— 平板 90%,手机 85%
- 单列优先 —— 手机单列,桌面多列
- 触摸友好 —— 按钮高度 ≥ 43px
- Header 高度 —— 桌面 76px,手机 64px
手机屏幕窄,字号需按比例缩小,但 80% 偏小、90% 偏大,85% 是经验最优值。
27. CSS Class Mapping
CSS 类映射
Home Page
| Term | CSS Class |
|---|---|
| Header | .site-header |
| Logo | .logo |
| Primary Nav | .site-nav |
| Nav Item | .site-nav a |
| Hero Name | .hero-name |
| Section | .section |
| Section Title | .section-title |
| Section Subtitle | .section-sub |
| Card | .card |
| Primary Button | .btn-primary |
| Secondary Button | .btn-secondary |
| Outline Button | .btn-outline |
| Badge | .badge |
| Post List | .post-list |
| Post Item | .post-item |
| Post Title | .post-title |
| Post Meta | .post-meta |
| Post Author | .post-author |
| Post Date | .post-date |
| Footer | .site-footer |
| Copyright | .footer-copyright |
Content Pages
| Term | CSS Class |
|---|---|
| Content Header | .gs-header |
| Content Nav Wrap | .gs-nav-wrap |
| Content Logo | .gs-logo |
| Header Title | .gs-header-h1 |
| Back Button | .gs-back |
| List Icon (mobile) | .gs-list-btn |
| Search Box | .gs-search |
| Document | .gs-doc |
| Document Header | .gs-doc-header |
| Category Tag | .gs-category |
| Author | .gs-author |
| Two-Column Grid | .gs-grid-2 |
| Column | .gs-col |
| List Card (listing) | .gs-card |
| Rating Stars | .gs-stars |
28. Framework Comparison
框架对照
| Our Term | Material | Apple HIG | Bootstrap |
|---|---|---|---|
| Page | Screen | Screen | Page |
| Header | App Bar | Nav Bar | Navbar |
| Primary Nav | Navigation Bar | Tab Bar | Nav |
| Card | Card | Cell | Card |
| Button | Button | Button | Button |
| Modal | Dialog | Modal | Modal |
| Form | Form | Form | Form |
| Input | Text Field | Text Field | Form Control |
| Badge | Chip | Badge | Badge |
29. Changelog
更新记录
| Version | Date | Changes |
|---|---|---|
| 1.0 | 2026-09-13 | 初始版本 |
| 1.1 | 2026-09-17 |
视觉系统:手机字号 80% → 85%; Header:手机高度 64px、按钮高度 43px; Spacing:Card padding 补左右 24px、Button padding 补左右 32px; Form:label gap 8px、input padding 12px 16px、radius 6px、group gap 16px; Footer:去时钟、padding 64px 0 24px、版权 22px 居中; 新增:文档主题色 --doc-*;--radius-btn;新增:Part 3.5 内容页规范; 新增:Part 3.6 Data & Meta; 新增:Part 3.7 Security; 新增:打印 / PDF 规范。 |
— End of Document · 文档结束 —