Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiaojiayu10
vue-element-admin
提交
67709636
V
vue-element-admin
项目概览
xiaojiayu10
/
vue-element-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
67709636
编写于
5月 21, 2019
作者:
花
花裤衩
提交者:
GitHub
5月 21, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf[Tinymce]: dynamic import tinymce(#2102)
上级
131b9b9e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
16 deletion
+57
-16
public/index.html
public/index.html
+0
-4
src/components/Tinymce/dynamicLoadScript.js
src/components/Tinymce/dynamicLoadScript.js
+39
-0
src/components/Tinymce/index.vue
src/components/Tinymce/index.vue
+18
-2
vue.config.js
vue.config.js
+0
-10
未找到文件。
public/index.html
浏览文件 @
67709636
...
...
@@ -9,10 +9,6 @@
<title><
%=
webpackConfig.name
%
></title>
</head>
<body>
<!-- import cdn js -->
<
%
for
(
var
js
of
htmlWebpackPlugin.options.cdn.js
)
{
%
>
<script
src=
"<%=js%>"
></script>
<
%
}
%
>
<div
id=
"app"
></div>
<!-- built files will be auto injected -->
</body>
...
...
src/components/Tinymce/dynamicLoadScript.js
0 → 100644
浏览文件 @
67709636
const
dynamicLoadScript
=
(
src
,
callback
)
=>
{
const
existingScript
=
document
.
getElementById
(
src
)
const
cb
=
callback
||
function
()
{}
if
(
!
existingScript
)
{
const
script
=
document
.
createElement
(
'
script
'
)
script
.
src
=
src
// src url for the third-party library being loaded.
script
.
id
=
src
document
.
body
.
appendChild
(
script
)
const
onEnd
=
'
onload
'
in
script
?
stdOnEnd
:
ieOnEnd
onEnd
(
script
,
cb
)
}
if
(
existingScript
&&
cb
)
cb
(
null
,
existingScript
)
function
stdOnEnd
(
script
,
cb
)
{
script
.
onload
=
function
()
{
// this.onload = null here is necessary
// because even IE9 works not like others
this
.
onerror
=
this
.
onload
=
null
cb
(
null
,
script
)
}
script
.
onerror
=
function
()
{
this
.
onerror
=
this
.
onload
=
null
cb
(
new
Error
(
'
Failed to load
'
+
src
),
script
)
}
}
function
ieOnEnd
(
script
,
cb
)
{
script
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
!==
'
complete
'
&&
this
.
readyState
!==
'
loaded
'
)
return
this
.
onreadystatechange
=
null
cb
(
null
,
script
)
// there is no way to catch loading errors in IE8
}
}
}
export
default
dynamicLoadScript
src/components/Tinymce/index.vue
浏览文件 @
67709636
...
...
@@ -15,6 +15,10 @@
import
editorImage
from
'
./components/EditorImage
'
import
plugins
from
'
./plugins
'
import
toolbar
from
'
./toolbar
'
import
load
from
'
./dynamicLoadScript
'
// why use this cdn, detail see https://github.com/PanJiaChen/tinymce-all-in-one
const
tinymceCDN
=
'
https://cdn.jsdelivr.net/npm/tinymce-all-in-one@4.9.3/tinymce.min.js
'
export
default
{
name
:
'
Tinymce
'
,
...
...
@@ -82,10 +86,12 @@ export default {
}
},
mounted
()
{
this
.
init
Tinymce
()
this
.
init
()
},
activated
()
{
this
.
initTinymce
()
if
(
window
.
tinymce
)
{
this
.
initTinymce
()
}
},
deactivated
()
{
this
.
destroyTinymce
()
...
...
@@ -94,6 +100,16 @@ export default {
this
.
destroyTinymce
()
},
methods
:
{
init
()
{
// dynamic load tinymce from cdn
load
(
tinymceCDN
,
(
err
)
=>
{
if
(
err
)
{
this
.
$message
.
error
(
err
.
message
)
return
}
this
.
initTinymce
()
})
},
initTinymce
()
{
const
_this
=
this
window
.
tinymce
.
init
({
...
...
vue.config.js
浏览文件 @
67709636
...
...
@@ -57,16 +57,6 @@ module.exports = {
}
},
chainWebpack
(
config
)
{
const
cdn
=
{
// inject tinymce into index.html
// why use this cdn, detail see https://github.com/PanJiaChen/tinymce-all-in-one
js
:
[
'
https://cdn.jsdelivr.net/npm/tinymce-all-in-one@4.9.3/tinymce.min.js
'
]
}
config
.
plugin
(
'
html
'
)
.
tap
(
args
=>
{
args
[
0
].
cdn
=
cdn
return
args
})
config
.
plugins
.
delete
(
'
preload
'
)
// TODO: need test
config
.
plugins
.
delete
(
'
prefetch
'
)
// TODO: need test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录