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
8fe357fc
Commit
8fe357fc
authored
Feb 28, 2026
by
水玉婷
Browse files
feat:登陆不取缓存+md处理代码块
parent
b36cf82d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/views/Login.vue
View file @
8fe357fc
...
...
@@ -47,12 +47,12 @@ export default {
}
onMounted
(()
=>
{
// 检查是否已登录
const
status
=
wechat
.
checkLoginStatus
()
if
(
status
.
isLoggedIn
)
{
router
.
replace
(
'
/
'
)
return
}
//
//
检查是否已登录
//
const status = wechat.checkLoginStatus()
//
if (status.isLoggedIn) {
//
router.replace('/')
//
return
//
}
// 执行静默登录
handleLogin
()
...
...
src/views/components/utils/markdownTemplate.ts
View file @
8fe357fc
...
...
@@ -26,7 +26,7 @@ const processMarkdownFormat = (text: string): string => {
processedText
=
processedText
.
replace
(
/~~
(
.*
?)
~~/gim
,
'
<del>$1</del>
'
);
// 处理行内代码
processedText
=
processedText
.
replace
(
/`
([^
`
]
+
)
`/gim
,
'
<code>$1</code>
'
);
processedText
=
processedText
.
replace
(
/`
([^
`
\n
]
+
)
`/gim
,
'
<code>$1</code>
'
);
return
processedText
;
};
...
...
@@ -84,17 +84,16 @@ export const parseMarkdown = (text: string): string => {
// 处理引用块(必须在HTML转义之前,避免>被转义为>)
// 改进的多行引用块处理,支持连续引用行
text
=
text
.
replace
(
/^>
\s
*
(
.*
(?:\n
>
\s
*.*
)
*
)
$/gim
,
(
match
,
content
)
=>
{
text
=
text
.
replace
(
/^>
\s
*
(
.*
(?:\n
>
\s
*.*
)
*
)
$/gim
,
(
_
match
,
content
)
=>
{
// 将多行引用内容合并,并用<br>分隔
const
lines
=
content
.
split
(
/
\n
>
\s
*/
);
const
processedContent
=
lines
.
map
(
line
=>
line
.
trim
()).
join
(
'
<br/>
'
);
const
processedContent
=
lines
.
map
(
(
line
:
string
)
=>
line
.
trim
()).
join
(
'
<br/>
'
);
return
`<blockquote>
${
processedContent
}
</blockquote>`
;
});
// 处理图片(必须在任何格式处理之前,避免图片格式被破坏)
text
=
text
.
replace
(
/!
\[([^\]]
*
)\]\(([^\)]
+
)\)
/g
,
(
match
,
alt
,
src
)
=>
{
text
=
text
.
replace
(
/!
\[([^\]]
*
)\]\(([^\)]
+
)\)
/g
,
(
_
match
,
alt
,
src
)
=>
{
const
altText
=
alt
||
'
图片
'
;
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>`
:
''
}
...
...
@@ -155,12 +154,12 @@ export const parseMarkdown = (text: string): string => {
}
});
// 使用统一的Markdown格式处理函数处理基础格式(包括标题)
text
=
processMarkdownFormat
(
text
);
// 处理代码块(支持语言标识)- 必须在换行处理之前
// 处理代码块(支持语言标识)- 必须在行内代码处理之前
text
=
text
.
replace
(
/```
(\w
+
)?\n([\s\S]
*
?)
```/gim
,
'
<pre><code class="language-$1">$2</code></pre>
'
);
text
=
text
.
replace
(
/```
([\s\S]
*
?)
```/gim
,
'
<pre><code>$1</code></pre>
'
);
text
=
text
.
replace
(
/```
\s
*
([\s\S]
*
?)
```/gim
,
'
<pre><code>$1</code></pre>
'
);
// 使用统一的Markdown格式处理函数处理基础格式(包括标题、行内代码等)
text
=
processMarkdownFormat
(
text
);
// 处理链接(支持相对路径和绝对路径)
text
=
text
.
replace
(
/
\[([^\]]
+
)\]\(([^
)
]
+
)\)
/gim
,
(
match
,
text
,
url
)
=>
{
...
...
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