huwhois 5 months ago
parent
commit
5a42c71d34

+ 24 - 13
app/controller/sys/Article.php

@@ -12,16 +12,13 @@ declare(strict_types=1);
 namespace app\controller\sys;
 
 // 引入框架内置类
-
-use app\facade\FileFacade;
 use think\Exception;
 use think\facade\Db;
-use think\facade\Config;
 use think\facade\View;
 
-
 use app\model\Category as CategoryModel;
 use app\model\Article as ArticleModel;
+use app\model\TagArticle As TagArticleModel;
 use app\utils\FileUtils;
 use app\utils\ReUtils;
 
@@ -62,27 +59,43 @@ class Article extends Base
                 $this->error("标题不能为空");
             }
 
+            if ($params['titlepic'] && preg_match('/(http[s]:\/\/.*)/isU', $params['titlepic'])) {
+                $params['titlepic'] = FileUtils::downloadUrlImg($params['titlepic']);
+            }
+
             $params['content'] =  isset($params['content']) ? $params['content'] : '';
-            
+
             $params['content'] = $this->saveRomteImage($params['content']);
 
             $params['keywords'] = trim($params['keywords']);
 
             try {
                 if ($params['id'] != 0) {
-                    ArticleModel::update($params);
+                    $oldKeywords = ArticleModel::getKeywordsById((int) $params['id']);
+                    $article = ArticleModel::update($params);
+                    $oldTags = explode(",", $oldKeywords);
+                    $newTags = explode(",", $article->keywords);
+
+                    $addTas = array_diff($newTags, $oldTags);
+                    $subTas = array_diff($oldTags, $newTags);
+                    TagArticleModel::saveArticleTag($addTas, $article->id, $article->cid);
+                    TagArticleModel::delArticleTag($subTas, $article->id);
                 } else {
                     $params['userid'] = $this->getSysUser()->userid;
-                    $params['username'] = $this->getSysUser()->nickname ?? $this->getSysUser()->username;
+                    $params['username'] = $this->getSysUser()->nickname == "" ?: $this->getSysUser()->username;
                     unset($params['id']);
-                    ArticleModel::create($params);
+                    $article = ArticleModel::create($params);
+
+                    $tags = explode(",", $article->keywords);
+
+                    TagArticleModel::saveArticleTag($tags, $article->id, $article->cid);
                 }
             } catch (\Exception $e) {
                 $msg = $e->getMessage();
 
                 $this->error("错误提示:" . $msg);
             }
-            $this->success('操作成功', (string) url('index?cid=' . $params['cid']));
+            $this->success('操作成功', (string) url('/sys/article/index'));
         } else {
             if ($id) {
                 $data = ArticleModel::find($id);
@@ -91,11 +104,10 @@ class Article extends Base
                 $data->content_type = $content_type;
             }
 
-            $data->cjid = time();
-
             $categories = CategoryModel::field('id, parent_id, name')->select();
 
             View::assign('category_tree', list_tree($categories));
+
             View::assign('data', $data);
 
             $template = $content_type ? 'savemd' : 'save';
@@ -120,7 +132,6 @@ class Article extends Base
 
             $content = str_replace($value, $filename, $content);
         }
-
         return $content;
     }
 
@@ -133,7 +144,7 @@ class Article extends Base
 
         $idss = implode(',', $ids);
 
-        $sql = "update " . $tablename . " set cid=". $cid ." where id IN (" . $idss . ");";
+        $sql = "update " . $tablename . " set cid=" . $cid . " where id IN (" . $idss . ");";
 
         try {
             Db::execute($sql);

+ 6 - 2
app/controller/sys/FileManager.php

@@ -62,11 +62,15 @@ class FileManager extends Base
                     )->check(['file' => $file]);
 
                     $savename = \think\facade\Filesystem::disk('public')->putFile('/', $file);
