WIN-2308041133\Administrator hai 8 meses
pai
achega
5c192154e5
Modificáronse 2 ficheiros con 24 adicións e 6 borrados
  1. 9 4
      app/admin/view/article/article/create.php
  2. 15 2
      app/models/article/Article.php

+ 9 - 4
app/admin/view/article/article/create.php

@@ -97,7 +97,8 @@
                <div class="form-group">
                    <div class="col-md-12">
                        <label style="color:#aaa">文章内容</label>
-                       <textarea type="text/plain" id="myEditor" style="width:100%;">{$news['content']}</textarea>
+<!--                       <textarea type="text/plain" id="myEditor" style="width:100%;">{$news['content']}</textarea>-->
+                       <textarea type="text/plain" id="myEditor" style="width:100%;">{$news['content']|raw}</textarea>
                    </div>
                </div>
                <div class="form-group">
@@ -168,8 +169,11 @@
 
             });
             //实例化编辑器
-            var um = UM.getEditor('myEditor');
-
+            // var um = UM.getEditor('myEditor');
+            var um = UM.getEditor('myEditor', {
+                autoTransWord: false,       // 关闭自动转义
+                allHtmlEnabled: true        // 允许所有HTML
+            });
             /**
             * 获取编辑器内的内容
             * */
@@ -231,7 +235,8 @@
                 list.title = $('#title').val();/* 标题 */
                 list.author = $('#author').val();/* 作者 */
                 list.image_input = $('#image_input').val();/* 图片 */
-                list.content = getContent();/* 内容 */
+                // list.content = getContent();/* 内容 */
+                list.content = UM.getEditor('myEditor').body.innerHTML;
                 list.synopsis = $('#synopsis').val();/* 简介 */
                 list.url = $('#url').val();/* 原文链接 */
                 list.id = $('#id').val();/* 原文链接 */

+ 15 - 2
app/models/article/Article.php

@@ -48,6 +48,18 @@ class Article extends BaseModel
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      */
+//    public static function getArticleOne($id = 0)
+//    {
+//        if (!$id) return [];
+//        $list = self::where('status', 1)->where('hide', 0)->where('id', $id)->order('id desc')->find();
+//        if ($list) {
+//            $list->store_info = $list->profile ? $list->profile->toArray() : null;
+//            $list = $list->hidden(['hide', 'status', 'admin_id', 'mer_id'])->toArray();
+//            $list["content"] = Db::name('articleContent')->where('nid', $id)->value('content');
+//            $list["content"] = htmlspecialchars_decode($list["content"]);
+//            return $list;
+//        } else return [];
+//    }
     public static function getArticleOne($id = 0)
     {
         if (!$id) return [];
@@ -55,12 +67,13 @@ class Article extends BaseModel
         if ($list) {
             $list->store_info = $list->profile ? $list->profile->toArray() : null;
             $list = $list->hidden(['hide', 'status', 'admin_id', 'mer_id'])->toArray();
+
+            // 修改这里:去除 htmlspecialchars_decode 调用
             $list["content"] = Db::name('articleContent')->where('nid', $id)->value('content');
-            $list["content"] = htmlspecialchars_decode($list["content"]);
+
             return $list;
         } else return [];
     }
-
     /**
      * TODO 获取某个分类底下的文章
      * @param $cid