3 files modified
1 files added
| | |
| | | } |
| | | |
| | | /** |
| | | * 上传图片 |
| | | * 上传封面图片 |
| | | * @return Json |
| | | */ |
| | | public function upload_cover_img(): Json { |
| | |
| | | } |
| | | return json($result); |
| | | } |
| | | |
| | | public function save_blog() { |
| | | try { |
| | | if (!request()->isPost()) { |
| | | throw new Exception('请求方式错误'); |
| | | } |
| | | $data = request()->post(); |
| | | |
| | | } catch (Exception $exc) { |
| | | $result = [ |
| | | 'code' => $exc->getCode(), |
| | | 'message' => $exc->getMessage(), |
| | | ]; |
| | | } |
| | | return json($result); |
| | | } |
| | | } |
| New file |
| | |
| | | <?php |
| | | |
| | | namespace app\admin\validate; |
| | | |
| | | use think\Validate; |
| | | |
| | | class Blog extends Validate { |
| | | |
| | | protected $rule = [ |
| | | 'title' => 'require', |
| | | 'menu_index' => 'require', |
| | | ]; |
| | | protected $message = [ |
| | | 'title.require' => '请填写菜单名称', |
| | | 'menu_index.require' => '请填写菜单索引', |
| | | ]; |
| | | |
| | | |
| | | } |
| | |
| | | <template v-if="addBlogForm.cover_img"> |
| | | <div> |
| | | <img :src="addBlogForm.cover_img" class="avatar" /> |
| | | <el-button type="danger" icon="Delete"></el-button> |
| | | <!-- <el-button type="danger" icon="Delete"></el-button> --> |
| | | </div> |
| | | </template> |
| | | <el-icon v-else class="avatar-uploader-icon"> |
| | |
| | | config: toolbarConfigEn, |
| | | mode: 'default', // or 'simple' |
| | | }) |
| | | </script> |
| | | <script> |
| | | /** |
| | | * 富文本编辑器 |
| | | */ |
| | | // var E = window.wangEditor |
| | | // const editor = new E('#editer_data') |
| | | // var textarea = $('#content') |
| | | |
| | | // editor.config.onchange = function (html) { |
| | | // // 监控变化,同步更新到 textarea |
| | | // textarea.val(html) |
| | | // } |
| | | |
| | | // // editor.config.onblur = function (html) { |
| | | // // // 编辑区域失去焦点后的操作,保存内容 |
| | | // // save_reading_data(); |
| | | // // } |
| | | |
| | | // //设置提示文字 |
| | | // editor.config.placeholder = '请输入文章内容...' |
| | | |
| | | // //设置编辑区域z-index |
| | | // editor.config.zIndex = 100 |
| | | |
| | | // // 自定义菜单配置 |
| | | // editor.config.menus = [ |
| | | // 'bold', |
| | | // 'fontSize', |
| | | // 'italic', |
| | | // 'underline', |
| | | // 'strikeThrough', |
| | | // 'indent', |
| | | // 'lineHeight', |
| | | // 'foreColor', |
| | | // 'backColor', |
| | | // 'link', |
| | | // 'list', |
| | | // 'justify', |
| | | // 'image', |
| | | // ] |
| | | |
| | | // //粘贴内容去掉图片 |
| | | // editor.config.pasteIgnoreImg = true |
| | | |
| | | // // 配置粘贴文本的内容处理 |
| | | // editor.config.pasteTextHandle = function (pasteStr) { |
| | | // // 对粘贴的文本进行处理,然后返回处理后的结果 |
| | | // return pasteStr.replace(/<[^>]+>/g, ""); |
| | | // } |
| | | |
| | | // //上传图片服务端地址 |
| | | // editor.config.uploadImgServer = "/admin/upload/index_v1.html" |
| | | |
| | | // // 隐藏“网络图片”tab |
| | | // editor.config.showLinkImg = false |
| | | |
| | | // // 将图片大小限制为 10M |
| | | // editor.config.uploadImgMaxSize = 20 * 1024 * 1024 |
| | | |
| | | // // 限制一次最多上传 20 张图片 |
| | | // editor.config.uploadImgMaxLength = 20 |
| | | |
| | | // //编辑器初始化 |
| | | // editor.create() |
| | | |
| | | // // 初始化 textarea 的值 |
| | | // textarea.val(editor.txt.html()) |
| | | ////////////////////////////////////////富文本编辑器-end////////////////////////////////// |
| | | </script> |
| | | |
| | | </html> |
| | |
| | | } |
| | | }, |
| | | |
| | | /////上传图片成功后///// |
| | | handleCoverImgSuccess(response, uploadFile) { |
| | | if (response.code != 200) { |
| | | this.$message({ |
| | |
| | | return false; |
| | | } |
| | | this.addBlogForm.cover_img = response.data.url; |
| | | // console.log(response,uploadFile); |
| | | // this.addBlogForm.cover_img = arguments[0].url; |
| | | }, |
| | | |
| | | handleRemove(){}, |
| | | |
| | | /////上传图片之前///// |
| | | beforeCoverImgUpload(rawFile) { |
| | | // console.log(rawFile); |
| | | if (rawFile.type !== 'image/jpeg') { |