+                    
+                    $urlpath = Config::get('filesystem.disks.public.url');
+
+                    $pictureurl = str_replace("\\", "/", $urlpath . '/' . $savename);
 
                     return json([
                         'uploaded' => 1,
                         'fileName' => basename($savename),
-                        'url' => Config::get('filesystem.disks.public.url') . '/' . $savename
+                        'url' => $pictureurl
                     ]);
                 } catch (\think\exception\ValidateException $e) {
                     $this->error($e->getMessage());
@@ -191,7 +195,7 @@ class FileManager extends Base
      * @param int $height       缩略图最大高
      * @param bool $overwrite   生成缩略图后是否保存原图
      */
-    public function uploadUrlImg(string $img_id = 'picture', $thumb = false, $width = 400, $height = 300,
+    public function uploadUrlImage(string $img_id = 'picture', $thumb = false, $width = 400, $height = 300,
         $original = false, $id = 0, $cjid = 0)
     {
         if ($this->request->isPost()) {

+ 1 - 1
app/event.php

@@ -10,7 +10,7 @@ return [
         'HttpEnd'  => [],
         'LogLevel' => [],
         'LogWrite' => [],
-        'SysLog'   => ['app\admin\listener\SysUserLog'],
+        'SysLog'   => ['app\listener\SysUserLog'],
     ],
 
     'subscribe' => [

+ 7 - 0
app/model/Article.php

@@ -11,6 +11,8 @@ use think\facade\Config;
 
 class Article extends Base
 {
+    protected $pk = 'id';
+
     protected $schema = [
         "id"          => "int",
         "cid"         => "int",
@@ -169,4 +171,9 @@ class Article extends Base
 
         return $timeList;
     }
+
+    public static function getKeywordsById(int $id) {
+        $article = self::where("id", $id)->find();
+        return $article->keywords;
+    }
 }

+ 0 - 27
app/model/ArticleBrowerHistory.php

@@ -1,27 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace app\model;
-
-use think\Model;
-
-/**
- * @mixin \think\Model
- */
-class ArticleBrowerHistory extends Model
-{
-    
-    protected $schema = [
-        "id" => "int",  // id
-        "ip" => "varchar",  // ip地址
-        "aid" => "int",  // 文章id
-        "create_time" => "int",  // 创建时间
-    ];
-
-    protected $autoWriteTimestamp = false;
-
-    public static function getByIpAid($ip, $aid)
-    {
-        return self::where('ip', $ip)->where('aid', $aid)->find();
-    }
-}

+ 3 - 38
app/model/Tag.php

@@ -7,10 +7,10 @@ use app\model\Base;
 
 class Tag extends Base
 {
-    protected $pk = 'tagid';
+    protected $pk = 'id';
 
     protected $schema = [
-        "tagid"       => "int",
+        "id"       => "int",
         "tagname"     => "varchar",
         "nums"        => "int",
         "create_time" => "int",
@@ -19,41 +19,6 @@ class Tag extends Base
 
     public static function queryList($tagname)
     {
-        return self::where('tagname','LIKE', '%'.$tagname.'%')->field('tagid, tagname')->select();
-    }
-
-    public static function saveTags(array $tags, int $infoid = 0, int $cid = 0)
-    {
-        foreach ($tags as  $tagname) {
-            $tag = self::where('tagname', $tagname)->find();
-
-            if ($tag == null) {
-                $tag = new static;
-                $tag->tagname = $tagname;
-            }
-            $tag->nums += 1;
-            $tag->save();
-
-            TagArticle::create([
-                'infoid' => $infoid,
-                'cid'    => $cid,
-                'tagid'  => $tag->tagid
-            ]);
-        }
-    }
-
-    public static function decNums(array $tags, int $infoid=0)
-    {
-        foreach ($tags as  $tagname) {
-            $tag = self::where('tagname', $tagname)->find();
-
-            if ($tag != null) {
-                $tag->nums = $tag->nums - 1;
-                
-                $tag->save();
-
-                TagArticle::where(['infoid'=>$infoid, 'tagid'=>$tag->tagid])->delete();
-            }
-        }
+        return self::where('tagname','LIKE', '%'.$tagname.'%')->field('id, tagname, nums')->select();
     }
 }

+ 45 - 10
app/model/TagArticle.php

@@ -1,41 +1,76 @@
 <?php
+
 declare(strict_types=1);
 
 namespace app\model;
 
-use think\facade\Config;
 use think\facade\Db;
+use think\facade\Config;
 
 use app\model\Base;
-use app\model\Article;
+use app\model\Tag;
 
 class TagArticle extends Base
 {
-    protected $pk = 'atid';
+    protected $pk = 'id';
 
     protected $schema = [
-        'atid'   => "int",
-        "infoid" => "int",
-        "cid"    => "int",
-        "tagid"  => "int",
+        'id'   => "int",  // 主键id
+        "tid"  => "int",  // 标签id
+        "aid" => "int",   // 文章id
+        "cid"    => "int", // 栏目id
     ];
 
     protected $autoWriteTimestamp = false;
 
     public function article()
     {
-        return $this->belongsTo('Article', 'infoid')->bind(['id','title','titlepic','summary','hits','create_time','username']);
+        return $this->belongsTo('Article', 'aid')->bind(['id', 'title', 'titlepic', 'summary', 'hits', 'create_time', 'username']);
     }
 
     public function category()
     {
-        return $this->belongsTo('Category', 'cid')->bind(['category_url'=>'url','category_name'=>'name']);
+        return $this->belongsTo('Category', 'cid')->bind(['category_url' => 'url', 'category_name' => 'name']);
     }
 
     public static function queryList($tagid)
     {
         $limit = (int) Config::get('app.page_size', 20);
 
-        return self::with(['article','category'])->where('tagid', $tagid)->order('infoid DESC')->limit($limit)->paginate();
+        return self::with(['article', 'category'])->where('tid', $tagid)->order('aid DESC')->limit($limit)->paginate();
+    }
+
+    public static function saveArticleTag(array $tags, int $aid, int $cid)
+    {
+        foreach ($tags as  $tagname) {
+            $tag = Tag::where('tagname', $tagname)->find();
+            if ($tag == null) {
+                $tag = new Tag();
+                $tag->tagname = $tagname;
+            }
+            $tag->nums += 1;
+            $tag->save();
+
+            self::create([
+                'tid' => $tag->id,
+                'aid' => $aid,
+                'cid' => $cid
+            ]);
+        }
+    }
+
+    public static function delArticleTag(array $tags, int $aid)
+    {
+        foreach ($tags as  $tagname) {
+            $tag = Tag::where('tagname', $tagname)->find();
+
+            if ($tag != null) {
+                $tag->nums = $tag->nums - 1;
+                
+                $tag->save();
+
+                self::where(['aid'=>$aid, 'tid'=>$tag->id])->delete();
+            }
+        }
     }
 }

+ 0 - 77
app/utils/AliyunSmsUtils.php

@@ -1,77 +0,0 @@
-<?php
-
-// This file is auto-generated, don't edit it. Thanks.
-namespace app\utils;
-
-use think\facade\Env;
-
-use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
-use AlibabaCloud\Tea\Utils\Utils;
-
-use Darabonba\OpenApi\Models\Config;
-use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;
-use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
-use app\model\SmsLog;
-
-class AliyunSmsUtils {
-
-    /**
-     * 使用AK&SK初始化账号Client
-     * @param string $accessKeyId
-     * @param string $accessKeySecret
-     * @return Dysmsapi Client
-     */
-    public static function createClient($accessKeyId, $accessKeySecret){
-        $config = new Config([
-            // 必填,您的 AccessKey ID
-            "accessKeyId" => $accessKeyId,
-            // 必填,您的 AccessKey Secret
-            "accessKeySecret" => $accessKeySecret
-        ]);
-        // 访问的域名
-        $config->endpoint = "dysmsapi.aliyuncs.com";
-        return new Dysmsapi($config);
-    }
-
-    /**
-     * 发送验证码
-     */
-    public static function sendSms($phone, $code)
-    {
-        $access_key_id = Env::get('aliyun.access_key_id');
-        # 必填,您的 AccessKey Secret
-        $access_key_secret = Env::get('aliyun.access_key_secret');
-        # 短信签名名称
-        $sign_name = Env::get('aliyun.sign_name');
-        # 短信模板CODE
-        $template_code = Env::get('aliyun.template_code');
-
-        $client = self::createClient($access_key_id, $access_key_secret);
-
-        $sendSmsRequest = new SendSmsRequest([
-            "signName" => $sign_name,
-            "templateCode" => $template_code,
-            "phoneNumbers" => $phone,
-            "templateParam" => "{\"code\":\"$code\"}"
-        ]);
-
-        $runtime = new RuntimeOptions([]);
-
-        $resp = $client->sendSmsWithOptions($sendSmsRequest, $runtime);
-
-        @SmsLog::create([
-            "phone" => $phone,  // 
-            "sign_name" => $sign_name,  // 签名
-            "template_code" => $template_code,  // 模板id
-            "template_param" => "{\"code\":\"$code\"}",  // 变量
-            "message" => $resp->body->message,  // 返回值信息
-            "request_id" => $resp->body->requestId,  // 请求id
-            "biz_id" => $resp->body->bizId,  // 回执id
-            "code" => $resp->body->code,  // 发送状态
-            "send_time" => date("Y-m-d H:i:s"),  // 发送时间
-        ]);
-
-        return $resp;
-    }
-}
-

+ 0 - 82
app/utils/ControllerUtils.php

@@ -1,82 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace app\utils;
-
-// 引入框架内置类
-use think\facade\Db;
-use think\facade\Config;
-
-/**
- * 模型 utils
- *
- * @version      0.0.1
- * @author      by huwhois
- * @time        2022/08/10
- */
-class ControllerUtils
-{
-    protected $namespace;
-    protected $class;
-
-    protected function getPathName(string $name): string
-    {
-        $name = substr($name, 4);
-
-        return app()->getBasePath() . ltrim(str_replace('\\', '/', $name), '/') . '.php';
-    }
-
-    protected function getStub(): string
-    {
-        return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'controller.stub';
-    }
-
-    /**
-     * 构建Class文件
-     * @return string
-     */
-    protected function buildClass()
-    {
-        $stub = file_get_contents($this->getStub());
-
-        return str_replace(['{%namespace%}', '{%className%}'], [
-            $this->namespace,
-            $this->class
-        ], $stub);
-    }
-
-    /**
-     * 生成 Model 文件
-     * @param  string $name 类目,包含命名空间
-     * @param string $connections 数据库配置, 默认 mysql
-     */
-    public function makeModel(string $name, string $connections = 'mysql')
-    {
-        $pathname = $this->getPathName($name);
-
-        if (is_file($pathname)) {
-            throw new \Exception("Model :' . $name . ' already exists!</error>", 1);
-        }
-
-        if (!is_dir(dirname($pathname))) {
-            mkdir(dirname($pathname), 0755, true);
-        }
-
-        file_put_contents($pathname, $this->codeModel($name, $connections));
-    }
-
-    /**
-     * 生成 Model 不生成文件
-     * @param  string $name 类目,包含命名空间
-     * @return string
-     */
-    public function codeModel(string $name)
-    {
-        $this->namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\');
-
-        $this->class = str_replace($this->namespace . '\\', '', $name);
-
-        return $this->buildClass();
-    }
-}

+ 4 - 4
app/utils/FileUtils.php

@@ -139,17 +139,17 @@ class FileUtils
 
         $rootpath = Config::get('filesystem.disks.public.root');
 
-        $filepath = date("YMd");
+        $filepath = date("Ymd");
 
         if (!file_exists($rootpath . "/" . $filepath)) {
             mkdir($rootpath . "/" . $filepath, 0755);
         }
 
-        $savename = $filepath . md5(microtime(true). substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 6));
-
+        $savename = $filepath . "/" . md5(microtime(true). substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 6)). "." . $type;
+        
         $filename = Config::get('filesystem.disks.public.url') . '/' . $savename;
 
-        file_put_contents($rootpath . $savename, $imageAll["imgBody"]);
+        file_put_contents($rootpath . "/" . $savename, $imageAll["imgBody"]);
 
         return $filename;
     }

+ 0 - 155
app/utils/ModelUtils.php

@@ -1,155 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace app\utils;
-
-// 引入框架内置类
-use think\facade\Db;
-use think\facade\Config;
-
-/**
- * 模型 utils
- *
- * @version      0.0.1
- * @author      by huwhois
- * @time        2022/08/10
- */
-class ModelUtils
-{
-    protected $namespace;
-    protected $class;
-    protected $tableName;
-    protected $databaseName;
-
-    protected function getPathName(string $name): string
-    {
-        $name = substr($name, 4);
-
-        return app()->getBasePath() . ltrim(str_replace('\\', '/', $name), '/') . '.php';
-    }
-
-    protected function getStub(): string
-    {
-        return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'model.stub';
-    }
-
-    /**
-     * 获取表的主键
-     * @return string
-     */
-    protected function getPrimarykey()
-    {
-        $sql = "SELECT COLUMN_NAME AS pk FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_NAME = '" . $this->tableName . "' AND table_schema = '.$this->databaseName.' AND CONSTRAINT_NAME = 'PRIMARY'";
-
-        $res = Db::query($sql);
-
-        $pk = empty($res) ? '' : $res[0]['pk'];
-
-        return $pk;
-    }
-
-    /**
-     * 获取表的所有字段信息
-     * @return array
-     */
-    protected function getColumns(string $tableName = '', string $database = '')
-    {
-        $sql = "SELECT column_name,column_comment,data_type FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $this->tableName . "' AND table_schema = '" . $this->databaseName . "'";
-
-        // echo $sql . "\n";
-
-        $res = Db::query($sql);
-
-        $columns = empty($res) ? [] : $res;
-
-        return $columns;
-    }
-
-    /**
-     * 构建Class文件
-     * @return string
-     */
-    protected function buildClass()
-    {
-        $stub = file_get_contents($this->getStub());
-
-        $primarykey = "";
-
-        $pk = $this->getPrimarykey();
-
-        if ($pk != "" && $pk != "id") {
-            $primarykey = 'protected $pk = "' . $pk . '";';
-        }
-
-        $schemas = '';
-        $autoWriteTimestamp = '';
-        $create_time = false;
-        $update_time = false;
-
-        $columns = $this->getColumns();
-
-        foreach ($columns as $column) {
-            $schemas .= "\n" . '        "' . $column['column_name'] . '" => "' . $column['data_type'] . '",  // ' . $column['column_comment'];
-
-            if ($column['column_name'] == 'create_time') {
-                $create_time = true;
-            }
-
-            if ($column['column_name'] == 'update_time') {
-                $update_time = true;
-            }
-        }
-
-        if (!$create_time || !$update_time) {
-            $autoWriteTimestamp = 'protected $autoWriteTimestamp = false;';
-        }
-
-        return str_replace(['{%namespace%}', '{%className%}', '{%primarykey%}', '{%schemas%}', '{%autoWriteTimestamp%}'], [
-            $this->namespace,
-            $this->class,
-            $primarykey,
-            $schemas,
-            $autoWriteTimestamp
-        ], $stub);
-    }
-
-    /**
-     * 生成 Model 文件
-     * @param  string $name 类目,包含命名空间
-     * @param string $connections 数据库配置, 默认 mysql
-     */
-    public function makeModel(string $name, string $connections = 'mysql')
-    {
-        $pathname = $this->getPathName($name);
-
-        if (is_file($pathname)) {
-            throw new \Exception("Model :' . $name . ' already exists!</error>", 1);
-        }
-
-        if (!is_dir(dirname($pathname))) {
-            mkdir(dirname($pathname), 0755, true);
-        }
-
-        file_put_contents($pathname, $this->codeModel($name, $connections));
-    }
-
-    /**
-     * 生成 Model 不生成文件
-     * @param  string $name 类目,包含命名空间
-     * @param string $connections 数据库配置, 默认 mysql
-     * @return string
-     */
-    public function codeModel(string $name, string $connections = 'mysql')
-    {
-        $this->namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\');
-
-        $this->class = str_replace($this->namespace . '\\', '', $name);
-
-        $this->tableName = Config::get('database.connections.'.$connections.'.prefix') . strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $this->class));
-
-        $this->databaseName = Config::get('database.connections.'.$connections.'.database');
-
-        return $this->buildClass();
-    }
-}

+ 0 - 115
app/utils/ValidateUtils.php

@@ -1,115 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace app\utils;
-
-// 引入框架内置类
-use think\facade\Db;
-use think\facade\Config;
-
-/**
- * 验证 utils
- *
- * @version      0.0.1
- * @author      by huwhois
- * @time        20228/10
- */
-class ValidateUtils
-{
-    protected $namespace;
-    protected $class;
-    protected $tableName;
-    protected $databaseName;
-
-    protected function getPathName(string $name): string
-    {
-        $name = substr($name, 4);
-
-        return app()->getBasePath() . ltrim(str_replace('\\', '/', $name), '/') . '.php';
-    }
-
-    protected function getStub(): string
-    {
-        return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'validate.stub';
-    }
-
-    /**
-     * 获取表的所有字段信息
-     * @return array
-     */
-    protected function getColumns()
-    {
-        $sql = "SELECT column_name,column_comment,data_type FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $this->tableName . "' AND table_schema = '" . $this->databaseName . "'";
-
-        // echo $sql . "\n";
-
-        $res = Db::query($sql);
-
-        $columns = empty($res) ? [] : $res;
-
-        return $columns;
-    }
-
-    /**
-     * 构建Class文件
-     * @return string
-     */
-    protected function buildClass()
-    {
-        $stub = file_get_contents($this->getStub());
-
-        $schemas = '';
-
-        $columns = $this->getColumns();
-
-        foreach ($columns as $column) {
-            $schemas .= "\n" . '        "' . $column['column_name'] . '" => "require",';
-        }
-
-        return str_replace(['{%namespace%}', '{%className%}', '{%schemas%}'], [
-            $this->namespace,
-            $this->class,
-            $schemas
-        ], $stub);
-    }
-
-    /**
-     * 生成 Model 文件
-     * @param  string $name 类目,包含命名空间
-     * @param string $connections 数据库配置, 默认 mysql
-     */
-    public function makeModel(string $name, string $connections = 'mysql')
-    {
-        $pathname = $this->getPathName($name);
-
-        if (is_file($pathname)) {
-            throw new \Exception("Valiate :' . $name . ' already exists!</error>", 1);
-        }
-
-        if (!is_dir(dirname($pathname))) {
-            mkdir(dirname($pathname), 0755, true);
-        }
-
-        file_put_contents($pathname, $this->codeModel($name, $connections));
-    }
-
-    /**
-     * 生成 Model 不生成文件
-     * @param  string $name 类目,包含命名空间
-     * @param string $connections 数据库配置, 默认 mysql
-     * @return string
-     */
-    public function codeModel(string $name, string $connections = 'mysql')
-    {
-        $this->namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\');
-
-        $this->class = str_replace($this->namespace . '\\', '', $name);
-
-        $this->tableName = Config::get('database.connections.'.$connections.'.prefix') . strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $this->class));
-
-        $this->databaseName = Config::get('database.connections.'.$connections.'.database');
-
-        return $this->buildClass();
-    }
-}

