Skip to content

Commit

Permalink
ueditor demo
Browse files Browse the repository at this point in the history
  • Loading branch information
daxiongYang committed May 25, 2018
1 parent fc89d85 commit dfff102
Show file tree
Hide file tree
Showing 282 changed files with 97,792 additions and 33 deletions.
3 changes: 2 additions & 1 deletion build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module.exports = {
// 引入外部库, 无需webpack打包处理
externals: {
mockjs: 'Mock',
echarts: 'echarts'
echarts: 'echarts',
ueditor: 'UE'
}
}
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<script src="./static/config/index.js"></script>
<script src="./static/plugins/mock-1.0.0-beta3/mock-min.js"></script>
<script src="./static/plugins/echarts-3.8.5/echarts.common.min.js"></script>
<script src="./static/plugins/ueditor-1.4.3.3/ueditor.config.js"></script>
<script src="./static/plugins/ueditor-1.4.3.3/ueditor.all.min.js"></script>
<script src="./static/plugins/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js"></script>
<% } %>
</head>
<body>
Expand Down
6 changes: 2 additions & 4 deletions src/assets/scss/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ img {
}
}
> .el-tabs__content {
position: relative;
z-index: 920;
padding: 0 15px 15px;
> .site-tabs__tools {
position: fixed;
Expand All @@ -356,7 +358,3 @@ img {
}
}
}


/* Dropdown
------------------------------ */
4 changes: 2 additions & 2 deletions src/element-ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
TabPane,
Tag,
Tree,
// Alert,
Alert,
// Slider,
// Icon,
Row,
Expand Down Expand Up @@ -117,7 +117,7 @@ Vue.use(Tabs)
Vue.use(TabPane)
Vue.use(Tag)
Vue.use(Tree)
// Vue.use(Alert)
Vue.use(Alert)
// Vue.use(Slider)
// Vue.use(Icon)
Vue.use(Row)
Expand Down
1 change: 1 addition & 0 deletions src/icons/svg/icon-editor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const mainRoutes = {
// 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理!
{ path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页' } },
{ path: '/theme', component: _import('common/theme'), name: 'theme', meta: { title: '主题' } },
{ path: '/demo-echarts', component: _import('demo/echarts'), name: 'demo-echarts', meta: { title: 'demo-图表', isTab: true } }
{ path: '/demo-echarts', component: _import('demo/echarts'), name: 'demo-echarts', meta: { title: 'demo-echarts', isTab: true } },
{ path: '/demo-ueditor', component: _import('demo/ueditor'), name: 'demo-ueditor', meta: { title: 'demo-ueditor', isTab: true } }
],
beforeEnter (to, from, next) {
let token = Vue.cookie.get('token')
Expand Down
71 changes: 51 additions & 20 deletions src/views/demo/echarts.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<template>
<div class="mod-demo-echarts">
<el-alert
title="提示:"
type="warning"
description="1. 此Demo只提供ECharts官方使用文档,入门部署和体验功能。具体使用请参考:http://echarts.baidu.com/index.html"
:closable="false"
style="margin-bottom: 10px;">
</el-alert>

<el-row :gutter="20">
<el-col :span="24">
<el-card>
Expand Down Expand Up @@ -28,15 +36,38 @@
<script>
import echarts from 'echarts'
export default {
data () {
return {
chartLine: null,
chartBar: null,
chartPie: null,
chartScatter: null
}
},
mounted () {
this.chartLine()
this.chartBar()
this.chartPie()
this.chartScatter()
this.initChartLine()
this.initChartBar()
this.initChartPie()
this.initChartScatter()
},
activated () {
// 由于给echart添加了resize事件, 在组件激活时需要重新resize绘画一次, 否则出现空白bug
if (this.chartLine) {
this.chartLine.resize()
}
if (this.chartBar) {
this.chartBar.resize()
}
if (this.chartPie) {
this.chartPie.resize()
}
if (this.chartScatter) {
this.chartScatter.resize()
}
},
methods: {
// 折线图
chartLine () {
initChartLine () {
var option = {
'title': {
'text': '折线图堆叠'
Expand Down Expand Up @@ -99,14 +130,14 @@
}
]
}
var chart = echarts.init(document.getElementById('J_chartLineBox'))
chart.setOption(option)
this.chartLine = echarts.init(document.getElementById('J_chartLineBox'))
this.chartLine.setOption(option)
window.addEventListener('resize', () => {
chart.resize()
this.chartLine.resize()
})
},
// 柱状图
chartBar () {
initChartBar () {
var option = {
tooltip: {
trigger: 'axis',
Expand Down Expand Up @@ -200,14 +231,14 @@
}
]
}
var chart = echarts.init(document.getElementById('J_chartBarBox'))
chart.setOption(option)
this.chartBar = echarts.init(document.getElementById('J_chartBarBox'))
this.chartBar.setOption(option)
window.addEventListener('resize', () => {
chart.resize()
this.chartBar.resize()
})
},
// 饼状图
chartPie () {
initChartPie () {
var option = {
backgroundColor: '#2c343c',
title: {
Expand Down Expand Up @@ -276,14 +307,14 @@
}
]
}
var chart = echarts.init(document.getElementById('J_chartPieBox'))
chart.setOption(option)
this.chartPie = echarts.init(document.getElementById('J_chartPieBox'))
this.chartPie.setOption(option)
window.addEventListener('resize', () => {
chart.resize()
this.chartPie.resize()
})
},
// 散点图
chartScatter () {
initChartScatter () {
var option = {
backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
{ offset: 0, color: '#f7f8fa' },
Expand Down Expand Up @@ -410,10 +441,10 @@
}
]
}
var chart = echarts.init(document.getElementById('J_chartScatterBox'))
chart.setOption(option)
this.chartPie = echarts.init(document.getElementById('J_chartScatterBox'))
this.chartPie.setOption(option)
window.addEventListener('resize', () => {
chart.resize()
this.chartPie.resize()
})
}
}
Expand Down
55 changes: 55 additions & 0 deletions src/views/demo/ueditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<div class="mod-demo-ueditor">
<el-alert
title="提示:"
type="warning"
:closable="false"
style="margin-bottom: 10px;">
<div slot-scope="description">
<p class="el-alert__description">1. 此Demo只提供UEditor官方使用文档,入门部署和体验功能。具体使用请参考:http://fex.baidu.com/ueditor/</p>
<p class="el-alert__description">2. 浏览器控制台报错“请求后台配置项http错误,上传功能将不能正常使用!”,此错需要后台提供上传接口方法(赋值给serverUrl属性)</p>
</div>
</el-alert>

<script id="J_ueditorBox" class="ueditor-box" type="text/plain" style="width: 100%; height: 260px;">hello world!</script>

<!-- 获取内容 -->
<p><el-button @click="getContent()">获得内容</el-button></p>
<el-dialog
title="内容"
:visible.sync="dialogVisible"
:append-to-body="true">
{{ ueContent }}
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
</span>
</el-dialog>
</div>
</template>

<script>
import ueditor from 'ueditor'
export default {
data () {
return {
ue: null,
ueContent: '',
dialogVisible: false
}
},
mounted () {
this.ue = ueditor.getEditor('J_ueditorBox', {
// serverUrl: '', // 服务器统一请求接口路径
zIndex: 3000
})
},
methods: {
getContent () {
this.dialogVisible = true
this.ue.ready(() => {
this.ueContent = this.ue.getContent()
})
}
}
}
</script>
4 changes: 4 additions & 0 deletions src/views/main-sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg>
<span slot="title">echarts</span>
</el-menu-item>
<el-menu-item index="demo-ueditor" @click="$router.push({ name: 'demo-ueditor' })">
<icon-svg name="editor" class="site-sidebar__menu-icon"></icon-svg>
<span slot="title">ueditor</span>
</el-menu-item>
</el-submenu>
<sub-menu
v-for="menu in menuList"
Expand Down
2 changes: 1 addition & 1 deletion static/config/index-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
// cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './'; // 域名
window.SITE_CONFIG['version'] = ''; // 版本号(年月日时分)
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version;
})();
2 changes: 1 addition & 1 deletion static/config/index-qa.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
// cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './'; // 域名
window.SITE_CONFIG['version'] = ''; // 版本号(年月日时分)
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version;
})();
2 changes: 1 addition & 1 deletion static/config/index-uat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
// cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './'; // 域名
window.SITE_CONFIG['version'] = ''; // 版本号(年月日时分)
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version;
})();
2 changes: 1 addition & 1 deletion static/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
// cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './'; // 域名
window.SITE_CONFIG['version'] = ''; // 版本号(年月日时分)
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version
window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version;
})();
7 changes: 6 additions & 1 deletion static/config/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
window.SITE_CONFIG.cdnUrl + '/static/css/app.css',
],
js: [
// 插件(放置业务之前加载, 以免业务需求依赖插件时, 还未加载出错)
// 插件, 放置业务之前加载, 以免业务需求依赖插件时, 还未加载出错
// 插件 - echarts
window.SITE_CONFIG.cdnUrl + '/static/plugins/echarts-3.8.5/echarts.common.min.js',
// 插件 - ueditor
window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/ueditor.config.js',
window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/ueditor.all.min.js',
window.SITE_CONFIG.cdnUrl + '/static/plugins/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js',
// 业务
window.SITE_CONFIG.cdnUrl + '/static/js/manifest.js',
window.SITE_CONFIG.cdnUrl + '/static/js/vendor.js',
Expand Down
40 changes: 40 additions & 0 deletions static/plugins/ueditor-1.4.3.3/dialogs/anchor/anchor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
*{color: #838383;margin: 0;padding: 0}
html,body {font-size: 12px;overflow: hidden; }
.content{padding:5px 0 0 15px;}
input{width:210px;height:21px;line-height:21px;margin-left: 4px;}
</style>
</head>
<body>
<div class="content">
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value="" />
</div>
<script type="text/javascript" src="../internal.js"></script>
<script type="text/javascript">
var anchorInput = $G('anchorName'),
node = editor.selection.getRange().getClosedNode();
if(node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))){
anchorInput.value = node;
}
anchorInput.onkeydown = function(evt){
evt = evt || window.event;
if(evt.keyCode == 13){
editor.execCommand('anchor', anchorInput.value);
dialog.close();
domUtils.preventDefault(evt)
}
};
dialog.onok = function (){
editor.execCommand('anchor', anchorInput.value);
dialog.close();
};
$focus(anchorInput);
</script>
</body>
</html>
Loading

0 comments on commit dfff102

Please sign in to comment.