- 新增 cdnjs.cloudflare.com CSP 白名单,允许加载 highlight.js - 消毒策略放行 span 元素,保留 highlight.js 高亮 class - 详情页和新帖子页引入 highlight.js 库和 GitHub 主题 - 代码块语言选择器默认 text,支持 prev/next 循环切换语言 - 代码块语言标签注入兼容 data-language 和 code class 双来源 - 修复 utils.js defer 导致 common.js 执行时 getCSRFToken 未定义
551 lines
12 KiB
CSS
551 lines
12 KiB
CSS
/* ========== 帖子列表 ========== */
|
||
.posts-container {
|
||
max-width: 960px;
|
||
margin: 0 auto;
|
||
padding: 24px 16px;
|
||
}
|
||
|
||
.posts-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 24px;
|
||
}
|
||
|
||
.posts-header h1 {
|
||
font-size: 28px;
|
||
font-weight: 700;
|
||
color: #111;
|
||
margin: 0;
|
||
}
|
||
|
||
.post-card {
|
||
background: #fff;
|
||
border: 1px solid #e5e7eb;
|
||
border-radius: 10px;
|
||
padding: 20px 24px;
|
||
margin-bottom: 16px;
|
||
transition: box-shadow 0.2s;
|
||
}
|
||
|
||
.post-card:hover {
|
||
box-shadow: 0 2px 12px rgba(0,0,0,0.08);
|
||
}
|
||
|
||
.post-card-title a {
|
||
font-size: 20px;
|
||
font-weight: 600;
|
||
color: #111;
|
||
text-decoration: none;
|
||
}
|
||
|
||
.post-card-title a:hover {
|
||
color: #6366f1;
|
||
}
|
||
|
||
.post-card-meta {
|
||
display: flex;
|
||
gap: 16px;
|
||
margin-top: 8px;
|
||
font-size: 13px;
|
||
color: #6b7280;
|
||
}
|
||
|
||
.post-card-summary {
|
||
margin-top: 12px;
|
||
color: #4b5563;
|
||
font-size: 14px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
/* ========== 帖子详情 ========== */
|
||
.post-detail {
|
||
max-width: 800px;
|
||
margin: 24px auto 40px;
|
||
}
|
||
|
||
.post-article {
|
||
background: #fff;
|
||
border-radius: 12px;
|
||
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
|
||
padding: 40px 48px;
|
||
}
|
||
|
||
.post-detail-header {
|
||
position: static !important;
|
||
z-index: auto !important;
|
||
box-shadow: none !important;
|
||
background: transparent !important;
|
||
margin-bottom: 32px;
|
||
padding-bottom: 20px;
|
||
border-bottom: 1px solid #e5e7eb;
|
||
}
|
||
|
||
.post-detail-title {
|
||
font-size: 32px;
|
||
font-weight: 700;
|
||
color: #111;
|
||
margin: 0 0 12px 0;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.post-detail-meta {
|
||
display: flex;
|
||
gap: 16px;
|
||
align-items: center;
|
||
font-size: 14px;
|
||
color: #6b7280;
|
||
}
|
||
|
||
.post-detail-body {
|
||
font-size: 16px;
|
||
line-height: 1.8;
|
||
color: #1f2937;
|
||
}
|
||
|
||
.post-detail-body h1,
|
||
.post-detail-body h2,
|
||
.post-detail-body h3 {
|
||
margin-top: 24px;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.post-detail-body p {
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.post-detail-body a {
|
||
color: var(--color-accent);
|
||
text-decoration: underline;
|
||
text-underline-offset: 2px;
|
||
transition: color 0.2s;
|
||
}
|
||
|
||
.post-detail-body a:hover {
|
||
color: #2980b9;
|
||
}
|
||
|
||
/* 代码块基础样式(背景色与 github-dark 主题保持一致) */
|
||
.post-detail-body pre {
|
||
position: relative;
|
||
background: #0d1117;
|
||
color: #c9d1d9;
|
||
padding: 12px 16px;
|
||
border-radius: 8px;
|
||
overflow-x: auto;
|
||
font-size: 14px;
|
||
line-height: 1.5;
|
||
font-family: 'Menlo', 'Consolas', 'Monaco', 'Liberation Mono', monospace;
|
||
}
|
||
|
||
/* 代码块语言标签(JS 动态注入) */
|
||
.post-detail-body pre .code-lang-label {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
padding: 4px 16px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
color: #8b949e;
|
||
background: #161b22;
|
||
border-radius: 8px 8px 0 0;
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
|
||
pointer-events: none;
|
||
z-index: 1;
|
||
}
|
||
|
||
.post-detail-body pre code {
|
||
background: transparent !important;
|
||
border: none !important;
|
||
padding: 0 !important;
|
||
font-size: inherit !important;
|
||
white-space: pre;
|
||
display: block;
|
||
}
|
||
|
||
.post-detail-body code {
|
||
background: #f3f4f6;
|
||
padding: 2px 6px;
|
||
border-radius: 4px;
|
||
font-size: 0.9em;
|
||
}
|
||
|
||
/* 代码块语法高亮由 highlight.js CDN 主题提供,此处仅保留基础布局 */
|
||
|
||
.post-detail-body img {
|
||
max-width: 100%;
|
||
height: auto;
|
||
border-radius: 8px;
|
||
}
|
||
|
||
.post-detail-body blockquote {
|
||
border-left: 4px solid #6366f1;
|
||
padding-left: 16px;
|
||
color: #6b7280;
|
||
margin: 16px 0;
|
||
}
|
||
|
||
.post-status {
|
||
padding: 2px 10px;
|
||
border-radius: 12px;
|
||
font-size: 12px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.post-status-draft { background: #f3f4f6; color: #6b7280; }
|
||
.post-status-pending { background: #fef3c7; color: #d97706; }
|
||
.post-status-approved { background: #d1fae5; color: #059669; }
|
||
.post-status-rejected { background: #fef2f2; color: #dc2626; }
|
||
.post-status-locked { background: #fee2e2; color: #b91c1c; }
|
||
|
||
.post-reject-reason {
|
||
margin-top: 20px;
|
||
padding: 12px 16px;
|
||
background: #fef2f2;
|
||
border: 1px solid #fecaca;
|
||
border-radius: 8px;
|
||
color: #b91c1c;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.post-actions {
|
||
margin-top: 24px;
|
||
display: flex;
|
||
gap: 12px;
|
||
}
|
||
|
||
/* ========== 404 ========== */
|
||
.error-404 {
|
||
text-align: center;
|
||
padding: 80px 0;
|
||
}
|
||
|
||
.error-404 h1 {
|
||
font-size: 72px;
|
||
color: #d1d5db;
|
||
margin: 0;
|
||
}
|
||
|
||
.error-404 p {
|
||
font-size: 18px;
|
||
color: #6b7280;
|
||
margin: 12px 0 24px;
|
||
}
|
||
|
||
/* ========== 空状态 ========== */
|
||
.empty-state {
|
||
text-align: center;
|
||
padding: 60px 0;
|
||
color: #9ca3af;
|
||
font-size: 16px;
|
||
}
|
||
|
||
.search-hint {
|
||
margin-bottom: 16px;
|
||
color: #6b7280;
|
||
font-size: 14px;
|
||
}
|
||
|
||
/* ========== 按钮 ========== */
|
||
.btn {
|
||
display: inline-block;
|
||
padding: 10px 20px;
|
||
border: none;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
cursor: pointer;
|
||
text-decoration: none;
|
||
transition: background 0.2s;
|
||
}
|
||
|
||
.btn-primary {
|
||
background: #6366f1;
|
||
color: #fff;
|
||
}
|
||
|
||
.btn-primary:hover { background: #4f46e5; }
|
||
|
||
.btn-secondary {
|
||
background: #f3f4f6;
|
||
color: #374151;
|
||
}
|
||
|
||
.btn-secondary:hover { background: #e5e7eb; }
|
||
|
||
/* ========== 分页 ========== */
|
||
.pagination {
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
gap: 16px;
|
||
margin-top: 32px;
|
||
padding-top: 20px;
|
||
border-top: 1px solid #e5e7eb;
|
||
}
|
||
|
||
.page-link {
|
||
padding: 8px 16px;
|
||
border: 1px solid #d1d5db;
|
||
border-radius: 8px;
|
||
color: #374151;
|
||
text-decoration: none;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.page-link:hover { background: #f3f4f6; }
|
||
|
||
.page-info {
|
||
font-size: 14px;
|
||
color: #6b7280;
|
||
}
|
||
|
||
/* ========== 错误消息 ========== */
|
||
.error-message {
|
||
padding: 12px 16px;
|
||
background: #fef2f2;
|
||
border: 1px solid #fecaca;
|
||
border-radius: 8px;
|
||
color: #b91c1c;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
/* ========== 编辑器布局 ========== */
|
||
.editor-layout {
|
||
height: calc(100vh - 56px);
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.editor-form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 100%;
|
||
}
|
||
|
||
.editor-header {
|
||
padding: 16px 24px 12px;
|
||
border-bottom: 1px solid #e5e7eb;
|
||
background: #fff;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.editor-title-input {
|
||
width: 100%;
|
||
padding: 6px 0;
|
||
border: none;
|
||
font-size: 26px;
|
||
font-weight: 700;
|
||
color: #111;
|
||
outline: none;
|
||
background: transparent;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.editor-title-input::placeholder { color: #c4c4c4; }
|
||
|
||
.editor-main {
|
||
flex: 1;
|
||
display: flex;
|
||
overflow: hidden;
|
||
min-height: 0;
|
||
}
|
||
|
||
.editor-pane {
|
||
flex: 1;
|
||
overflow: hidden;
|
||
min-width: 0;
|
||
}
|
||
|
||
.editor-statusbar {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16px;
|
||
padding: 6px 20px;
|
||
background: #fafafa;
|
||
border-top: 1px solid #e5e7eb;
|
||
font-size: 12px;
|
||
color: #9ca3af;
|
||
flex-shrink: 0;
|
||
min-height: 34px;
|
||
}
|
||
|
||
.status-item { white-space: nowrap; }
|
||
.status-spacer { flex: 1; }
|
||
.status-draft { color: #059669; font-weight: 500; }
|
||
.btn-submit { padding: 5px 18px; font-size: 13px; border-radius: 6px; }
|
||
|
||
.editor-layout.fullscreen {
|
||
position: fixed;
|
||
top: 0; left: 0; right: 0; bottom: 0;
|
||
z-index: 9999;
|
||
height: 100vh;
|
||
background: #fff;
|
||
}
|
||
|
||
/* ========== Tiptap 编辑器容器 ========== */
|
||
#editor-container {
|
||
flex: 1;
|
||
overflow: hidden;
|
||
min-height: 0;
|
||
background: #fff;
|
||
}
|
||
|
||
.tiptap {
|
||
padding: 16px 24px;
|
||
outline: none;
|
||
min-height: 100%;
|
||
font-size: 15px;
|
||
line-height: 1.7;
|
||
color: #24292f;
|
||
}
|
||
|
||
.tiptap p { margin: 0.5em 0; }
|
||
.tiptap h1 { margin: 1em 0 0.5em; font-size: 2em; font-weight: 700; }
|
||
.tiptap h2 { margin: 0.8em 0 0.4em; font-size: 1.5em; font-weight: 700; }
|
||
.tiptap h3 { margin: 0.6em 0 0.3em; font-size: 1.17em; font-weight: 700; }
|
||
|
||
.tiptap ul, .tiptap ol { padding-left: 1.5em; margin: 0.5em 0; }
|
||
.tiptap li { margin: 0.2em 0; }
|
||
.tiptap ul[data-type="taskList"] { list-style: none; padding-left: 0; }
|
||
.tiptap ul[data-type="taskList"] li { display: flex; align-items: flex-start; gap: 0.4em; }
|
||
.tiptap ul[data-type="taskList"] li > label { flex-shrink: 0; margin-top: 0.15em; }
|
||
|
||
.tiptap blockquote {
|
||
border-left: 3px solid #3498db;
|
||
padding-left: 1em;
|
||
margin: 0.5em 0;
|
||
color: #6b7280;
|
||
}
|
||
|
||
.tiptap pre {
|
||
background: #1a2332;
|
||
color: #e2e8f0;
|
||
padding: 12px 16px;
|
||
border-radius: 6px;
|
||
font-size: 13px;
|
||
line-height: 1.5;
|
||
overflow-x: auto;
|
||
margin: 0.5em 0;
|
||
position: relative;
|
||
}
|
||
.tiptap pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; white-space: pre; display: block; }
|
||
.tiptap code {
|
||
background: #f3f4f6;
|
||
padding: 2px 5px;
|
||
border-radius: 4px;
|
||
font-size: 0.9em;
|
||
font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
|
||
}
|
||
|
||
.tiptap pre .code-lang-label {
|
||
position: absolute;
|
||
top: 0; left: 0; right: 0;
|
||
padding: 4px 16px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
color: #94a3b8;
|
||
background: #2c3e50;
|
||
border-radius: 6px 6px 0 0;
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
|
||
pointer-events: none;
|
||
z-index: 1;
|
||
}
|
||
|
||
/* highlight.js One Dark 语法高亮 — 编辑器内 */
|
||
.tiptap pre code .hljs-keyword,
|
||
.tiptap pre code .hljs-selector-tag,
|
||
.tiptap pre code .hljs-literal,
|
||
.tiptap pre code .hljs-section,
|
||
.tiptap pre code .hljs-link { color: #c792ea; }
|
||
.tiptap pre code .hljs-string,
|
||
.tiptap pre code .hljs-title,
|
||
.tiptap pre code .hljs-name,
|
||
.tiptap pre code .hljs-type,
|
||
.tiptap pre code .hljs-attribute,
|
||
.tiptap pre code .hljs-symbol,
|
||
.tiptap pre code .hljs-bullet,
|
||
.tiptap pre code .hljs-addition,
|
||
.tiptap pre code .hljs-variable,
|
||
.tiptap pre code .hljs-template-tag,
|
||
.tiptap pre code .hljs-template-variable { color: #c3e88d; }
|
||
.tiptap pre code .hljs-comment,
|
||
.tiptap pre code .hljs-quote,
|
||
.tiptap pre code .hljs-deletion,
|
||
.tiptap pre code .hljs-meta { color: #676e95; }
|
||
.tiptap pre code .hljs-number,
|
||
.tiptap pre code .hljs-regexp,
|
||
.tiptap pre code .hljs-built_in { color: #f78c6c; }
|
||
.tiptap pre code .hljs-function .hljs-title,
|
||
.tiptap pre code .hljs-doctag,
|
||
.tiptap pre code .hljs-formula { color: #82aaff; }
|
||
.tiptap pre code .hljs-tag,
|
||
.tiptap pre code .hljs-subst { color: #f07178; }
|
||
.tiptap pre code .hljs-emphasis { font-style: italic; }
|
||
.tiptap pre code .hljs-strong { font-weight: bold; }
|
||
.tiptap pre code .hljs-attr,
|
||
.tiptap pre code .hljs-selector-attr,
|
||
.tiptap pre code .hljs-selector-class,
|
||
.tiptap pre code .hljs-selector-id,
|
||
.tiptap pre code .hljs-selector-pseudo { color: #ffcb6b; }
|
||
|
||
.tiptap hr { border: none; border-top: 1px solid #e5e7eb; margin: 1em 0; }
|
||
.tiptap img { max-width: 100%; height: auto; border-radius: 6px; }
|
||
.tiptap a { color: #3498db; text-decoration: underline; }
|
||
|
||
.tiptap p.is-editor-empty:first-child::before {
|
||
content: attr(data-placeholder);
|
||
float: left;
|
||
color: #c4c4c4;
|
||
pointer-events: none;
|
||
height: 0;
|
||
}
|
||
|
||
/* ========== 工具栏 ========== */
|
||
.editor-toolbar {
|
||
display: flex;
|
||
gap: 2px;
|
||
padding: 6px 12px;
|
||
background: #fafafa;
|
||
border-bottom: 1px solid #e5e7eb;
|
||
flex-shrink: 0;
|
||
flex-wrap: wrap;
|
||
}
|
||
.editor-toolbar button {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 32px;
|
||
height: 30px;
|
||
border: 1px solid transparent;
|
||
border-radius: 4px;
|
||
background: transparent;
|
||
color: #374151;
|
||
font-size: 13px;
|
||
cursor: pointer;
|
||
transition: background 0.15s;
|
||
}
|
||
.editor-toolbar button:hover { background: #e5e7eb; }
|
||
.editor-toolbar button.is-active { background: #1a2332; color: #fff; }
|
||
.code-lang-select {
|
||
height: 30px;
|
||
padding: 0 6px;
|
||
border: 1px solid transparent;
|
||
border-radius: 4px;
|
||
background: transparent;
|
||
color: #374151;
|
||
font-size: 12px;
|
||
cursor: pointer;
|
||
font-family: inherit;
|
||
outline: none;
|
||
}
|
||
.code-lang-select:hover { border-color: #e5e7eb; }
|
||
.code-lang-select:focus { border-color: #3498db; }
|
||
.editor-toolbar .toolbar-divider {
|
||
width: 1px;
|
||
background: #e5e7eb;
|
||
margin: 3px 4px;
|
||
}
|