Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
f8e7255c
Commit
f8e7255c
authored
Jan 04, 2026
by
yangjianbo
Browse files
feat(界面): 为 Gemini 配置片段添加语法高亮
补齐高亮渲染并保留纯文本回退 新增高亮 token 工具并做 HTML 转义
parent
5dd8b880
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/keys/UseKeyModal.vue
View file @
f8e7255c
...
@@ -107,7 +107,10 @@
...
@@ -107,7 +107,10 @@
</button>
</button>
</div>
</div>
<!-- Code Content -->
<!-- Code Content -->
<pre
class=
"p-4 text-sm font-mono text-gray-100 overflow-x-auto"
><code
v-text=
"file.content"
></code></pre>
<pre
class=
"p-4 text-sm font-mono text-gray-100 overflow-x-auto"
>
<code
v-if=
"file.highlighted"
v-html=
"file.highlighted"
></code>
<code
v-else
v-text=
"file.content"
></code>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -165,6 +168,7 @@ interface FileConfig {
...
@@ -165,6 +168,7 @@ interface FileConfig {
path
:
string
path
:
string
content
:
string
content
:
string
hint
?:
string
// Optional hint message for this file
hint
?:
string
// Optional hint message for this file
highlighted
?:
string
}
}
const
props
=
defineProps
<
Props
>
()
const
props
=
defineProps
<
Props
>
()
...
@@ -310,6 +314,22 @@ const platformNote = computed(() => {
...
@@ -310,6 +314,22 @@ const platformNote = computed(() => {
}
}
})
})
const
escapeHtml
=
(
value
:
string
)
=>
value
.
replace
(
/&/g
,
'
&
'
)
.
replace
(
/</g
,
'
<
'
)
.
replace
(
/>/g
,
'
>
'
)
.
replace
(
/"/g
,
'
"
'
)
.
replace
(
/'/g
,
'
'
'
)
const
wrapToken
=
(
className
:
string
,
value
:
string
)
=>
`<span class="
${
className
}
">
${
escapeHtml
(
value
)}
</span>`
const
keyword
=
(
value
:
string
)
=>
wrapToken
(
'
text-emerald-300
'
,
value
)
const
variable
=
(
value
:
string
)
=>
wrapToken
(
'
text-sky-200
'
,
value
)
const
operator
=
(
value
:
string
)
=>
wrapToken
(
'
text-slate-400
'
,
value
)
const
string
=
(
value
:
string
)
=>
wrapToken
(
'
text-amber-200
'
,
value
)
const
comment
=
(
value
:
string
)
=>
wrapToken
(
'
text-slate-500
'
,
value
)
// Syntax highlighting helpers
// Syntax highlighting helpers
// Generate file configs based on platform and active tab
// Generate file configs based on platform and active tab
const
currentFiles
=
computed
(():
FileConfig
[]
=>
{
const
currentFiles
=
computed
(():
FileConfig
[]
=>
{
...
@@ -382,9 +402,9 @@ ${keyword('export')} ${variable('GEMINI_MODEL')}${operator('=')}${string(`"${mod
...
@@ -382,9 +402,9 @@ ${keyword('export')} ${variable('GEMINI_MODEL')}${operator('=')}${string(`"${mod
content
=
`set GOOGLE_GEMINI_BASE_URL=
${
baseUrl
}
content
=
`set GOOGLE_GEMINI_BASE_URL=
${
baseUrl
}
set GEMINI_API_KEY=
${
apiKey
}
set GEMINI_API_KEY=
${
apiKey
}
set GEMINI_MODEL=
${
model
}
`
set GEMINI_MODEL=
${
model
}
`
highlighted
=
`
${
keyword
(
'
set
'
)}
${
variable
(
'
GOOGLE_GEMINI_BASE_URL
'
)}${
operator
(
'
=
'
)}${
baseUrl
}
highlighted
=
`
${
keyword
(
'
set
'
)}
${
variable
(
'
GOOGLE_GEMINI_BASE_URL
'
)}${
operator
(
'
=
'
)}${
string
(
baseUrl
)
}
${
keyword
(
'
set
'
)}
${
variable
(
'
GEMINI_API_KEY
'
)}${
operator
(
'
=
'
)}${
apiKey
}
${
keyword
(
'
set
'
)}
${
variable
(
'
GEMINI_API_KEY
'
)}${
operator
(
'
=
'
)}${
string
(
apiKey
)
}
${
keyword
(
'
set
'
)}
${
variable
(
'
GEMINI_MODEL
'
)}${
operator
(
'
=
'
)}${
model
}
${
keyword
(
'
set
'
)}
${
variable
(
'
GEMINI_MODEL
'
)}${
operator
(
'
=
'
)}${
string
(
model
)
}
${
comment
(
`REM
${
modelComment
}
`
)}
`
${
comment
(
`REM
${
modelComment
}
`
)}
`
break
break
case
'
powershell
'
:
case
'
powershell
'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment