浏览代码

Merge pull request #1656 from sspanel-uim/dev

Dev 20221031
M1Screw 3 年之前
父节点
当前提交
68fd9d2d79

+ 10 - 10
db/migrations/20000101000000_init_database.php.new

@@ -47,7 +47,7 @@ final class InitDatabase extends AbstractMigration
             ->addColumn('ga_token', 'string', [ ])
             ->addIndex([ 'ga_token' ], [ 'unique' => true ])
             ->addColumn('ga_enable', 'integer', [ 'default' => '0' ])
-            ->addColumn('remark', 'string', [ 'comment' => '备注', 'default' => '' ])
+            ->addColumn('remark', 'text', [ 'comment' => '备注', 'default' => '' ])
             ->addColumn('node_group', 'integer', [ 'comment' => '节点分组', 'default' => 0 ])
             ->addColumn('protocol', 'string', [ 'comment' => 'SS/SSR协议方式', 'default' => 'origin' ])
             ->addColumn('protocol_param', 'string', [ 'default' => '' ])
@@ -71,8 +71,8 @@ final class InitDatabase extends AbstractMigration
             ->addColumn('name', 'string', [])
             ->addColumn('type', 'integer', [])
             ->addColumn('server', 'string', [])
-            ->addColumn('custom_config', 'string', [])
-            ->addColumn('info', 'string', [ 'default' => '' ])
+            ->addColumn('custom_config', 'json', [ 'comment' => '自定义配置', 'default' => '{}' ])
+            ->addColumn('info', 'text', [ 'default' => '' ])
             ->addColumn('status', 'string', [ 'default' => '' ])
             ->addColumn('sort', 'integer', [])
             ->addColumn('traffic_rate', 'float', [ 'default' => 1 ])
@@ -104,8 +104,8 @@ final class InitDatabase extends AbstractMigration
         $this->table('announcement', [ 'id' => false, 'primary_key' => [ 'id' ]])
             ->addColumn('id', 'integer', [ 'identity' => true ])
             ->addColumn('date', 'datetime', [])
-            ->addColumn('content', 'string', [])
-            ->addColumn('markdown', 'string', [])
+            ->addColumn('content', 'text', [])
+            ->addColumn('markdown', 'text', [])
             ->create();
 
         $this->table('blockip', [ 'id' => false, 'primary_key' => [ 'id' ]])
@@ -157,9 +157,9 @@ final class InitDatabase extends AbstractMigration
             ->create();
 
         $this->table('detect_ban_log', [ 'id' => false, 'primary_key' => [ 'id' ]])
-            ->addColumn('id', 'integer', [ 'identity' => true,'signed' => false ])
+            ->addColumn('id', 'integer', [ 'identity' => true, 'signed' => false ])
             ->addColumn('user_name', 'string', [ 'comment' => '用户名' ])
-            ->addColumn('user_id', 'biginteger', [ 'comment' => '用户 ID','signed' => false ])
+            ->addColumn('user_id', 'biginteger', [ 'comment' => '用户 ID', 'signed' => false ])
             ->addColumn('email', 'string', [ 'comment' => '用户邮箱' ])
             ->addColumn('detect_number', 'integer', [ 'comment' => '本次违规次数' ])
             ->addColumn('ban_time', 'integer', [ 'comment' => '本次封禁时长' ])
@@ -253,7 +253,7 @@ final class InitDatabase extends AbstractMigration
             ->addColumn('id', 'biginteger', [ 'identity' => true ])
             ->addColumn('name', 'string', [])
             ->addColumn('price', 'decimal', [ 'precision' => 12, 'scale' => 2 ])
-            ->addColumn('content', 'string', [])
+            ->addColumn('content', 'text', [])
             ->addColumn('auto_renew', 'integer', [])
             ->addColumn('auto_reset_bandwidth', 'integer', [ 'default' => 0 ])
             ->addColumn('status', 'integer', [ 'default' => 1 ])
@@ -298,7 +298,7 @@ final class InitDatabase extends AbstractMigration
         $this->table('ticket', [ 'id' => false, 'primary_key' => [ 'id' ]])
             ->addColumn('id', 'biginteger', [ 'identity' => true ])
             ->addColumn('title', 'string', [])
-            ->addColumn('content', 'string', [])
+            ->addColumn('content', 'text', [])
             ->addColumn('rootid', 'biginteger', [])
             ->addColumn('userid', 'biginteger', [])
             ->addColumn('datetime', 'biginteger', [])
@@ -330,7 +330,7 @@ final class InitDatabase extends AbstractMigration
             ->addColumn('subscribe_type', 'string', [ 'comment' => '获取的订阅类型' ])
             ->addColumn('request_ip', 'string', [ 'comment' => '请求 IP' ])
             ->addColumn('request_time', 'datetime', [ 'comment' => '请求时间' ])
-            ->addColumn('request_user_agent', 'string', [ 'comment' => '请求 UA 信息','default' => null ])
+            ->addColumn('request_user_agent', 'text', [ 'comment' => '请求 UA 信息','default' => null ])
             ->addIndex([ 'user_id' ])
             ->addForeignKey('user_id', 'user', 'id', [ 'delete' => 'CASCADE', 'update' => 'CASCADE' ])
             ->create();

