diff --git a/src/assets/styles/codePreview.scss b/src/assets/styles/codePreview.scss index 32d6e6d3bfc72000982ef4b6f5cf4aea2a05cd09..2dc303b3f3d764fbccce63c1e39beb4a7bb059d2 100644 --- a/src/assets/styles/codePreview.scss +++ b/src/assets/styles/codePreview.scss @@ -3,6 +3,7 @@ color: var(--o-text-color-secondary); font-size: 14px; font-family: + SFMono-Regular, monospace, 'Courier New', Courier, @@ -53,6 +54,7 @@ .hljs-function { font-size: 14px; font-family: + SFMono-Regular, monospace, 'Courier New', Courier, @@ -69,6 +71,31 @@ 'IBM Plex Mono'; } + /* 支持行内代码渲染 */ + .inline-code { + background-color: var(--o-bash-bg); + color: var(--o-text-color-secondary); + padding: 0.2em 0.4em; + border-radius: 6px; + font-family: + SFMono-Regular, + monospace, + 'Courier New', + Courier, + Consolas, + 'Andale Mono WT', + 'Andale Mono', + 'Lucida Console', + 'DejaVu Sans Mono', + 'Bitstream Vera Sans Mono', + 'Liberation Mono', + Monaco, + 'Source Code Pro', + 'Fira Mono', + 'IBM Plex Mono'; + font-size: 0.9em; + } + p { font-size: 16px; font-weight: 400; @@ -146,6 +173,7 @@ white-space: pre-wrap; /* 保持缩进同时允许换行 */ margin: 8px 0px; .code-toolbar { + user-select: none; background-color: var(--o-bash-bg); color: var(--o-text-color-primarys); display: flex; diff --git a/src/components/dialoguePanel/FlowCode.vue b/src/components/dialoguePanel/FlowCode.vue index b099dc56b60cfed67dd65926004c313696aec9e8..63faf38b869f13a954d64012ad274f2123e10810 100644 --- a/src/components/dialoguePanel/FlowCode.vue +++ b/src/components/dialoguePanel/FlowCode.vue @@ -120,7 +120,6 @@ onMounted(() => { } .json-display { font-family: Arial, sans-serif; - /* max-width: 600px; */ margin: 0 auto; } @@ -181,9 +180,9 @@ pre { white-space: pre-wrap; /* 保持缩进同时允许换行 */ margin: 8px 0px; border: 1px solid black; - /* max-height: 300px; */ overflow-y: scroll; .code-toolbar { + user-select: none; background-color: var(--o-bash-bg); color: var(--o-text-color-primarys); display: flex; diff --git a/src/utils/marked.ts b/src/utils/marked.ts index 2677e495af5f652e699b07c958cc9b92b340a1c6..b2c2e60f53f8d4bd2310bc744fd95edd61158af9 100644 --- a/src/utils/marked.ts +++ b/src/utils/marked.ts @@ -49,6 +49,10 @@ renderer.code = function ({ text, lang }) { const id = `pre-${Date.now()}-${randomInt()}`; return `
${text}
`;
};
+// 支持行内代码渲染
+renderer.codespan = function ({ text }) {
+ return `${text}
`;
+};
renderer.link = function ({ href, title, tokens }) {
const text = this.parser.parseInline(tokens);
if (href === title) {