+ 0 - 120
app/utils/ZipUtils.php

@@ -1,120 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace app\utils;
-
-use ZipArchive;
-
-class ZipUtils
-{
-    public function packZip($source, $dest)
-    {
-        //判断zip扩展是否加载或者文件目录是否存在
-        if (!extension_loaded('zip') || !file_exists($source)) {
-            return false;
-        }
-        //创建一个zip打包文件
-        $zip = new ZipArchive();
-
-        if (!$zip->open($dest, ZipArchive::CREATE)) {
-            return false;
-        }
-
-        $source = str_replace('\\', '/', realpath($source));
-        
-        if (is_dir($source) === true) {
-            //创建件一个目录迭代器
-            $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source));
-
-            foreach ($files as $file) {
-                $file = str_replace('\\', '/', $file);
-                //忽略当前目录和上级目录
-                if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) {
-                    continue;
-                }
-                if (is_dir($file) === true) {
-                    //创建一个子目录
-                    $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
-                } else if (is_file($file) === true) {
-                    //创建一个子文件
-                    $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
-                } else if (is_file($source) === true) {
-                    //创建文件根目录下的文件
-                    $zip->addFromString(basename($source), file_get_contents($source));
-                }
-            }
-            $zip->close();
-        }
-    }
-
-    protected function addFileToZip(string $path,  ZipArchive $zip)
-    {
-        $handler = opendir($path); //打开当前文件夹由$path指定。
-        while (($filename = readdir($handler)) !== false) {
-            if ($filename != "." && $filename != "..") { //文件夹文件名字为'.'和‘..’,不要对他们进行操作
-                if (is_dir($path . "/" . $filename)) {
-                    $this->addFileToZip($path . "/" . $filename, $zip);
-                } else {
-                    $zip->addFile($path . "/" . $filename);
-                }
-            }
-        }
-        @closedir($handler);
-    }
-
-
-    /**
-     * 删除临时路径
-     * @param $path
-     */
-    public function deleteDir($path)
-    {
-        if (is_dir($path)) {
-            //
-            $dirs = scandir($path);
-            foreach ($dirs as $dir) {
-                if ($dir != '.' | $dir != '..') {
-                    $sonDir = $path . '/' . $dir;
-                    if (is_dir($sonDir)) {
-                        $this->deleteDir($sonDir);
-                        @rmdir($sonDir);
-                    } else {
-                        @unlink($sonDir);
-                    }
-                }
-            }
-            @rmdir($path);
-        }
-    }
-
-    /**
-     * 文件下载
-     * @param $file
-     */
-    public function downLoad($file)
-    {
-        if (file_exists($file)) {
-            $openFile = fopen($file, 'r');
-            //返回文件类型
-            Header('Content-type: application/octet-iostream');
-            //返回文件的字节大小
-            Header('Accept-Range: bytes');
-            //返回文件大小
-            Header('Accept-Length: ' . $file);
-            //这里对客户端弹出的对话框,对应的文件名
-            Header('Content-disposition: filename=' . substr($file, strrpos($file, '/') + 1));
-            $buffer = 1024;
-            while (!feof($openFile)) {
-                $file_data = fread($openFile, $buffer);
-                echo $file_data;
-            }
-            fclose($file);
-
-            @unlink($file);
-        } else {
-
-            echo '下载文件不存在';
-        }
-    }
-}

