Commit 0d0faeb5 authored by 水玉婷's avatar 水玉婷
Browse files

feat:为md中图片添加新窗口打开功能

parent eaf62b20
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
const userInfo = localStorage.getItem('wechat_user') const userInfo = localStorage.getItem('wechat_user')
const {extMap = {}} = JSON.parse(userInfo || '{}') const {extMap = {}} = JSON.parse(userInfo || '{}')
const userToken = extMap.sessionId; const userToken = extMap.sessionId;
console.log('userToken', userToken)
// 使用环境变量代替硬编码 // 使用环境变量代替硬编码
const appCode = import.meta.env.VITE_APP_CODE || 'ped.qywx'; const appCode = import.meta.env.VITE_APP_CODE || 'ped.qywx';
......
...@@ -35,6 +35,12 @@ ...@@ -35,6 +35,12 @@
padding: 0; padding: 0;
margin: 0; margin: 0;
box-sizing: border-box; box-sizing: border-box;
// 禁止用户选择文本
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
// Webkit浏览器滚动条样式(Chrome, Safari, Edge) // Webkit浏览器滚动条样式(Chrome, Safari, Edge)
&::-webkit-scrollbar { &::-webkit-scrollbar {
...@@ -1066,6 +1072,8 @@ li { ...@@ -1066,6 +1072,8 @@ li {
// Markdown图片容器样式 // Markdown图片容器样式
.markdown-image-container { .markdown-image-container {
overflow: hidden;
border-radius: 8px;
img { img {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
......
...@@ -94,8 +94,9 @@ export const parseMarkdown = (text: string): string => { ...@@ -94,8 +94,9 @@ export const parseMarkdown = (text: string): string => {
// 处理图片(必须在任何格式处理之前,避免图片格式被破坏) // 处理图片(必须在任何格式处理之前,避免图片格式被破坏)
text = text.replace(/!\[([^\]]*)\]\(([^\)]+)\)/g, (match, alt, src) => { text = text.replace(/!\[([^\]]*)\]\(([^\)]+)\)/g, (match, alt, src) => {
const altText = alt || '图片'; const altText = alt || '图片';
return `<div class="markdown-image-container"> const imageId = 'img_' + Math.random().toString(36).substr(2, 9);
<img src="${src}" alt="${altText}"> 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>` : ''} ${alt ? `<div class="image-caption">${alt}</div>` : ''}
</div>`; </div>`;
}); });
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment