Skip to content

Commit 7422c7d

Browse files
committed
前端增加富文本编辑起模块
1 parent 6c5c5b6 commit 7422c7d

File tree

10 files changed

+109
-3
lines changed

10 files changed

+109
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.idea
44
.vscode
55

6+
/backend/nbproject/private/

backend/app/Http/Controllers/Controller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Support\Facades\Route;
1212
use Rap2hpoutre\FastExcel\FastExcel;
1313
use Illuminate\Support\Facades\Validator;
14+
1415
/**
1516
* @SWG\Swagger(
1617
* basePath="/calculate-rates",

backend/nbproject/project.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
auxiliary.org-netbeans-modules-php-smarty.smarty-framework=false
2+
browser.reload.on.save=true
3+
include.path=${php.global.include.path}
4+
php.version=PHP_70
5+
source.encoding=UTF-8
6+
src.dir=.
7+
tags.asp=false
8+
tags.short=false
9+
web.root=.

backend/nbproject/project.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.php.project</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/php-project/1">
6+
<name>laravel</name>
7+
</data>
8+
</configuration>
9+
</project>

frontend/.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ module.exports = {
182182
'spaced-comment': [2, 'always', {
183183
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
184184
}],
185-
'template-curly-spacing': [2, 'never'],
185+
// 'template-curly-spacing': [2, 'never'],
186+
"template-curly-spacing": "off",
187+
'indent': "off",
186188
'use-isnan': 2,
187189
'valid-typeof': 2,
188190
'wrap-iife': [2, 'any'],

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
"path-to-regexp": "2.4.0",
2525
"screenfull": "^4.2.0",
2626
"socket.io-client": "^2.2.0",
27+
"tinymce": "^5.1.6",
2728
"v-contextmenu": "^2.8.0",
2829
"vue": "2.6.10",
2930
"vue-image-crop-upload": "^2.5.0",
3031
"vue-router": "3.0.6",
32+
"vue-runtime-helpers": "^1.1.2",
3133
"vuex": "3.1.0"
3234
},
3335
"devDependencies": {
@@ -47,7 +49,7 @@
4749
"eslint-plugin-vue": "5.2.2",
4850
"html-webpack-plugin": "3.2.0",
4951
"mockjs": "1.0.1-beta3",
50-
"node-sass": "^4.9.0",
52+
"node-sass": "^4.13.1",
5153
"runjs": "^4.3.2",
5254
"sass-loader": "^7.1.0",
5355
"script-ext-html-webpack-plugin": "2.1.3",

frontend/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
</noscript>
1414
<div id="app"></div>
1515
<!-- built files will be auto injected -->
16+
<script src="https://fe.120yibao.com/common/tinymce/5.0.13/tinymce.min.js"></script>
1617
</body>
1718
</html>

frontend/src/api/editor.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export function uploadImg(data) {
2+
return fetch({
3+
url: '/api/editor/upload',
4+
method: 'post',
5+
data,
6+
headers: {
7+
'Content-Type': 'multipart/form-data'
8+
}
9+
})
10+
}

frontend/src/router/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,19 @@ export const asyncRoutes = [
203203
title: '订单列表',
204204
icon: 'tab'
205205
}
206-
}]
206+
},
207+
{
208+
path: 'editor',
209+
name: 'editor_index',
210+
component: () => import('@/views/editor/index'),
211+
meta: {
212+
roles: ['editor.index'],
213+
title: '富文本',
214+
icon: 'tab'
215+
}
216+
},
217+
218+
]
207219
},
208220
{
209221
path: '/app',

frontend/src/views/editor/index.vue

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<template>
2+
<div class="default-tinymce">
3+
<textarea class="editor"></textarea>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import Tinymce from "tinymce";
9+
10+
export default {
11+
name: "editor_index",
12+
mounted() {
13+
Tinymce.init({
14+
selector: ".editor",
15+
language: "zh_CN",
16+
// 编辑器的皮肤,有 oxide oxide-dark
17+
// skin: 'oxide',
18+
// 编辑器宽高
19+
height: 600,
20+
// plugins: ['link'],
21+
//会自动引入silver主题
22+
// https://fe.120yibao.com/common/tinymce/5.0.13/themes/silver/theme.min.js
23+
theme: 'silver',
24+
//会自动引入oxide皮肤
25+
// https://fe.120yibao.com/common/tinymce/5.0.13/skins/ui/oxide/skin.min.css
26+
skin: "oxide",
27+
menubar: true,
28+
statusbar: false,
29+
// 用到的插件
30+
plugins: 'image',
31+
async images_upload_handler (blobInfo, success, fail) {
32+
const file = blobInfo.blob()
33+
console.log(file);
34+
35+
// try {
36+
// const url = self.YB.businessURL(await self.upload.post(file))
37+
// success(url)
38+
// } catch (e) {
39+
// fail(e.message || '上传失败,请重试')
40+
// }
41+
},
42+
autosave_interval: '30s',
43+
// 自动保存的数据存储的最大时间
44+
autosave_retention: '30m',
45+
// // 编辑区域内容样式
46+
// content_css: "css/content.css",
47+
// 工具栏的配置项
48+
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons",
49+
// toolbar: "code",
50+
// plugins: "numlist bullist",
51+
// toolbar: "lists",
52+
});
53+
}
54+
};
55+
</script>
56+
57+
<style lang="sass" scoped>
58+
59+
</style>

0 commit comments

Comments
 (0)