+ 0 - 64
app/utils/stubs/controller.stub

@@ -1,64 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace {%namespace%};
-
-use think\Request;
-
-class {%className%}
-{
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        //
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param  \think\Request  $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        //
-    }
-
-    /**
-     * 显示指定的资源
-     *
-     * @param  int  $id
-     * @return \think\Response
-     */
-    public function read($id)
-    {
-        //
-    }
-
-    /**
-     * 保存更新的资源
-     *
-     * @param  \think\Request  $request
-     * @param  int  $id
-     * @return \think\Response
-     */
-    public function update(Request $request, $id)
-    {
-        //
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param  int  $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        //
-    }
-}

+ 0 - 110
app/utils/stubs/form.vue.stub

@@ -1,110 +0,0 @@
-<template>
-  <el-dialog
-    :title="!dataForm.id ? '新增' : '修改'"
-    :close-on-click-modal="false"
-    :visible.sync="visible">
-    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
-#foreach($column in $columns)
-#if($column.columnName != $pk.columnName)
-    <el-form-item label="${column.comments}" prop="${column.attrname}">
-      <el-input v-model="dataForm.${column.attrname}" placeholder="${column.comments}"></el-input>
-    </el-form-item>
-#end
-#end
-    </el-form>
-    <span slot="footer" class="dialog-footer">
-      <el-button @click="visible = false">取消</el-button>
-      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
-    </span>
-  </el-dialog>
-</template>
-
-<script>
-  export default {
-    data () {
-      return {
-        visible: false,
-        dataForm: {
-#foreach($column in $columns)
-#if($column.columnName == $pk.columnName)
-          ${column.attrname}: 0,
-#else
-          ${column.attrname}: ''#if($velocityCount != $columns.size()),#end
-
-#end
-#end
-        },
-        dataRule: {
-#foreach($column in $columns)
-#if($column.columnName != $pk.columnName)
-          ${column.attrname}: [
-            { required: true, message: '${column.comments}不能为空', trigger: 'blur' }
-          ]#if($velocityCount != $columns.size()),#end
-
-#end
-#end
-        }
-      }
-    },
-    methods: {
-      init (id) {
-        this.dataForm.${pk.attrname} = id || 0
-        this.visible = true
-        this.$nextTick(() => {
-          this.$refs['dataForm'].resetFields()
-          if (this.dataForm.${pk.attrname}) {
-            this.$http({
-              url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/info/#[[$]]#{this.dataForm.${pk.attrname}}`),
-              method: 'get',
-              #[[params: this.$http.adornParams()]]#
-            }).then(({data}) => {
-              if (data && data.code === 0) {
-#foreach($column in $columns)
-#if($column.columnName != $pk.columnName)
-                this.dataForm.${column.attrname} = data.${classname}.${column.attrname}
-#end
-#end
-              }
-            })
-          }
-        })
-      },
-      // 表单提交
-      dataFormSubmit () {
-        #[[this.$refs['dataForm'].validate((valid) => {]]#
-          if (valid) {
-            this.$http({
-              url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
-              method: 'post',
-              #[[data: this.$http.adornData({]]#
-#foreach($column in $columns)
-#if($column.columnName == $pk.columnName)
-                '${column.attrname}': this.dataForm.${column.attrname} || undefined,
-#else
-                '${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
-
-#end
-#end
-              })
-            }).then(({data}) => {
-              if (data && data.code === 0) {
-                #[[this.$message({]]#
-                  message: '操作成功',
-                  type: 'success',
-                  duration: 1500,
-                  onClose: () => {
-                    this.visible = false
-                    #[[this.$emit('refreshDataList')]]#
-                  }
-                })
-              } else {
-                #[[this.$message.error(data.msg)]]#
-              }
-            })
-          }
-        })
-      }
-    }
-  }
-</script>
-

+ 0 - 152
app/utils/stubs/index.vue.stub

