feat: 调整全局和管理员字体大小,优化样式

This commit is contained in:
2026-04-12 13:59:18 +08:00
parent af78359d94
commit bae46aef77
6 changed files with 12 additions and 252 deletions

View File

@@ -20,9 +20,9 @@ require_once ("../include/my_func.inc.php");
:root {
--hustoj-admin-font-family: 'Sarasa Mono SC Local', '等距更纱黑体 SC', 'Sarasa Mono SC', 'Sarasa Fixed SC', 'Sarasa Gothic SC', Consolas, 'Cascadia Mono', 'JetBrains Mono', 'Courier New', monospace;
--hustoj-admin-font-size: 26px;
--hustoj-admin-heading-size: 30px;
--hustoj-admin-subheading-size: 28px;
--hustoj-admin-font-size: 24px;
--hustoj-admin-heading-size: 24px;
--hustoj-admin-subheading-size: 24px;
--hustoj-admin-line-height: 1.6;
}
@@ -42,10 +42,7 @@ require_once ("../include/my_func.inc.php");
.ui.label,
.ui.segment,
.ui.message,
.ui.table,
.vditor,
.vditor-reset,
.vditor-reset * {
.ui.table {
font-family: var(--hustoj-admin-font-family) !important;
font-size: var(--hustoj-admin-font-size) !important;
line-height: var(--hustoj-admin-line-height) !important;

View File

@@ -36,18 +36,7 @@
return scriptSrc.replace(/\/include\/vditor-adapter\.js(?:[?#].*)?$/, '/ace');
}
function getLocalSarasaFontUrl() {
var scriptSrc = currentScriptRef && currentScriptRef.src;
if (!scriptSrc) {
return 'template/syzoj/fonts/SarasaMonoSC-Regular.ttf';
}
return scriptSrc.replace(/\/include\/vditor-adapter\.js(?:[?#].*)?$/, '/template/syzoj/fonts/SarasaMonoSC-Regular.ttf');
}
function injectAdapterStyle() {
var sarasaFontUrl = getLocalSarasaFontUrl();
var style;
if (styleInjected) {
@@ -58,68 +47,17 @@
style.type = 'text/css';
style.setAttribute('data-hustoj-vditor', 'adapter-style');
style.textContent = [
'@font-face{font-family:"Sarasa Mono SC Local";src:local("等距更纱黑体 SC"),local("Sarasa Mono SC"),url("' + sarasaFontUrl + '") format("truetype");font-weight:400;font-style:normal;font-display:swap;}',
'.hustoj-vditor-hidden{display:none !important;}',
'.hustoj-vditor-wrapper{width:100%;margin:0 0 12px;}',
'.hustoj-vditor-wrapper,.hustoj-vditor-preview,.hustoj-vditor-markdown,.hustoj-vditor-code{--hustoj-vditor-font-family:"Sarasa Mono SC Local","等距更纱黑体 SC","Sarasa Mono SC","Sarasa Fixed SC","Sarasa Gothic SC",Consolas,"Cascadia Mono","JetBrains Mono","Courier New",monospace;--hustoj-vditor-font-size:24px;--hustoj-vditor-preview-code-font-size:24px;}',
'.hustoj-vditor-markdown,.hustoj-vditor-markdown .vditor,.hustoj-vditor-markdown .vditor-content,.hustoj-vditor-markdown .vditor-ir,.hustoj-vditor-markdown .vditor-sv,.hustoj-vditor-markdown .vditor-reset,.hustoj-vditor-markdown .vditor-wysiwyg,.hustoj-vditor-markdown .vditor-sv__preview{text-align:left !important;}',
'.hustoj-vditor-markdown .vditor{margin-left:0 !important;margin-right:auto !important;}',
'.hustoj-vditor-markdown .vditor-toolbar{justify-content:flex-start;}',
'.hustoj-vditor-markdown .vditor-content,.hustoj-vditor-markdown .vditor-reset,.hustoj-vditor-markdown .vditor-reset *,.hustoj-vditor-markdown textarea{font-family:var(--hustoj-vditor-font-family) !important;}',
'.hustoj-vditor-code{text-align:left;}',
'.hustoj-vditor-code.ace_editor{position:relative;border:1px solid #d4d4d5;border-radius:6px;line-height:1.5;}',
'.hustoj-vditor-code .ace_scroller,',
'.hustoj-vditor-code .ace_gutter,',
'.hustoj-vditor-code .ace_content{font-family:var(--hustoj-vditor-font-family) !important;font-size:var(--hustoj-vditor-font-size) !important;line-height:1.5 !important;}',
'.hustoj-vditor-code .ace_content{font-family:Consolas,Monaco,"Courier New",monospace !important;font-size:var(--hustoj-vditor-font-size) !important;line-height:1.5 !important;}',
'.hustoj-vditor-code .ace_gutter{background:#f8f8f8;color:#8a8a8a;}',
'.hustoj-vditor-dark.ace_editor{background:#272822;border-color:#4a4a4a;}',
'.hustoj-vditor-dark .ace_gutter{background:#2f3129;color:#bcbcbc;}',
'.hustoj-vditor-dark .ace_print-margin{background:#3a3d34;}',
'.hustoj-vditor-preview{--hustoj-diagram-font-family:"Microsoft YaHei","PingFang SC","Hiragino Sans GB","Noto Sans CJK SC","Source Han Sans SC","WenQuanYi Micro Hei",Arial,sans-serif;--hustoj-diagram-font-size:14px;}',
'.hustoj-vditor-code .vditor-toolbar{display:none !important;}',
'.hustoj-vditor-code .vditor-reset,',
'.hustoj-vditor-code .vditor-content,',
'.hustoj-vditor-code .vditor,',
'.hustoj-vditor-code textarea{text-align:left !important;font-family:var(--hustoj-vditor-font-family) !important;font-size:var(--hustoj-vditor-font-size) !important;line-height:1.5 !important;}',
'.hustoj-vditor-code .vditor-sv,',
'.hustoj-vditor-code .vditor-ir{min-height:100%;}',
'.hustoj-vditor-dark .vditor{background:#272822;border-color:#4a4a4a;}',
'.hustoj-vditor-dark .vditor-reset,',
'.hustoj-vditor-dark .vditor-content,',
'.hustoj-vditor-dark textarea{color:#f8f8f2 !important;background:#272822 !important;}',
'.hustoj-vditor-dark .vditor-toolbar svg{fill:#f8f8f2;}',
'.hustoj-vditor-mail .vditor-toolbar{border-bottom:1px solid #ddd;}',
'.hustoj-vditor-mail .vditor{height:100%;min-height:180px;}',
'.hustoj-vditor-preview .vditor-reset pre{position:relative;margin:16px 0;padding:16px 18px;border:1px solid #cfd7e6;border-radius:12px;background:linear-gradient(180deg,#f9fbff 0%,#f3f7ff 100%);box-shadow:0 8px 20px rgba(15,23,42,0.06);}',
'.hustoj-vditor-preview .vditor-reset pre code{display:block;font-family:var(--hustoj-vditor-font-family) !important;font-size:var(--hustoj-vditor-preview-code-font-size) !important;line-height:1.7;}',
'.hustoj-vditor-preview .vditor-reset pre div.vditor-copy{display:block !important;opacity:1 !important;visibility:visible !important;position:absolute;top:12px;right:12px;z-index:2;}',
'.hustoj-vditor-preview .vditor-copy span{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid #c8d3e6;border-radius:999px;background:rgba(255,255,255,0.96);box-shadow:0 4px 12px rgba(15,23,42,0.08);font-size:12px;font-weight:600;color:#2f4f7f;position:static !important;}',
'.hustoj-vditor-preview .vditor-copy span::after{content:attr(aria-label);}',
'.hustoj-vditor-preview .vditor-copy svg{width:14px !important;height:14px !important;color:currentColor;}',
'.hustoj-vditor-preview .hustoj-vditor-sample-heading{display:flex;align-items:center;margin:24px 0 0;padding:12px 16px;border:1px solid #d6dde8;border-bottom:0;border-radius:14px 14px 0 0;background:#eef4ff;color:#274061;font-size:1.05em;font-weight:700;line-height:1.4;}',
'.hustoj-vditor-preview .vditor-reset pre.hustoj-vditor-sample-box{margin-top:0;border-top-left-radius:0;border-top-right-radius:0;border-top-color:#d6dde8;padding-top:52px;}',
'.hustoj-vditor-preview .vditor-reset .language-mermaid,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart{margin:18px 0;padding:14px;border:1px solid #d7dce5;border-radius:12px;background:#fff;overflow:auto;text-align:center;}',
'.hustoj-vditor-preview .vditor-reset .language-mermaid svg,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart svg{display:block;max-width:100%;height:auto !important;overflow:visible;}',
'.hustoj-vditor-preview .vditor-reset .language-mermaid foreignObject,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart foreignObject,',
'.hustoj-vditor-preview .vditor-reset .language-mermaid .label,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart .label{overflow:visible;}',
'.hustoj-vditor-preview .vditor-reset .language-mermaid .label div,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart .label div,',
'.hustoj-vditor-preview .vditor-reset .language-mermaid .edgeLabel,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart .edgeLabel{font-family:var(--hustoj-diagram-font-family) !important;font-size:var(--hustoj-diagram-font-size) !important;white-space:normal !important;line-height:1.4 !important;}',
'.hustoj-vditor-preview .vditor-reset .language-mermaid .nodeLabel,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart .nodeLabel,',
'.hustoj-vditor-preview .vditor-reset .language-mermaid .nodeLabel *,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart .nodeLabel *,',
'.hustoj-vditor-preview .vditor-reset .language-mermaid svg text,',
'.hustoj-vditor-preview .vditor-reset .language-mermaid svg tspan,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart svg text,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart svg tspan{font-family:var(--hustoj-diagram-font-family) !important;font-size:var(--hustoj-diagram-font-size) !important;font-variant-ligatures:none;text-rendering:geometricPrecision;}',
'.hustoj-vditor-preview .vditor-reset .language-mermaid .nodeLabel p,',
'.hustoj-vditor-preview .vditor-reset .language-flowchart .nodeLabel p{margin:0;line-height:1.4 !important;}'
'.hustoj-vditor-dark .ace_print-margin{background:#3a3d34;}'
].join('');
documentRef.head.appendChild(style);
styleInjected = true;
@@ -478,113 +416,6 @@
return previewOptions;
}
function decorateRenderedPreview(element) {
if (!element || !element.classList) {
return;
}
element.classList.add('hustoj-vditor-preview');
decorateSampleBlocks(element);
Array.prototype.forEach.call(
element.querySelectorAll('.language-mermaid, .language-flowchart'),
function (diagramContainer) {
Array.prototype.forEach.call(diagramContainer.querySelectorAll('svg'), function (svgElement) {
svgElement.style.maxWidth = '100%';
svgElement.style.height = 'auto';
svgElement.style.overflow = 'visible';
});
Array.prototype.forEach.call(
diagramContainer.querySelectorAll('foreignObject, .label, .label div, .edgeLabel, .nodeLabel, .nodeLabel p'),
function (node) {
if (node.tagName === 'FOREIGNOBJECT') {
node.style.overflow = 'visible';
}
if (node.tagName === 'DIV' || node.tagName === 'SPAN') {
node.style.whiteSpace = 'normal';
}
if (node.tagName === 'P') {
node.style.margin = '0';
node.style.lineHeight = '1.4';
}
if (node.classList && node.classList.contains('nodeLabel')) {
node.style.lineHeight = '1.4';
}
}
);
}
);
}
function normalizeHeadingText(text) {
return String(text || '').replace(/\s+/g, ' ').trim();
}
function parseSampleHeading(text) {
var normalized = normalizeHeadingText(text).replace(/[:]+$/, '');
var match = normalized.match(/^(?:(?:样例|示例|sample|example)\s*)?(输入|输出|input|output)\s*([0-9]+)?$/i);
var kind;
if (!match) {
return null;
}
kind = match[1].toLowerCase();
if (kind === '输入' || kind === 'input') {
kind = 'input';
} else {
kind = 'output';
}
return {
kind: kind,
index: match[2] || ''
};
}
function getSiblingCodeBlock(heading) {
var sibling = heading ? heading.nextElementSibling : null;
while (sibling && sibling.tagName === 'P' && !normalizeHeadingText(sibling.textContent)) {
sibling = sibling.nextElementSibling;
}
if (!sibling || sibling.tagName !== 'PRE') {
return null;
}
return sibling;
}
function decorateSampleBlocks(element) {
Array.prototype.forEach.call(element.querySelectorAll('h1, h2, h3, h4, h5, h6'), function (heading) {
var sampleMeta = parseSampleHeading(heading.textContent);
var codeBlock;
if (!sampleMeta) {
return;
}
codeBlock = getSiblingCodeBlock(heading);
if (!codeBlock) {
return;
}
heading.classList.add('hustoj-vditor-sample-heading');
heading.setAttribute('data-hustoj-sample-kind', sampleMeta.kind);
if (sampleMeta.index) {
heading.setAttribute('data-hustoj-sample-index', sampleMeta.index);
}
codeBlock.classList.add('hustoj-vditor-sample-box');
codeBlock.setAttribute('data-hustoj-sample-kind', sampleMeta.kind);
if (sampleMeta.index) {
codeBlock.setAttribute('data-hustoj-sample-index', sampleMeta.index);
}
});
}
function renderMarkdownBlocks(target, options) {
var renderOptions = options || {};
@@ -601,7 +432,6 @@
tasks.push(new Promise(function (resolve, reject) {
var previewOptions = buildPreviewOptions(renderOptions, function () {
decorateRenderedPreview(element);
if (typeof renderOptions.afterEach === 'function') {
renderOptions.afterEach(element, source);
}
@@ -820,7 +650,7 @@
state = {
theme: options.theme || 'ace/theme/chrome',
fontSize: parseInt(options.fontSize, 10) || 24,
fontSize: parseInt(options.fontSize, 10) || 18,
mode: normalizeMode(options.mode || ''),
wrap: true
};

View File

@@ -65,9 +65,6 @@
.ui.list .list > .item,
.ui.statistic > .value,
.ui.statistic > .label,
.vditor,
.vditor-reset,
.vditor-reset *,
.ace_editor,
.ace_editor textarea,
.ace_content,

View File

@@ -15,11 +15,11 @@
"Sarasa Gothic SC", Consolas, "Cascadia Mono", "Cascadia Code",
"Fira Mono", "JetBrains Mono", "Liberation Mono", Menlo, Monaco,
"Courier New", monospace;
--hustoj-global-font-size: 26px;
--hustoj-global-font-size: 24px;
--hustoj-global-line-height: 1.6;
--hustoj-global-code-font-size: 24px;
--hustoj-global-heading-size: 30px;
--hustoj-global-subheading-size: 28px;
--hustoj-global-heading-size: 24px;
--hustoj-global-subheading-size: 24px;
}
.ui.header,
@@ -96,9 +96,6 @@ h5,
.ui.list .list > .item,
.ui.statistic > .value,
.ui.statistic > .label,
.vditor,
.vditor-reset,
.vditor-reset *,
.ace_editor,
.ace_editor textarea,
.ace_content,
@@ -124,9 +121,6 @@ h5,
.ui.list .list > .item,
.ui.statistic > .value,
.ui.statistic > .label,
.vditor,
.vditor-reset,
.vditor-reset *,
pre,
code,
.ace_editor,
@@ -146,8 +140,7 @@ code,
.ace_gutter,
.ace_line,
.ace_text-layer,
.sample-box code,
.vditor-reset pre code {
.sample-box code {
font-size: var(--hustoj-global-code-font-size) !important;
}

View File

@@ -110,26 +110,6 @@
overflow-wrap: anywhere;
}
.docs-render .vditor-reset {
font-size: 16px;
line-height: 1.8;
}
.docs-render table tr td {
border: 1px solid #d1d5db;
text-align: center;
min-width: 120px;
height: 30px;
}
.docs-render table th {
border: 1px solid #d1d5db;
min-width: 120px;
height: 30px;
background-color: #eff6ff;
text-align: center;
}
@media (max-width: 991px) {
.docs-shell {
flex-direction: column;

View File

@@ -660,46 +660,9 @@ if ($pr_flag) {
$(document).ready(function () {
$("#creator").load("problem-ajax.php?pid=<?php echo $id ?>");
function addMarkdownInputOutputLabels() {
for (let i = 1; i < 10; i++) {
$(".language-input" + i).parent().each(function () {
if ($(this).prev('.hustoj-md-io-label').length === 0) {
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Input ?>" + i + ":</div>");
}
});
$(".language-output" + i).parent().each(function () {
if ($(this).prev('.hustoj-md-io-label').length === 0) {
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Output ?>" + i + ":</div>");
}
});
}
}
function styleMarkdownTables() {
$(".md table tr td").css({
"border": "1px solid grey",
"text-align": "center",
"width": "200px",
"height": "30px"
});
$(".md table th").css({
"border": "1px solid grey",
"width": "200px",
"height": "30px",
"background-color": "#9e9e9ea1",
"text-align": "center"
});
}
function renderProblemMarkdown() {
<?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
return HustOJVditor.renderMarkdownBlocks('.md').then(function () {
addMarkdownInputOutputLabels();
styleMarkdownTables();
$('.md .hustoj-vditor-sample-heading').addClass('ui top attached block header sample-header');
$('.md pre.hustoj-vditor-sample-box').addClass('ui bottom attached segment font-content sample-box');
});
return HustOJVditor.renderMarkdownBlocks('.md');
<?php } ?>
return Promise.resolve([]);
}