This commit is contained in:
Tokumeikoi 2020-01-31 17:18:00 +08:00
parent 34892d9c34
commit 6c606527b1
3 changed files with 93 additions and 43 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
/node_modules
/config/v2panel.php
/config/v2board.php
/public/hot
/public/storage
/public/env.example.js

View File

@ -16,24 +16,74 @@ class ConfigController extends Controller
public function fetch()
{
return response([
'data' => config('v2board')
'data' => [
'invite' => [
'invite_force' => (int)config('v2board.invite_force', 0),
'invite_commission' => config('v2board.invite_commission', 10),
'invite_gen_limit' => config('v2board.invite_gen_limit', 5),
'invite_never_expire' => config('v2board.invite_never_expire', 0)
],
'site' => [
'stop_register' => (int)config('v2board.stop_register', 0),
'email_verify' => (int)config('v2board.email_verify', 0),
'app_name' => config('v2board.app_name', 'V2Board'),
'app_url' => config('v2board.app_url'),
'subscribe_url' => config('v2board.subscribe_url'),
'plan_change_enable' => (int)config('v2board.plan_change_enable', 1),
'plan_transfer_hour' => config('v2board.plan_transfer_hour', 12),
'try_out_enable' => (int)config('v2board.try_out_enable', 0),
'try_out_plan_id' => (int)config('v2board.try_out_plan_id'),
'try_out_hour' => (int)config('v2board.try_out_hour', 1)
],
'pay' => [
// alipay
'alipay_enable' => (int)config('v2board.alipay_enable'),
'alipay_appid' => config('v2board.alipay_appid'),
'alipay_pubkey' => config('v2board.alipay_pubkey'),
'alipay_privkey' => config('v2board.alipay_privkey'),
// stripe
'stripe_sk_live' => config('v2board.stripe_sk_live'),
'stripe_pk_live' => config('v2board.stripe_pk_live'),
'stripe_alipay_enable' => (int)config('v2board.stripe_alipay_enable'),
'stripe_wepay_enable' => (int)config('v2board.stripe_wepay_enable'),
'stripe_webhook_key' => config('v2board.stripe_webhook_key'),
// bitpayx
'bitpayx_enable' => config('v2board.bitpayx_enable'),
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret'),
// paytaro
'paytaro_enable' => config('v2board.paytaro_enable'),
'paytaro_app_id' => config('v2board.paytaro_app_id'),
'paytaro_app_secret' => config('v2board.paytaro_app_secret')
],
'frontend' => [
'frontend_theme' => config('v2board.frontend_theme', 1),
'frontend_background_url' => config('v2board.frontend_background_url')
],
'server' => [
'server_token' => config('v2board.server_token'),
'server_license' => config('v2board.server_license')
],
'tutorial' => [
'apple_id' => config('v2board.apple_id')
]
]
]);
}
public function save(ConfigSave $request)
{
$data = $request->input();
// $array = \Config::get('v2board');
$array = \Config::get('v2board');
foreach ($data as $k => $v) {
if (!in_array($k, ConfigSave::filter())) {
abort(500, '参数' . $k . '不在规则内,禁止修改');
}
config(['v2board.' . $k => $v]);
$array[$k] = $v;
}
$data = var_export($array, 1);
if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
abort(500, '修改失败');
}
// $data = var_export($array, 1);
// if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
// abort(500, '修改失败');
// }
\Artisan::call('config:cache');
return response([
'data' => true

View File

@ -7,47 +7,47 @@ use Illuminate\Foundation\Http\FormRequest;
class ConfigSave extends FormRequest
{
CONST RULES = [
'invite.invite_force' => 'in:0,1',
'invite.invite_commission' => 'integer',
'invite.invite_gen_limit' => 'integer',
'invite.invite_never_expire' => 'in:0,1',
'site.stop_register' => 'in:0,1',
'site.email_verify' => 'in:0,1',
'site.app_name' => '',
'site.app_url' => 'url',
'site.subscribe_url' => 'url',
'site.plan_transfer_hour' => 'numeric',
'site.plan_change_enable' => 'in:0,1',
'site.try_out_enable' => 'in:0,1',
'site.try_out_plan_id' => 'integer',
'site.try_out_hour' => 'numeric',
'invite_force' => 'in:0,1',
'invite_commission' => 'integer',
'invite_gen_limit' => 'integer',
'invite_never_expire' => 'in:0,1',
'stop_register' => 'in:0,1',
'email_verify' => 'in:0,1',
'app_name' => '',
'app_url' => 'url',
'subscribe_url' => 'url',
'plan_transfer_hour' => 'numeric',
'plan_change_enable' => 'in:0,1',
'try_out_enable' => 'in:0,1',
'try_out_plan_id' => 'integer',
'try_out_hour' => 'numeric',
// server
'server.server_token' => 'nullable|min:16',
'server.server_license' => 'nullable',
'server_token' => 'nullable|min:16',
'server_license' => 'nullable',
// alipay
'pay.alipay_enable' => 'in:0,1',
'pay.alipay_appid' => 'nullable|integer|min:16',
'pay.alipay_pubkey' => 'max:2048',
'pay.alipay_privkey' => 'max:2048',
'alipay_enable' => 'in:0,1',
'alipay_appid' => 'nullable|integer|min:16',
'alipay_pubkey' => 'max:2048',
'alipay_privkey' => 'max:2048',
// stripe
'pay.stripe_alipay_enable' => 'in:0,1',
'pay.stripe_wepay_enable' => 'in:0,1',
'pay.stripe_sk_live' => '',
'pay.stripe_pk_live' => '',
'pay.stripe_webhook_key' => '',
'stripe_alipay_enable' => 'in:0,1',
'stripe_wepay_enable' => 'in:0,1',
'stripe_sk_live' => '',
'stripe_pk_live' => '',
'stripe_webhook_key' => '',
// bitpayx
'pay.bitpayx_enable' => 'in:0,1',
'pay.bitpayx_appsecret' => '',
'bitpayx_enable' => 'in:0,1',
'bitpayx_appsecret' => '',
// paytaro
'pay.paytaro_enable' => 'in:0,1',
'pay.paytaro_app_id' => '',
'pay.paytaro_app_secret' => '',
'paytaro_enable' => 'in:0,1',
'paytaro_app_id' => '',
'paytaro_app_secret' => '',
// frontend
'frontend.frontend_theme' => 'in:1,2',
'frontend.frontend_background_url' => 'nullable|url',
'frontend_theme' => 'in:1,2',
'frontend_background_url' => 'nullable|url',
// tutorial
'tutorial.apple_id' => 'email',
'tutorial.apple_id_password' => ''
'apple_id' => 'email',
'apple_id_password' => ''
];
public static function filter()