@@ -1,152 +0,0 @@
-<template>
-  <div class="app-container">
-    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
-      <el-form-item>
-        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
-      </el-form-item>
-      <el-form-item>
-        <el-button @click="getDataList()">查询</el-button>
-        <el-button v-if="isAuth('{%moduleName%}:{%className%}:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
-        <el-button v-if="isAuth('{%moduleName%}:{%className%}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
-      </el-form-item>
-    </el-form>
-    <el-table
-      :data="dataList"
-      border
-      v-loading="dataListLoading"
-      @selection-change="selectionChangeHandle"
-      style="width: 100%;">
-      <el-table-column
-        type="selection"
-        header-align="center"
-        align="center"
-        width="50">
-      </el-table-column>
-        {%schemas%}
-      <el-table-column
-        fixed="right"
-        header-align="center"
-        align="center"
-        width="150"
-        label="操作">
-        <template slot-scope="scope">
-          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.{%primarykey%})">修改</el-button>
-          <el-button type="text" size="small" @click="deleteHandle(scope.row.{%primarykey%})">删除</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-    <el-pagination
-      @size-change="sizeChangeHandle"
-      @current-change="currentChangeHandle"
-      :current-page="pageIndex"
-      :page-sizes="[10, 20, 50, 100]"
-      :page-size="pageSize"
-      :total="totalPage"
-      layout="total, sizes, prev, pager, next, jumper">
-    </el-pagination>
-    <!-- 弹窗, 新增 / 修改 -->
-    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
-  </div>
-</template>
-
-<script>
-  import AddOrUpdate from './{%className%}-add-or-update'
-  export default {
-    data () {
-      return {
-        dataForm: {
-          key: ''
-        },
-        dataList: [],
-        pageIndex: 1,
-        pageSize: 10,
-        totalPage: 0,
-        dataListLoading: false,
-        dataListSelections: [],
-        addOrUpdateVisible: false
-      }
-    },
-    components: {
-      AddOrUpdate
-    },
-    activated () {
-      this.getDataList()
-    },
-    methods: {
-      // 获取数据列表
-      getDataList () {
-        this.dataListLoading = true
-        this.$http({
-          url: this.$http.adornUrl('/{%moduleName%}/{%className%}/index'),
-          method: 'get',
-          params: this.$http.adornParams({
-            'page': this.pageIndex,
-            'limit': this.pageSize,
-            'key': this.dataForm.key
-          })
-        }).then(({res}) => {
-          if (res && res.code === 0) {
-            this.dataList = res.data.data
-            this.totalPage = res.data.total
-          } else {
-            this.dataList = []
-            this.totalPage = 0
-          }
-          this.dataListLoading = false
-        })
-      },
-      // 每页数
-      sizeChangeHandle (val) {
-        this.pageSize = val
-        this.pageIndex = 1
-        this.getDataList()
-      },
-      // 当前页
-      currentChangeHandle (val) {
-        this.pageIndex = val
-        this.getDataList()
-      },
-      // 多选
-      selectionChangeHandle (val) {
-        this.dataListSelections = val
-      },
-      // 新增 / 修改
-      addOrUpdateHandle (id) {
-        this.addOrUpdateVisible = true
-        this.$nextTick(() => {
-          this.$refs.addOrUpdate.init(id)
-        })
-      },
-      // 删除
-      deleteHandle (id) {
-        var ids = id ? [id] : this.dataListSelections.map(item => {
-          return item.{%primarykey%}
-        })
-        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          this.$http({
-            url: this.$http.adornUrl('/{%moduleName%}/{%className%}/delete'),
-            method: 'post',
-            data: this.$http.adornData(ids, false)
-          }).then(({data}) => {
-            if (data && data.code === 0) {
-              this.$message({
-                message: '操作成功',
-                type: 'success',
-                duration: 1500,
-                onClose: () => {
-                  this.getDataList()
-                }
-              })
-            } else {
-              this.$message.error(data.msg)
-            }
-          })
-        }).catch(() => {})
-      }
-    }
-  }
-</script>

+ 0 - 18
app/utils/stubs/model.stub

@@ -1,18 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace {%namespace%};
-
-use think\Model;
-
-/**
- * @mixin \think\Model
- */
-class {%className%} extends Model
-{
-    {%primarykey%}
-    protected $schema = [{%schemas%}
-    ];
-
-    {%autoWriteTimestamp%}    
-}

+ 0 - 21
app/utils/stubs/validate.stub

@@ -1,21 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace {%namespace%};
-
-use think\Validate;
-
-/**
- * @mixin \think\Validate
- */
-class {%className%} extends Validate
-{
-    /**
-     * 定义验证规则
-     * 格式:'字段名' =>  ['规则1','规则2'...]
-     *
-     * @var array
-     */
-    protected $rule = [{%schemas%}
-    ];   
-}

+ 0 - 63
view/sys/article/ckeditor4.html

@@ -1,63 +0,0 @@
-<script src="/static/plugins/ckeditor/ckeditor4/ckeditor.js"></script>
-<script>
-if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
-	CKEDITOR.tools.enableHtml5Elements( document );
-
-// The trick to keep the editor in the sample quite small
-// unless user specified own height.
-CKEDITOR.config.height = 300;
-CKEDITOR.config.width = 'auto';
-
-var initSample = ( function() {
-	var wysiwygareaAvailable = isWysiwygareaAvailable(),
-		isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );
-
-	return function() {
-		var editorElement = CKEDITOR.document.getById( 'editor' );
-
-		// :(((
-		if ( isBBCodeBuiltIn ) {
-			editorElement.setHtml(
-				'Hello world!\n\n' +
-				'I\'m an instance of [url=https://ckeditor.com]CKEditor[/url].'
-			);
-		}
-
-		// Depending on the wysiwygarea plugin availability initialize classic or inline editor.
-		if ( wysiwygareaAvailable ) {
-			CKEDITOR.replace( 'editor' );
-		} else {
-			editorElement.setAttribute( 'contenteditable', 'true' );
-			CKEDITOR.inline( 'editor' );
-
-			// TODO we can consider displaying some info box that
-			// without wysiwygarea the classic editor may not work.
-		}
-	};
-
-	function isWysiwygareaAvailable() {
-		// If in development mode, then the wysiwygarea must be available.
-		// Split REV into two strings so builder does not replace it :D.
-		if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {
-			return true;
-		}
-
-		return !!CKEDITOR.plugins.get( 'wysiwygarea' );
-	}
-} )();
-
-initSample();
-
-$("#form-button-save").click(function(){
-    if (!validator().form()) {
-        return false
-    }
-    
-    const content = CKEDITOR.instances.editor.getData();
-    
-    $("<input/>").attr("type","hidden").attr("name", "content").val(content).appendTo($("#form-save"));
-
-    $("#form-save")[0].submit();
-})
-</script>
-

+ 0 - 33
view/sys/article/ckeditor5.html

@@ -1,33 +0,0 @@
-<style>
-    .ck-editor__editable_inline {
-        height: 400px !important;
-    }
-</style>
-<script src="/static/plugins/ckeditor/ckeditor5-build-classic/ckeditor.js"></script>
-<script>
-    ClassicEditor
-        .create(document.querySelector('#editor'), {
-            //功能模块
-            toolbar:
-                ['heading', '|', 'bold', 'italic', 'bulletedList', 'numberedList', '|', 'indent', 'outdent', '|', 'link', 'imageUpload', 'mediaEmbed', '|', 'blockQuote', 'insertTable', 'undo', 'redo']
-            , language: 'zh-cn'
-            //图片上传
-            , ckfinder: {
-                uploadUrl: 'http://192.168.31.123:2000/api/Home/UploadImg'
-            }
-        })
-        .then(editor => {
-            window.editor = editor;
-        })
-        .catch(err => {
-            console.error(err.stack);
-        });
-
-    $("#form-button-save").click(function () {
-        if (!validator().form()) {
-            return false
-        }
-
-        $("#form-save")[0].submit();
-    })
-</script>

+ 1 - 1
view/sys/article/index.html

@@ -76,7 +76,7 @@
                         </div>
                     </td>
                     <td class="td-manage">
