Преглед изворни кода

feat: add new shop switch in admin/user

Cat пре 2 година
родитељ
комит
24db05cdc4

+ 1 - 1
README.md

@@ -9,7 +9,7 @@
 [![License](https://img.shields.io/github/license/Anankke/SSPanel-Uim?style=flat-square)](https://github.com/Anankke/SSPanel-Uim/blob/dev/LICENSE)
 ![GitHub repo size](https://img.shields.io/github/repo-size/anankke/sspanel-uim?style=flat-square&color=328657)
 ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Anankke/SSPanel-Uim?style=flat-square)
-![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Anankke/SSPanel-Uim/Lint%20code?label=lint&style=flat-square)
+![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/Anankke/SSPanel-Uim/lint.yml?branch=dev&label=lint&style=flat-square)
 
 
 [配套SS/SSR后端](https://github.com/sspanel-uim/shadowsocks-mod) | [配套Trojan后端](https://github.com/sspanel-uim/TrojanX) | [Telegram 水群](https://t.me/ssunion) | [Telegram 通知频道](https://t.me/sspanel_uim) | [Telegram 开发频道](https://t.me/sspanel_uim_dev) | [开发 Blog](https://blog.sspanel.org)

+ 1 - 0
db/migrations/20000101000000_init_database.php.new

@@ -65,6 +65,7 @@ final class InitDatabase extends AbstractMigration
             ->addColumn('auto_reset_day', 'integer', [ 'default' => 0])
             ->addColumn('auto_reset_bandwidth', 'decimal', [ 'default' => '0.00', 'precision' => 12, 'scale' => 2 ])
             ->addColumn('api_token', 'uuid', [ 'comment' => 'API 密钥', 'null' => false, 'default' => '' ])
+            ->addColumn('use_new_shop', 'smallinteger', [ 'comment' => '是否启用新商店', 'null' => false, 'default' => 0 ])
             ->addIndex([ 'user_name' ])
             ->create();
 

+ 24 - 0
db/migrations/20221217033500_add_user_use_new_shop.php

@@ -0,0 +1,24 @@
+<?php
+
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class AddUserUseNewShop extends AbstractMigration
+{
+    public function up(): void
+    {
+        if (! $this->table('user')->hasColumn('use_new_shop')) {
+            $this->table('user')
+                ->addColumn('use_new_shop', 'smallinteger', [ 'comment' => '是否启用新商店', 'null' => false, 'default' => 0 ])
+                ->save();
+        }
+    }
+
+    public function down(): void
+    {
+        $this->table('user')
+            ->removeColumn('use_new_shop')
+            ->save();
+    }
+}

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

@@ -78,10 +78,10 @@
               'bold italic backcolor link | blocks | alignleft aligncenter ' +
               'alignright alignjustify | bullist numlist outdent indent | ' +
               'removeformat',
-            content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;font-size:   14px; -webkit-font-smoothing: antialiased; }'
+            content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;font-size:   14px; -webkit-font-smoothing: antialiased; }',
             {if $user->is_dark_mode}
-            skin = 'oxide-dark';
-            content_css = 'dark';
+            skin: 'oxide-dark',
+            content_css: 'dark',
             {/if}
         }
         tinyMCE.init(options);

+ 3 - 3
resources/views/tabler/admin/announcement/edit.tpl

@@ -57,10 +57,10 @@
               'bold italic backcolor link | blocks | alignleft aligncenter ' +
               'alignright alignjustify | bullist numlist outdent indent | ' +
               'removeformat',
-            content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;   font-size:   14px; -webkit-font-smoothing: antialiased; }'
+            content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;   font-size:   14px; -webkit-font-smoothing: antialiased; }',
             {if $user->is_dark_mode}
-            skin = 'oxide-dark';
-            content_css = 'dark';
+            skin: 'oxide-dark',
+            content_css: 'dark',
             {/if}
         }
         tinyMCE.init(options);

+ 0 - 12
resources/views/tabler/admin/setting.tpl

@@ -26,9 +26,6 @@
                                 <li>
                                     <a data-toggle="tab" href="#verification_code_settings"><i class="mdi mdi-shield-check icon-lg"></i>&nbsp;验证</a>
                                 </li>
-                                <li>
-                                    <a data-toggle="tab" href="#personalise_settings"><i class="mdi mdi-magic-staff icon-lg"></i>&nbsp;个性化</a>
-                                </li>
                                 <li>
                                     <a data-toggle="tab" href="#registration_settings"><i class="mdi mdi-account-plus icon-lg"></i>&nbsp;注册</a>
                                 </li>
@@ -656,15 +653,6 @@
                                     </div>
                                 </div>
 
-                                <div class="tab-pane fade" id="personalise_settings">
-                                    <nav class="tab-nav margin-top-no">
-                                        <ul class="nav nav-list">
-                                            <li class="active">
-                                                <a data-toggle="tab" href="#custom_background_image">&nbsp;背景图像</a>
-                                            </li>
-                                        </ul>
-                                    </nav>
-
                                 <div class="tab-pane fade" id="registration_settings">
                                     <nav class="tab-nav margin-top-no">
                                         <ul class="nav nav-list">

