Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
水玉婷
ai-wechat
Commits
0d0faeb5
Commit
0d0faeb5
authored
Dec 10, 2025
by
水玉婷
Browse files
feat:为md中图片添加新窗口打开功能
parent
eaf62b20
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/views/Home.vue
View file @
0d0faeb5
...
...
@@ -32,7 +32,6 @@
const
userInfo
=
localStorage
.
getItem
(
'
wechat_user
'
)
const
{
extMap
=
{}}
=
JSON
.
parse
(
userInfo
||
'
{}
'
)
const
userToken
=
extMap
.
sessionId
;
console
.
log
(
'
userToken
'
,
userToken
)
// 使用环境变量代替硬编码
const
appCode
=
import
.
meta
.
env
.
VITE_APP_CODE
||
'
ped.qywx
'
;
...
...
src/views/components/style.less
View file @
0d0faeb5
...
...
@@ -35,6 +35,12 @@
padding: 0;
margin: 0;
box-sizing: border-box;
// 禁止用户选择文本
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
// Webkit浏览器滚动条样式(Chrome, Safari, Edge)
&::-webkit-scrollbar {
...
...
@@ -1066,6 +1072,8 @@ li {
// Markdown图片容器样式
.markdown-image-container {
overflow: hidden;
border-radius: 8px;
img {
max-width: 100%;
height: auto;
...
...
src/views/components/utils/markdownTemplate.ts
View file @
0d0faeb5
...
...
@@ -94,8 +94,9 @@ export const parseMarkdown = (text: string): string => {
// 处理图片(必须在任何格式处理之前,避免图片格式被破坏)
text
=
text
.
replace
(
/!
\[([^\]]
*
)\]\(([^\)]
+
)\)
/g
,
(
match
,
alt
,
src
)
=>
{
const
altText
=
alt
||
'
图片
'
;
return
`<div class="markdown-image-container">
<img src="
${
src
}
" alt="
${
altText
}
">
const
imageId
=
'
img_
'
+
Math
.
random
().
toString
(
36
).
substr
(
2
,
9
);
return
`<div class="markdown-image-container" data-image-src="
${
src
}
">
<img src="
${
src
}
" alt="
${
altText
}
" style="cursor: pointer;" onclick="window.open('
${
src
}
', '_blank')">
${
alt
?
`<div class="image-caption">
${
alt
}
</div>`
:
''
}
</div>`
;
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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