+ 0 - 5
db/migrations/20220505044345_string_to_text.php

@@ -8,10 +8,6 @@ final class StringToText extends AbstractMigration
 {
     public function up(): void
     {
-        $this->table('email_queue')
-            ->changeColumn('array', 'text')
-            ->save();
-
         $this->table('shop')
             ->changeColumn('content', 'text')
             ->save();
@@ -26,7 +22,6 @@ final class StringToText extends AbstractMigration
 
         $this->table('node')
             ->changeColumn('info', 'text')
-            ->changeColumn('custom_config', 'text')
             ->save();
 
         $this->table('announcement')

+ 22 - 0
db/migrations/20221031185300_custom_config_json.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class CustomConfigJson extends AbstractMigration
+{
+    public function up(): void
+    {
+        $this->table('node')
+            ->changeColumn('custom_config', 'json', [ 'comment' => '自定义配置', 'default' => '{}' ])
+            ->save();
+    }
+
+    public function down(): void
+    {
+        $this->table('node')
+            ->changeColumn('custom_config', 'text')
+            ->save();
+    }
+}

+ 3 - 3
resources/views/tabler/admin/node/create.tpl

@@ -1,7 +1,7 @@
 {include file='admin/main.tpl'}
 
-<script src="//cdn.staticfile.org/jsoneditor/9.9.0/jsoneditor.min.js"></script>
-<link href="//cdn.staticfile.org/jsoneditor/9.9.0/jsoneditor.min.css" rel="stylesheet" type="text/css">
+<script src="//cdn.staticfile.org/jsoneditor/9.9.2/jsoneditor.min.js"></script>
+<link href="//cdn.staticfile.org/jsoneditor/9.9.2/jsoneditor.min.css" rel="stylesheet" type="text/css">
 
 <main class="content">
     <div class="content-header ui-content-header">
@@ -179,7 +179,7 @@
                 data: {
                     name: $$getValue('name'),
                     server: $$getValue('server'),
-                    custom_config: editor.get(),
+                    custom_config: JSON.stringify(editor.get()),
                     node_ip: $$getValue('node_ip'),
                     rate: $$getValue('rate'),
                     info: $$getValue('info'),

+ 7 - 9
resources/views/tabler/admin/node/edit.tpl

@@ -1,7 +1,7 @@
 {include file='admin/main.tpl'}
 
-<script src="//cdn.staticfile.org/jsoneditor/9.9.0/jsoneditor.min.js"></script>
-<link href="//cdn.staticfile.org/jsoneditor/9.9.0/jsoneditor.min.css" rel="stylesheet" type="text/css">
+<script src="//cdn.staticfile.org/jsoneditor/9.9.2/jsoneditor.min.js"></script>
+<link href="//cdn.staticfile.org/jsoneditor/9.9.2/jsoneditor.min.css" rel="stylesheet" type="text/css">
 
 <main class="content">
     <div class="content-header ui-content-header">
@@ -217,11 +217,10 @@
                 type: "PUT",
                 url: "/admin/node/{$node->id}",
                 dataType: "json",
-{literal}
                 data: {
                     name: $$getValue('name'),
                     server: $$getValue('server'),
-                    custom_config: editor.get(),
+                    custom_config: JSON.stringify(editor.get()),
                     node_ip: $$getValue('node_ip'),
                     rate: $$getValue('rate'),
                     info: $$getValue('info'),
@@ -232,8 +231,7 @@
                     node_speedlimit: $$getValue('node_speedlimit'),
                     class: $$getValue('class'),
                     node_bandwidth_limit: $$getValue('node_bandwidth_limit'),
-                    bandwidthlimit_resetday: $$getValue('bandwidthlimit_resetday')
-{/literal},
+                    bandwidthlimit_resetday: $$getValue('bandwidthlimit_resetday'),
                     mu_only: $$getValue('mu_only')
                 },
                 success: (data) => {
@@ -247,15 +245,15 @@
                         $$.getElementById('msg').innerHTML = data.msg;
                     }
                 },
-{literal}
                 error: (jqXHR) => {
                     $("#result").modal();
-                    $$.getElementById('msg').innerHTML = `发生错误:${jqXHR.status}`;
+                    $$.getElementById('msg').innerHTML = `发生错误:${
+                        jqXHR.status
+                        }`;
                 }
             });
         }
     });
-{/literal}
 </script>
 <script>
     $(document).ready(function () {

+ 2 - 2
src/Models/Docs.php

@@ -5,7 +5,7 @@ declare(strict_types=1);
 namespace App\Models;
 
 /**
- * Ann Model
+ * Docs Model
  *
  * @property-read   int    $id         Document ID
  *
@@ -14,7 +14,7 @@ namespace App\Models;
  * @property        string $content    Document in HTML
  * @property        string $markdown   Document in MarkDown
  */
-final class Ann extends Model
+final class Docs extends Model
 {
     protected $connection = 'default';
     protected $table = 'docs';