update: route data struct & remove google analytics

This commit is contained in:
tokumeikoi 2022-12-17 21:37:08 +08:00
parent 5fc49dc840
commit 99311e12a5
12 changed files with 84 additions and 15 deletions

View File

@ -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'));

View File

@ -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;

View File

@ -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)

View File

@ -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 one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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"
}]
}