+ 9 - 0
resources/views/tabler/admin/user/edit.tpl

@@ -123,6 +123,15 @@
                                     </label>
                                 </span>
                             </div>
+                            <div class="form-group mb-3 row">
+                                <span class="col">使用新的商店系统</span>
+                                <span class="col-auto">
+                                    <label class="form-check form-check-single form-switch">
+                                        <input id="use_new_shop" class="form-check-input" type="checkbox"
+                                            {if $edit_user->use_new_shop == 1}checked="" {/if}>
+                                    </label>
+                                </span>
+                            </div>
                             <div class="form-group mb-3 row">
                                 <span class="col">封禁用户</span>
                                 <span class="col-auto">

+ 4 - 2
src/Controllers/Admin/UserController.php

@@ -69,9 +69,10 @@ final class UserController extends BaseController
         'pass',
         'money',
         'is_admin',
+        'ga_enable',
+        'use_new_shop',
         'is_banned',
         'banned_reason',
-        'ga_enable',
         'transfer_enable',
         'invite_num',
         'ref_by',
@@ -200,9 +201,10 @@ final class UserController extends BaseController
         $user->remark = $request->getParam('remark');
         $user->money = $request->getParam('money');
         $user->is_admin = $request->getParam('is_admin') === 'true' ? 1 : 0;
+        $user->ga_enable = $request->getParam('ga_enable') === 'true' ? 1 : 0;
+        $user->use_new_shop = $request->getParam('use_new_shop') === 'true' ? 1 : 0;
         $user->is_banned = $request->getParam('is_banned') === 'true' ? 1 : 0;
         $user->banned_reason = $request->getParam('banned_reason');
-        $user->ga_enable = $request->getParam('ga_enable') === 'true' ? 1 : 0;
         $user->transfer_enable = Tools::toGB($request->getParam('transfer_enable'));
         $user->invite_num = $request->getParam('invite_num');
         $user->ref_by = $request->getParam('ref_by');

+ 5 - 0
src/Controllers/HomeController.php

@@ -5,6 +5,7 @@ declare(strict_types=1);
 namespace App\Controllers;
 
 use App\Models\InviteCode;
+use App\Services\Auth;
 use App\Utils\Telegram\Process;
 use Psr\Http\Message\ResponseInterface;
 use Slim\Http\Request;
@@ -45,6 +46,10 @@ final class HomeController extends BaseController
      */
     public function staff(Request $request, Response $response, array $args): ResponseInterface
     {
+        $user = Auth::getUser();
+        if (! $user->isLogin) {
+            return $response->withStatus(404)->write($this->view()->fetch('404.tpl'));
+        }
         return $response->write($this->view()->fetch('staff.tpl'));
     }
 

+ 4 - 4
src/Controllers/SubController.php

@@ -257,7 +257,7 @@ final class SubController extends BaseController
                     $encryption = $node_custom_config['encryption'] ?? 'auto';
                     $network = $node_custom_config['network'] ?? '';
                     $host = $node_custom_config['host'] ?? '';
-                    $servicename = $node_custom_config['servicename'] ?? '';
+                    $allow_insecure = $node_custom_config['allow_insecure'] ?? false;
                     $tls = \in_array($security, ['tls', 'xtls']) ? true : false;
                     // Clash 特定配置
                     $udp = $node_custom_config['udp'] ?? true;
@@ -275,9 +275,10 @@ final class SubController extends BaseController
                         'alterId' => (int) $alter_id,
                         'cipher' => $encryption,
                         'udp' => $udp,
-                        'network' => $network,
                         'tls' => $tls,
-                        'servicename' => $servicename,
+                        'skip-cert-verify' => $allow_insecure,
+                        'servername' => $host,
+                        'network' => $network,
                         'ws-opts' => $ws_opts,
                         'h2-opts' => $h2_opts,
                         'http-opts' => $http_opts,
@@ -290,7 +291,6 @@ final class SubController extends BaseController
                     $network = $node_custom_config['network'] ?? \array_key_exists('grpc', $node_custom_config) && $node_custom_config['grpc'] === '1' ? 'grpc' : 'tcp';
                     $host = $node_custom_config['host'] ?? '';
                     $allow_insecure = $node_custom_config['allow_insecure'] ?? false;
-                    $servicename = $node_custom_config['servicename'] ?? '';
                     // Clash 特定配置
                     $udp = $node_custom_config['udp'] ?? true;
                     $ws_opts = $node_custom_config['ws-opts'] ?? $node_custom_config['ws_opts'] ?? null;

+ 1 - 1
src/Services/Factory.php

@@ -15,6 +15,6 @@ final class Factory
             case 'cookie':
                 return new Cookie();
         }
-        return new Redis();
+        return new Cookie();
     }
 }