-                        <a href="{:url('save',['content_type'=>$val['content_type'], 'id'=>$val['id']])}" title="编辑"
+                        <a href="{:url('/sys/article/save',['content_type'=>$val['content_type'], 'id'=>$val['id']])}" title="编辑"
                             class="btn btn-primary radius">
                             <i class="Hui-iconfont">&#xe6df;</i></a>
                         <a href="javascript:;" title="删除" class="ml-10 btn btn-danger radius"

+ 3 - 4
view/sys/article/save.html

@@ -7,7 +7,6 @@
 <article class="cl pd-20">
     <form action="{:url('/sys/article/save')}" method="post" class="form form-horizontal" id="form-save">
         <input type="hidden" name="id" value="{$data['id']}">
-        <input type="hidden" name="cjid" value="{$data['cjid']}">
         <input type="hidden" name="content_type" value="{$data['content_type']}">
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-2">
@@ -68,7 +67,7 @@
             <div class="formControls col-xs-6 col-sm-4">
                 <input type="text" class="input-text" value="{$data.titlepic}" name="titlepic" id="titlepic">
                 <div style="width: 160px;height: 160px;">
-                    <a href="javascript:void(0);" onclick="addTitlePic()">
+                    <a href="javascript:void(0);" onclick="uploadPicture()">
                         <img id="view-titlepic"
                             src="{$data.titlepic ? $data.titlepic : '/static/images/upload_picture.png'}" alt="标题图"
                             title="{$data.titlepic ? '更换' : '添加'}标题图" style="max-width: 160px;max-height: 160px;">
@@ -76,7 +75,7 @@
                 </div>
             </div>
             <label class="form-label col-xs-2 col-sm-2">
