| <template lang="html"> |
| <div class="editor"> |
| |
| <div ref="toolbar" class="toolbar"> |
| </div> |
| |
| <div ref="editor" class="text"> |
| </div> |
| </div> |
| </template> |
| <script> |
| |
| import E from 'wangeditor' |
| import {getAction, postAction} from "@/api"; |
| import {ACCESS_TOKEN} from "@/store/KeyConstants"; |
| |
| import Vue from "vue"; |
| export default { |
| name: 'EditorBar', |
| data() { |
| return { |
| editor: null, |
| info_: null, |
| UploadVidio:'', |
| } |
| }, |
| model: { |
| prop: 'value', |
| event: 'change' |
| }, |
| props: { |
| value: { |
| type: String, |
| default: '' |
| }, |
| isClear: { |
| type: Boolean, |
| default: false |
| } |
| }, |
| watch: { |
| isClear(val) { |
| |
| if (val) { |
| this.editor.txt.clear() |
| this.info_ = null |
| } |
| }, |
| value: function(value) { |
| if (value !== this.editor.txt.html()) { |
| this.editor.txt.html(this.value) |
| } |
| }, |
| |
| }, |
| created() { |
| |
| getAction("/content/upload_url/"+1).then(res=>{ |
| this.UploadVidio=res.data |
| }).then(res=>{ |
| this.seteditor() |
| this.editor.txt.html(this.value) |
| }) |
| }, |
| |
| methods: { |
| seteditor() { |
| const token = Vue.ls.get(ACCESS_TOKEN); |
| |
| this.editor = new E(this.$refs.toolbar, this.$refs.editor) |
| |
| |
| this.editor.config.uploadImgServer = 'http://xcff.feizhisoft.com/api/v1/upload/picture' |
| this.editor.config.uploadImgHeaders = { |
| 'Authorization': `Bearer ` + token |
| } |
| this.editor.config.uploadFileName = 'file' |
| this.editor.config.uploadImgMaxSize = 2 * 1024 * 1024 |
| this.editor.config.uploadImgMaxLength = 6 |
| this.editor.config.uploadImgTimeout = 3 * 60 * 1000 |
| |
| |
| this.editor.config.menus = [ |
| 'head', |
| 'bold', |
| 'fontSize', |
| 'fontName', |
| 'italic', |
| 'underline', |
| 'strikeThrough', |
| 'foreColor', |
| 'backColor', |
| 'link', |
| 'list', |
| 'justify', |
| 'quote', |
| 'emoticon', |
| 'image', |
| 'table', |
| 'video', |
| 'code', |
| 'undo', |
| 'redo', |
| 'fullscreen' |
| ] |
| |
| this.editor.config.uploadImgHooks = { |
| fail: (xhr, editor, result) => { |
| |
| }, |
| success: (xhr, editor, result) => { |
| |
| }, |
| timeout: (xhr, editor) => { |
| |
| }, |
| error: (xhr, editor) => { |
| |
| }, |
| customInsert: (insertImg, result, editor) => { |
| |
| |
| |
| |
| |
| |
| let url = 'http://xcff.feizhisoft.com/'+ result.data |
| insertImg(url) |
| |
| } |
| } |
| this.editor.config.onchange = (html) => { |
| this.info_ = html |
| this.$emit('change', this.info_) |
| } |
| |
| this.editor.create() |
| } |
| } |
| } |
| </script> |
| |
| <style lang="css"> |
| .editor { |
| width: 100%; |
| margin: 0 auto; |
| position: relative; |
| z-index: 0; |
| } |
| .toolbar { |
| border: 1px solid #ccc; |
| } |
| .text { |
| border: 1px solid #ccc; |
| min-height: 500px; |
| } |
| </style> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!