Browse Source

update: route data struct & remove google analytics

tokumeikoi 2 years ago
parent
commit
99311e12a5

+ 14 - 2
app/Http/Controllers/Admin/Server/RouteController.php

@@ -15,6 +15,12 @@ class RouteController extends Controller
     public function fetch(Request $request)
     {
         $routes = ServerRoute::get();
+        // TODO: remove on 1.8.0
+        foreach ($routes as $k => $route) {
+            $array = json_decode($route->match, true);
+            if (is_array($array)) $routes[$k]['match'] = $array;
+        }
+        // TODO: remove on 1.8.0
         return [
             'data' => $routes
         ];
@@ -24,10 +30,16 @@ class RouteController extends Controller
     {
         $params = $request->validate([
             'remarks' => 'required',
-            'match' => 'required',
-            'action' => 'required',
+            'match' => 'required|array',
+            'action' => 'required|in:block,dns',
             'action_value' => 'nullable'
+        ], [
+            'remarks.required' => '备注不能为空',
+            'match.required' => '匹配值不能为空',
+            'action.required' => '动作类型不能为空',
+            'action.in' => '动作类型参数有误'
         ]);
+        $params['match'] = array_filter($params['match']);
         if ($request->input('id')) {
             try {
                 $route = ServerRoute::find($request->input('id'));

+ 2 - 2
app/Http/Controllers/Admin/ThemeController.php

@@ -25,9 +25,9 @@ class ThemeController extends Controller
     {
         $themeConfigs = [];
         foreach ($this->themes as $theme) {
-            $themeConfigFile = $this->path . "{$theme}/config.php";
+            $themeConfigFile = $this->path . "{$theme}/config.json";
             if (!File::exists($themeConfigFile)) continue;
-            $themeConfig = include($themeConfigFile);
+            $themeConfig = json_decode(File::get($themeConfigFile), true);
             if (!isset($themeConfig['configs']) || !is_array($themeConfig)) continue;
             $themeConfigs[$theme] = $themeConfig;
             if (config("theme.{$theme}")) continue;

+ 8 - 1
app/Services/ServerService.php

@@ -221,7 +221,14 @@ class ServerService
 
     public function getRoutes(array $routeIds)
     {
-        return ServerRoute::select(['id', 'match', 'action', 'action_value'])->whereIn('id', $routeIds)->get();
+        $routes = ServerRoute::select(['id', 'match', 'action', 'action_value'])->whereIn('id', $routeIds)->get();
+        // TODO: remove on 1.8.0
+        foreach ($routes as $k => $route) {
+            $array = json_decode($route->match, true);
+            if (is_array($array)) $routes[$k]['match'] = $array;
+        }
+        // TODO: remove on 1.8.0
+        return $routes;
     }
 
     public function getServer($serverId, $serverType)

+ 4 - 3
app/Services/ThemeService.php

@@ -18,9 +18,10 @@ class ThemeService
 
     public function init()
     {
-        $themeConfigFile = $this->path . "{$this->theme}/config.php";
-        if (!File::exists($themeConfigFile)) return;
-        $themeConfig = include($themeConfigFile);
+        $themeConfigFile = $this->path . "{$this->theme}/config.json";
+        if (!File::exists($themeConfigFile)) abort(500, "{$this->theme}主题不存在");
+        $themeConfig = json_decode(File::get($themeConfigFile), true);
+        if (!isset($themeConfig['configs']) || !is_array($themeConfig)) abort(500, "{$this->theme}主题配置文件有误");
         $configs = $themeConfig['configs'];
         $data = [];
         foreach ($configs as $config) {

File diff suppressed because it is too large
+ 0 - 0
public/assets/admin/components.async.js


File diff suppressed because it is too large
+ 0 - 0
public/assets/admin/components.chunk.css


File diff suppressed because it is too large
+ 0 - 0
public/assets/admin/umi.js


File diff suppressed because it is too large
+ 0 - 0
public/assets/admin/vendors.async.js


File diff suppressed because it is too large
+ 0 - 0
public/theme/v2board/assets/components.async.js


File diff suppressed because it is too large
+ 0 - 0
public/theme/v2board/assets/umi.js


File diff suppressed because it is too large
+ 0 - 0
public/theme/v2board/assets/vendors.async.js


+ 49 - 0
public/theme/v2board/config.json

@@ -0,0 +1,49 @@
+{
+    "name": "v2board",
+    "description": "v2board",
+    "version": "1.7.2",
+    "images": "https://images.unsplash.com/photo-1515405295579-ba7b45403062?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2160&q=80",
+    "configs": [{
+        "label": "主题色",
+        "placeholder": "请选择主题颜色",
+        "field_name": "theme_color",
+        "field_type": "select",
+        "select_options": {
+            "default": "默认(蓝色)",
+            "green": "奶绿色",
+            "black": "黑色",
+            "darkblue": "暗蓝色"
+        },
+        "default_value": "default"
+    }, {
+        "label": "背景",
+        "placeholder": "请输入背景图片URL",
+        "field_name": "background_url",
+        "field_type": "input"
+    }, {
+        "label": "边栏风格",
+        "placeholder": "请选择边栏风格",
+        "field_name": "theme_sidebar",
+        "field_type": "select",
+        "select_options": {
+            "light": "亮",
+            "dark": "暗",
+        },
+        "default_value": "light"
+    }, {
+        "label": "顶部风格",
+        "placeholder": "请选择顶部风格",
+        "field_name": "theme_header",
+        "field_type": "select",
+        "select_options": {
+            "light": "亮",
+            "dark": "暗"
+        },
+        "default_value": "dark"
+    }, {
+        "label": "自定义页脚HTML",
+        "placeholder": "可以实现客服JS代码的加入等",
+        "field_name": "custom_html",
+        "field_type": "textarea"
+    }]
+}

Some files were not shown because too many files changed in this diff