-                <a class="btn btn-success radius" href="javascript:addTitlePic();">{$data.titlepic ? '更换' :
+                <a class="btn btn-success radius" href="javascript:void(0);" onclick="uploadPicture()">{$data.titlepic ? '更换' :
                     '添加'}标题图</a></label>
             <div class="col-3"> </div>
         </div>
@@ -167,7 +166,7 @@
             //图片上传
             simpleUpload: {
                 // The URL the images are uploaded to.
-                uploadUrl: '/sys/file_manager/ckeditorUploadImage?infoid={$data.id}&cjid={$data.cjid}'
+                uploadUrl: '/sys/file_manager/ckeditorUploadImage'
             },
             //自定义字体
             fontFamily: {

+ 63 - 19
view/sys/article/savemd.html

@@ -62,9 +62,8 @@
 </style>
 
 <article class="cl pd-20">
-    <form action="{:url('save')}" method="post" class="form form-horizontal" id="form-save">
+    <form action="{:url('/sys/article/save')}" method="post" class="form form-horizontal" id="form-save">
         <input type="hidden" name="id" value="{$data['id']}">
-        <input type="hidden" name="cjid" value="{$data['cjid']}">
         <input type="hidden" name="content_type" value="{$data['content_type']}">
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-2">
@@ -125,7 +124,7 @@
             <div class="formControls col-xs-6 col-sm-4">
                 <input type="text" class="input-text" value="{$data.titlepic}" name="titlepic" id="titlepic">
                 <div style="width: 200px;height: 200px;">
-                    <a href="javascript:void(0);" onclick="addTitlePic()">
+                    <a href="javascript:void(0);" onclick="uploadPicture('titlepic')">
                         <img id="view-titlepic"
                             src="{$data.titlepic ? $data.titlepic : '/static/images/upload_picture.png'}" alt="标题图"
                             title="{$data.titlepic ? '更换' : '添加'}标题图" style="max-width: 200px;max-height: 200px;">
@@ -133,7 +132,7 @@
                 </div>
             </div>
             <label class="form-label col-xs-2 col-sm-2">
-                <a class="btn btn-success radius" href="javascript:addTitlePic();">{$data.titlepic ? '更换' :
+                <a class="btn btn-success radius" href="javascript:void(0);"  onclick="uploadPicture('titlepic')">{$data.titlepic ? '更换' :
                     '添加'}标题图</a></label>
             <div class="col-3"> </div>
         </div>
@@ -174,7 +173,7 @@
                     <img src="/static/images/code.png" id="code" onclick="insertText('```\n这里插入代码\n```')" />
                     <img src="/static/images/image.png" id="image" onclick="showDialog()" />
                 </div>
-                <div id="mdeditor" style="width: 100%;height: 400px;">{$data.content}</div>
+                <div id="mdeditor" name="content" style="width: 100%;height: 400px;">{$data.content}</div>
             </div>
         </div>
         <div class="row cl">
@@ -213,9 +212,9 @@
             <div
                 style="width: 160px;height: 160px;margin: 0 auto;display: table-cell;vertical-align: middle;text-align: center;">
                 <img id="view-picture" src="/static/images/upload_picture.png" alt="图片" title="图片"
-                    style="max-width: 120px;max-height: 120px;" onclick="addPicture()">
+                    style="max-width: 120px;max-height: 120px;" onclick="uploadPicture('picture')">
             </div>
-            <input type="text" class="input-text" name="picture" id="picture" value="">
+            <input type="text" class="input-text" name="picture" id="picture" value="" style="width: 90%;margin-left: 5%;">
         </div>
     </div>
     <div style="position: absolute;bottom: 1px;width: 100%;height: 40px;border-top: 1px solid gray;">
@@ -224,6 +223,13 @@
     </div>
 </div>
 
+<!-- 图片上传 -->
+<div>
+    <form id="form-upload_picture">
+        <input type="file" hidden name="image" id="upload_picture">
+    </form>
+</div>
+
 <!--请在下方写此页面业务相关的脚本-->
 <script src="/static/plugins/ace/ace.js"></script>
 <script src="/static/plugins/ace/mode-markdown.js"></script>
@@ -244,18 +250,6 @@
         editor.insert(val); //光标位置插入
     }
 
-    //添加标题图
-    function addTitlePic() {
-        let url = '{:url("file_manager/uploadimg", ["_layer"=>true,"img_id"=>"titlepic","infoid"=>$data.id,"cjid"=>$data.cjid])}'
-        layer_show('添加标题图', url, 800, 500);
-    }
-
-    // 上传图片
-    function addPicture() {
-        let url = '{:url("file_manager/uploadimg", ["_layer"=>true,"img_id"=>"picture","infoid"=>$data.id,"cjid"=>$data.cjid])}'
-        layer_show('插入图片', url, 800, 500);
-    }
-
     //插入图片弹窗取消
     function f_cancel() {
         $('#dialog').hide();
@@ -315,4 +309,54 @@
 
         $("#form-save")[0].submit();
     })
+
+    //添加图片
+    const file = document.getElementById('upload_picture');
+
+    function uploadPicture(name) {
+        // file模拟input点击事件
+        var evt = new MouseEvent("click", {
+            bubbles: false,
+            cancelable: true,
+            view: window,
+        });
+        file.dispatchEvent(evt, uploadfn(name));
+    }
+
+    function uploadfn(name) {
+        file.oninput = function () {
+            if (file.files && file.files[0]) {
+                var formData = new FormData();
+                formData.append("upload_file", file.files[0]);
+                $.ajax({
+                    url: '{:url("/sys/file_manager/uploadImage")}',
+                    type: "post",
+                    data: formData,
+                    processData: false, // 告诉jQuery不要去处理发送的数据
+                    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
+                    dataType: 'json',
+                    success: function (res) {
+                        // console.log(res);
+                        var img = res.data.filename;
+                        $("#view-"+name).attr('src', img);
+                        $("#"+name).val(img);
+                        layer.msg(res.msg, {
+                            icon: 1,
+                            time: 1000
+                        });
+                    },
+                    error: function (res) {
+                        layer.msg(res.msg, {
+                            icon: 5,
+                            time: 1000
+                        });
+                        return false;
+                    },
+                    complete: function () {
+                        document.getElementById('form-upload_picture').reset();
+                    }
+                });
+            }
+        }
+    }
 </script>

+ 0 - 404
view/sys/article/savemdbak.html

@@ -1,404 +0,0 @@
-<style>
-    #toolbar {
-        height: 40px;
-        background-color: #b6b6b6;
-        width: 100%;
-        color: #fff;
-        line-height: 50px;
-    }
-
-    #toolbar img {
-        width: 25px;
-        height: 25px;
-        padding-top: 8px;
-        padding-bottom: 7px;
-        margin-left: 10px;
-    }
-
-    #toolbar img:hover {
-        background: #EBEBEB;
-        cursor: pointer;
-    }
-
-    #dialog {
-        position: fixed;
-        height: 300px;
-        width: 600px;
-        background: #FFFFFF;
-        z-index: 5;
-        left: 30%;
-        border: 1px solid gray;
-        top: 25%;
-        display: none;
-    }
-
-    #cancel {
-        border: 0px none #FFECEC;
-        background: #999999;
-        color: #FFFFFF;
-        padding: 5px 15px;
-        position: absolute;
-        top: 8px;
-        right: 100px;
-    }
-
-    #cancel:hover {
-        background: #AAAAAA;
-    }
-
-    #insert {
-        border: 0px none #FFECEC;
-        background: #BE1A21;
-        color: #FFFFFF;
-        padding: 5px 15px;
-        position: absolute;
-        top: 8px;
-        right: 30px;
-    }
-
-    #insert:hover {
-        background: #CB474D;
-    }
-</style>
-
-<article class="cl pd-20">
-    <form action="{:url('save')}" method="post" class="form form-horizontal" id="form-save">
-        <input type="hidden" name="id" value="{$data['id']}">
-        <input type="hidden" name="cjid" value="{$data['cjid']}">
-        <input type="hidden" name="content_type" value="{$data['content_type']}">
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">
-                <span class="c-red">*</span>栏目:</label>
-            <div class="formControls col-xs-8 col-sm-6">
-                <span class="select-box inline">
-                    <select name="cid" class="select" id="cid">
-                        <option value="">所有栏目</option>
-                        {foreach $category_tree as $value}
-                        <option value="{$value.id}" {eq name='data.cid' value="$value.id" }selected{/eq}>{$value.name}
-                        </option>
-                        {notempty name="value.child"}
-                        {foreach $value.child as $val}
-                        <option value="{$val.id}" {eq name='data.cid' value="$val.id" }selected{/eq}>--{$val.name}
-                        </option>
-                        {notempty name="val.child"}
-                        {foreach $val.child as $vo}
-                        <option value="{$vo.id}" {eq name='data.cid' value="$vo.id" }selected{/eq}>&nbsp;&nbsp;└
-                            --{$vo.name}
-                        </option>
-                        {/foreach}
-                        {/notempty}
-                        {/foreach}
-                        {/notempty}
-                        {/foreach}
-                    </select>
-                </span>
-            </div>
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">
-                <span class="c-red">*</span>标题:</label>
-            <div class="formControls col-xs-8 col-sm-6">
-                <input type="text" class="input-text" value="{$data.title}" placeholder="请填写标题" id="title" name="title">
-            </div>
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">
-                作者: </label>
-            <div class="formControls col-xs-4 col-sm-2">
-                <input type="text" class="input-text" value="{$data.writer}" placeholder="作者" id="writer" name="writer">
-            </div>
-            <label class="form-label col-xs-4 col-sm-2">
-                来源:</label>
-            <div class="formControls col-xs-4 col-sm-2">
-                <input type="text" class="input-text" value="{$data.source}" placeholder="来源" id="source" name="source">
-            </div>
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">
-                标题图:</label>
-            <div class="formControls col-xs-6 col-sm-4">
-                <input type="text" class="input-text" value="{$data.titlepic}" name="titlepic" id="titlepic">
-                <div style="width: 200px;height: 200px;">
-                    <a href="javascript:void(0);" onclick="addTitlePic()">
-                        <img id="view-titlepic"
-                            src="{$data.titlepic ? $data.titlepic : '/static/images/upload_picture.png'}" alt="标题图"
-                            title="{$data.titlepic ? '更换' : '添加'}标题图" style="max-width: 200px;max-height: 200px;">
-                    </a>
-                </div>
-            </div>
-            <label class="form-label col-xs-2 col-sm-2">
-                <a class="btn btn-success radius" href="javascript:addTitlePic();">{$data.titlepic ? '更换' :
-                    '添加'}标题图</a></label>
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">
-                关键词:</label>
-            <div class="formControls col-xs-8 col-sm-6">
-                <input type="text" class="input-text" value="{$data.keywords}" placeholder="关键词" id="source"
-                    name="keywords">
-                <span class="c-red">多个关键词用英文','分割</span>
-            </div>
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">内容简介:</label>
-            <div class="formControls col-xs-8 col-sm-6">
-                <textarea name="summary" id="summary" cols="" rows="" class="textarea" placeholder="说点什么...最多输入500个字符"
-                    datatype="*10-100" dragonfly="true" onKeyUp="textarealength(this,500)">{$data.summary}</textarea>
-                <p class="textarea-numberbar">
-                    <em class="textarea-length">0</em>/500
-                </p>
-            </div>
-            <div class="col-3"> </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-4 col-sm-2">
-                文章正文:</label>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-1 col-sm-1"></label>
-            <input type="hidden" name="content" value="" id="content">
-            <div class="formControls col-xs-11 col-sm-10">
-                <div id="toolbar">
-                    <img src="/static/images/bold.png" id="bold" onclick="insertText('**这里填写要加粗的文字**')" />
-                    <img src="/static/images/italic.png" id="italic" onclick="insertText('_这里填写要斜体的文字_')" />
-                    <img src="/static/images/hyperlink.png" id="hyperlink" onclick="insertText('[这里写连接的描述](这里填写连接地址)')" />
-                    <img src="/static/images/code.png" id="code" onclick="insertText('```\n这里插入代码\n```')" />
-                    <img src="/static/images/image.png" id="image" onclick="showDialog()" />
-                </div>
-                <div id="mdeditor" style="width: 100%;height: 400px;">{$data.content}</div>
-            </div>
-        </div>
-        <div class="row cl">
-            <label class="form-label col-xs-2 col-sm-2">
-                点击量:</label>
-            <div class="formControls col-xs-4 col-sm-2">
-                <input type="number" class="input-text" value="{$data.hits}" id="hits" name="hits"
-                    style="width: 120px;">
-            </div>
-            <label class="form-label col-xs-2 col-sm-2">
-                排序:</label>
-            <div class="formControls col-xs-4 col-sm-2">
-                <input type="number" class="input-text" value="{$data.sort}" id="sort" name="sort"
-                    style="width: 120px;">
-            </div>
-        </div>
-        <div class="row cl">
-            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
-                <button type="button" class="btn btn-success radius" id="form-button-save">确&nbsp;定</button>
-                <button type="button" class="btn btn-default radius" onclick="window.history.back();"
-                    style="margin-left:20px;">取&nbsp;消</button>
-            </div>
-        </div>
-    </form>
-</article>
-
-<div id="dialog">
-    <div style="position: absolute;height: 40px;width: 100%;background: #FFFFFF;border-bottom: 1px solid gray;">
-        <span style="position: absolute;left: 10px;top: 10px;color: gray;">插入图片</span>
-        <img src="/static/images/X.png" style="height: 25px;width: 25px;position: absolute;right: 10px;top: 10px;cursor: pointer;"
-            onclick="f_cancel()" />
-    </div>
-    <div id="tab-img" class="HuiTab" style="margin-top: 40px;">
-        <div class="tabBar clearfix">
-            <span>本地上传</span>
-            <span>网络文件上传</span>
-            <a onclick="onlinepicture(1)"><span>服务器图片选择</span></a>
-        </div>
-        <div class="tabCon">
-            <div class="step1 active" style="margin-left:30px;">
-                <form id="form-uploadimg" method="post" action="" enctype="multipart/form-data">
-                    <div class="row cl" style="margin-top:20px;">
-                        <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>图片要求: </label>
-                        <div class="formControls col-xs-8 col-sm-8">
-                            格式 jpg,png,gif,jpeg,webp; 大小不超过4M.
-                        </div>
-                        <div class="col-3"> </div>
-                    </div>
-                    <div class="row cl">
-                        <label class="form-label col-xs-2 col-sm-2">
-                            <span class="c-red">*</span>本地上传:</label>
-                        <div class="formControls col-xs-4 col-sm-4">
-                            <input type="file" class="input-text" name="upload_file" id="upload_file">
-                        </div>
-                        <div class="formControls col-xs-2 col-sm-2">
-                            <button class="btn btn-primary radius" type="button" onclick="uploadImg()">上传</button>
-                        </div>
-                        <div style="width: 200px;height: 200px;">
-                            <img id="view-picture" src="/static/images/upload_picture.png" alt="图片"
-                                title="图片" style="max-width: 200px;max-height: 200px;">
-                        </div>
-                        <div class="col-3"> </div>
-                    </div>
-                </form>
-            </div>
-            <!-- 本地上传end -->
-        </div>
-        <div class="tabCon">
-            <div class="step2" style="margin-left:30px;">
-                <form id="form-uploadurlimg" method="post" action="" enctype="multipart/form-data">
-                    <div class="row cl" style="margin-top:20px;">
-                        <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>图片要求: </label>
-                        <div class="formControls col-xs-8 col-sm-8">
-                            格式 jpg,png,gif,jpeg,webp; 大小不超过4M.
-                        </div>
-                        <div class="col-3"> </div>
-                    </div>
-                    <div class="row cl" style="margin-top:20px;">
-                        <label class="form-label col-xs-2 col-sm-2">
-                            <span class="c-red">*</span>图片地址:</label>
-                        <div class="formControls col-xs-8 col-sm-8">
-                            <input type="text" class="input-text" name="url_file" id="url_file">
-                        </div>
-                        <div class="formControls col-xs-2 col-sm-2">
-                            <button class="btn btn-primary radius" type="button" onCLick="uploadUrlImg()">确定</button>
-                        </div>
-                        <div style="width: 200px;height: 200px;">
-                            <img id="view-picture-url" src="/static/images/upload_picture.png" alt="图片"
-                                title="图片" style="max-width: 200px;max-height: 200px;">
-                        </div>
-                        <div class="col-3"> </div>
-                    </div>
-                </form>
-            </div>
-            <!-- 网络图片 -->
-        </div>
-        <!-- 在线图片 -->
-        <div class="tabCon">
-            <form id="form-uploadonlineimg" method="post" action="" enctype="multipart/form-data">
-                <div class="row cl" style="margin-top:20px;" id="online">
-                    <div id="imageList">
-                        <ul class="list">
-                            <!-- <li>
-                                    <img width="170" height="113" src="/storage/20220223/d5cc488e71c58bb072debe45ed06c6ad.jpg?noCache=1634567323"
-                                     _src="/storage/20220223/d5cc488e71c58bb072debe45ed06c6ad.jpg">
-                                    <span class="icon"></span>
-                                </li>
-                                 -->
-                            <li class="clearFloat"></li>
-                        </ul>
-                    </div>
-                </div>
-                <div class="row cl">
-                    <label class="form-label col-xs-2 col-sm-2">
-                        <span class="c-red">*</span>图片地址:</label>
-                    <div class="formControls col-xs-8 col-sm-8">
-                        <input type="text" class="input-text" name="online_file" id="online_file">
-                    </div>
-                    <div class="col-3"> </div>
-                </div>
-            </form>
-        </div>
-
-    <div class="row cl" style="margin-top:40px;">
-        <div style="width: 160px;height: 160px;margin: 0 auto;display: table-cell;vertical-align: middle;text-align: center;">
-            <img id="view-picture" src="/static/images/upload_picture.png" alt="图片"
-                title="图片" style="max-width: 120px;max-height: 120px;" onclick="addPicture()">
-        </div>
-        <input type="text" class="input-text" name="picture" id="picture" value="">
-    </div>
-    <div style="position: absolute;bottom: 1px;width: 100%;height: 40px;border-top: 1px solid gray;">
-        <button id="cancel" onclick="f_cancel()">取消</button>
-        <button id="insert" onclick="insert()">插入</button>
-    </div>
-</div>
-
-<!--请在下方写此页面业务相关的脚本-->
-<script src="/static/plugins/ace/ace.js"></script>
-<script src="/static/plugins/ace/mode-markdown.js"></script>
-<script src="/static/plugins/ace/theme-chrome.js"></script>
-<script type="text/javascript" src="/static/plugins/jquery.validation/1.14.0/jquery.validate.js"></script>
-<script type="text/javascript" src="/static/plugins/jquery.validation/1.14.0/messages_zh.js"></script>
-<script type="text/javascript" src="/static/plugins/jquery.validation/1.14.0/validate-methods.js"></script>
-
-<script type="text/javascript">
-    var editor = ace.edit('mdeditor');//编辑框
-
-    editor.setTheme('ace/theme/chrome');
-    editor.getSession().setMode('ace/mode/markdown');
-    editor.renderer.setShowPrintMargin(false);
-
-    //左侧插入,用户插入一些特定方法
-    function insertText(val) {
-        editor.insert(val); //光标位置插入
-    }
-
-    //添加标题图
-    function addTitlePic() {
-        let url = '{:url("file_manager/uploadimg", ["_layer"=>true,"img_id"=>"titlepic","infoid"=>$data.id,"cjid"=>$data.cjid])}'
-        layer_show('添加标题图', url, 800, 500);
-    }
-
-    // 上传图片
-    function addPicture() {
-        let url = '{:url("file_manager/uploadimg", ["_layer"=>true,"img_id"=>"picture","infoid"=>$data.id,"cjid"=>$data.cjid])}'
-        layer_show('插入图片', url, 800, 500);
-    }
-
-    //插入图片弹窗取消
-    function f_cancel() {
-        $('#dialog').hide();
-    }
-    //显示弹窗
-    function showDialog() {
-        $('#dialog').show();
-    }
-    
-    //插入图片
-    function insert() {
-        $('#dialog').hide();
-
-        // 文档图片插入地址
-        var imgUrl = $("#picture").val();
-        
-        insertText('![这里写图片描述](' + imgUrl + ')')
-
-        $("#picture").val('');
-        $("#view-picture").attr('src', '/static/images/upload_picture.png');
-    }
-
-    function validator(params) {
-        return $("#form-save").validate({
-            debug: true,
-            rules: {
-                title: {
-                    required: true,
-                }
-                , summary: {
-                    maxlength: 500,
-                }
-                , sort: {
-                    max: 99
-                }
-                , cid: {
-                    required: true
-                }
-            },
-            messages: {
-                title: {
-                    required: "标题不能为空"
-                }
-                , cid: {
-                    required: "栏目不能为空"
-                }
-            }
-        });
-    }
-
-    $("#form-button-save").click(function () {
-        if (!validator().form()) {
-            return false
-        }
-
-        $("#content").val(editor.getValue());
-
-        $("#form-save")[0].submit();
-    })
-</script>