Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
d95815b5
提交
d95815b5
authored
7月 13, 2021
作者:
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(markdown): resolving markdown exceptions
修复markdown组件的异常以及不能正确设置value的问题
上级
0a3683a1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
54 行增加
和
27 行删除
+54
-27
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
Markdown.vue
src/components/Markdown/src/Markdown.vue
+41
-26
index.vue
src/views/demo/editor/markdown/index.vue
+12
-1
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
d95815b5
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
-
修复顶栏菜单在显示包含需要隐藏的菜单项目时出错的问题
-
修复顶栏菜单在显示包含需要隐藏的菜单项目时出错的问题
-
修复悬停触发模式下左侧混合菜单会在没有子菜单且被激活时直接跳转路由
-
修复悬停触发模式下左侧混合菜单会在没有子菜单且被激活时直接跳转路由
-
**Breadcrumb**
修复带有重定向的菜单点击无法跳转的问题
-
**Breadcrumb**
修复带有重定向的菜单点击无法跳转的问题
-
**Markdown**
修复初始化异常以及不能正确地动态设置 value 的问题
-
**其它**
-
**其它**
-
修复菜单默认折叠的配置不起作用的问题
-
修复菜单默认折叠的配置不起作用的问题
-
修复
`safari`
浏览器报错导致网站打不开
-
修复
`safari`
浏览器报错导致网站打不开
...
...
src/components/Markdown/src/Markdown.vue
浏览文件 @
d95815b5
...
@@ -5,18 +5,19 @@
...
@@ -5,18 +5,19 @@
import
{
import
{
defineComponent
,
defineComponent
,
ref
,
ref
,
onMounted
,
unref
,
unref
,
onUnmounted
,
nextTick
,
nextTick
,
computed
,
computed
,
watch
,
watch
,
onBeforeUnmount
,
onDeactivated
,
}
from
'vue'
;
}
from
'vue'
;
import
Vditor
from
'vditor'
;
import
Vditor
from
'vditor'
;
import
'vditor/dist/index.css'
;
import
'vditor/dist/index.css'
;
import
{
useLocale
}
from
'/@/locales/useLocale'
;
import
{
useLocale
}
from
'/@/locales/useLocale'
;
import
{
useModalContext
}
from
'../../Modal'
;
import
{
useModalContext
}
from
'../../Modal'
;
import
{
useRootSetting
}
from
'/@/hooks/setting/useRootSetting'
;
import
{
useRootSetting
}
from
'/@/hooks/setting/useRootSetting'
;
import
{
onMountedOrActivated
}
from
'/@/hooks/core/onMountedOrActivated'
;
type
Lang
=
'zh_CN'
|
'en_US'
|
'ja_JP'
|
'ko_KR'
|
undefined
;
type
Lang
=
'zh_CN'
|
'en_US'
|
'ja_JP'
|
'ko_KR'
|
undefined
;
...
@@ -26,7 +27,7 @@
...
@@ -26,7 +27,7 @@
height
:
{
type
:
Number
,
default
:
360
},
height
:
{
type
:
Number
,
default
:
360
},
value
:
{
type
:
String
,
default
:
''
},
value
:
{
type
:
String
,
default
:
''
},
},
},
emits
:
[
'change'
,
'get'
],
emits
:
[
'change'
,
'get'
,
'update:value'
],
setup
(
props
,
{
attrs
,
emit
})
{
setup
(
props
,
{
attrs
,
emit
})
{
const
wrapRef
=
ref
<
ElRef
>
(
null
);
const
wrapRef
=
ref
<
ElRef
>
(
null
);
const
vditorRef
=
ref
<
Nullable
<
Vditor
>>
(
null
);
const
vditorRef
=
ref
<
Nullable
<
Vditor
>>
(
null
);
...
@@ -36,17 +37,16 @@
...
@@ -36,17 +37,16 @@
const
{
getLocale
}
=
useLocale
();
const
{
getLocale
}
=
useLocale
();
const
{
getDarkMode
}
=
useRootSetting
();
const
{
getDarkMode
}
=
useRootSetting
();
const
valueRef
=
ref
(
''
);
watch
(
watch
(
[()
=>
getDarkMode
.
value
,
()
=>
initedRef
.
value
],
[()
=>
getDarkMode
.
value
,
()
=>
initedRef
.
value
],
([
val
])
=>
{
([
val
,
inited
])
=>
{
const
vditor
=
unref
(
vditorRef
);
if
(
!
inited
)
{
if
(
!
vditor
)
{
return
;
return
;
}
}
const
theme
=
val
===
'dark'
?
'dark'
:
undefined
;
const
theme
=
val
===
'dark'
?
'dark'
:
'classic'
;
vditor
.
setTheme
(
theme
as
'dark'
);
instance
.
getVditor
()?.
setTheme
(
theme
);
},
},
{
{
immediate
:
true
,
immediate
:
true
,
...
@@ -54,6 +54,16 @@
...
@@ -54,6 +54,16 @@
}
}
);
);
watch
(
()
=>
props
.
value
,
(
v
)
=>
{
if
(
v
!==
valueRef
.
value
)
{
instance
.
getVditor
()?.
setValue
(
v
);
valueRef
.
value
=
v
;
}
}
);
const
getCurrentLang
=
computed
(():
'zh_CN'
|
'en_US'
|
'ja_JP'
|
'ko_KR'
=>
{
const
getCurrentLang
=
computed
(():
'zh_CN'
|
'en_US'
|
'ja_JP'
|
'ko_KR'
=>
{
let
lang
:
Lang
;
let
lang
:
Lang
;
switch
(
unref
(
getLocale
))
{
switch
(
unref
(
getLocale
))
{
...
@@ -72,54 +82,59 @@
...
@@ -72,54 +82,59 @@
return
lang
;
return
lang
;
});
});
function
init
()
{
function
init
()
{
const
wrapEl
=
unref
(
wrapRef
);
const
wrapEl
=
unref
(
wrapRef
)
as
HTMLElement
;
if
(
!
wrapEl
)
return
;
if
(
!
wrapEl
)
return
;
const
bindValue
=
{
...
attrs
,
...
props
};
const
bindValue
=
{
...
attrs
,
...
props
};
vditorRef
.
value
=
new
Vditor
(
wrapEl
,
{
vditorRef
.
value
=
new
Vditor
(
wrapEl
,
{
theme
:
'classic'
,
theme
:
getDarkMode
.
value
===
'dark'
?
'dark'
:
'classic'
,
lang
:
unref
(
getCurrentLang
),
lang
:
unref
(
getCurrentLang
),
mode
:
'sv'
,
mode
:
'sv'
,
preview
:
{
preview
:
{
actions
:
[],
actions
:
[],
},
},
input
:
(
v
)
=>
{
input
:
(
v
)
=>
{
// emit('update:value', v);
valueRef
.
value
=
v
;
emit
(
'update:value'
,
v
);
emit
(
'change'
,
v
);
emit
(
'change'
,
v
);
},
},
after
:
()
=>
{
nextTick
(()
=>
{
modalFn
?.
redoModalHeight
?.();
initedRef
.
value
=
true
;
});
},
blur
:
()
=>
{
blur
:
()
=>
{
unref
(
vditorRef
)?.
setValue
(
props
.
value
);
//
unref(vditorRef)?.setValue(props.value);
},
},
...
bindValue
,
...
bindValue
,
cache
:
{
cache
:
{
enable
:
false
,
enable
:
false
,
},
},
});
});
initedRef
.
value
=
true
;
}
}
const
instance
=
{
const
instance
=
{
getVditor
:
():
Vditor
=>
vditorRef
.
value
!
,
getVditor
:
():
Vditor
=>
vditorRef
.
value
!
,
};
};
onMounted
(()
=>
{
function
destroy
()
{
nextTick
(()
=>
{
init
();
setTimeout
(()
=>
{
modalFn
?.
redoModalHeight
?.();
},
200
);
});
emit
(
'get'
,
instance
);
});
onUnmounted
(()
=>
{
const
vditorInstance
=
unref
(
vditorRef
);
const
vditorInstance
=
unref
(
vditorRef
);
if
(
!
vditorInstance
)
return
;
if
(
!
vditorInstance
)
return
;
try
{
try
{
vditorInstance
?.
destroy
?.();
vditorInstance
?.
destroy
?.();
}
catch
(
error
)
{}
}
catch
(
error
)
{}
vditorRef
.
value
=
null
;
}
onMountedOrActivated
(()
=>
{
nextTick
(()
=>
{
init
();
});
emit
(
'get'
,
instance
);
});
});
onBeforeUnmount
(
destroy
);
onDeactivated
(
destroy
);
return
{
return
{
wrapRef
,
wrapRef
,
...
instance
,
...
instance
,
...
...
src/views/demo/editor/markdown/index.vue
浏览文件 @
d95815b5
<
template
>
<
template
>
<PageWrapper
title=
"MarkDown组件示例"
>
<PageWrapper
title=
"MarkDown组件示例"
>
<a-button
@
click=
"toggleTheme"
class=
"mb-2"
type=
"primary"
>
黑暗主题
</a-button>
<a-button
@
click=
"toggleTheme"
class=
"mb-2"
type=
"primary"
>
黑暗主题
</a-button>
<MarkDown
:value=
"value"
@
change=
"handleChange"
ref=
"markDownRef"
/>
<a-button
@
click=
"clearValue"
class=
"mb-2"
type=
"default"
>
清空内容
</a-button>
<MarkDown
v-model:value=
"value"
@
change=
"handleChange"
ref=
"markDownRef"
placeholder=
"这是占位文本"
/>
</PageWrapper>
</PageWrapper>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
...
@@ -30,11 +36,16 @@
...
@@ -30,11 +36,16 @@
valueRef
.
value
=
v
;
valueRef
.
value
=
v
;
}
}
function
clearValue
()
{
valueRef
.
value
=
''
;
}
return
{
return
{
value
:
valueRef
,
value
:
valueRef
,
toggleTheme
,
toggleTheme
,
markDownRef
,
markDownRef
,
handleChange
,
handleChange
,
clearValue
,
};
};
},
},
});
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论