调整配置到数据库存放

This commit is contained in:
nilsir 2023-02-22 11:44:27 +08:00 committed by Edward Yang
parent b4586bd452
commit c988b851a8
17 changed files with 25 additions and 11 deletions

View File

@ -61,5 +61,3 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PROXY=beikeshop.test
MIX_HOST=192.168.0.122
# 自动获取最新汇率API KEY
RATE_KEY=

View File

@ -24,11 +24,11 @@ use Beike\Admin\View\Components\Header;
use Beike\Admin\View\Components\NoData;
use Beike\Admin\View\Components\Sidebar;
use Beike\Console\Commands\ChangeRootPassword;
use Beike\Console\Commands\FetchCurrencyRate;
use Beike\Console\Commands\GenerateDatabaseDict;
use Beike\Console\Commands\GenerateSitemap;
use Beike\Console\Commands\MakeRootAdminUser;
use Beike\Console\Commands\MigrateFromOpenCart;
use Beike\Console\Commands\FetchCurrencyRate;
use Beike\Models\AdminUser;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;

View File

@ -16,5 +16,4 @@ return [
'admin_name' => env('ADMIN_NAME'),
'force_url_https' => env('APP_FORCE_HTTPS', false),
'rate_key' => env('RATE_KEY')
];

View File

@ -32,6 +32,4 @@ class FetchCurrencyRate extends Command
$this->error(sprintf('获取 %s 汇率数据失败', $today));
}
}
}

View File

@ -33,6 +33,4 @@ class Currency extends Base
return $this->value;
}
}
}

View File

@ -99,8 +99,16 @@ class CurrencyService
if ($rates = cache()->get($cacheKey)) {
return $rates;
}
$data = Http::get(sprintf('https://v6.exchangerate-api.com/v6/%s/latest/USD', config('beike.rate_key')))
->json();
if (empty(system_setting('base.rate_api_key'))) {
return [];
}
$data = Http::get(
sprintf(
'https://v6.exchangerate-api.com/v6/%s/latest/%s',
system_setting('base.rate_api_key'),
system_setting('base.currency', 'USD')
)
)->json();
$rates = $data['conversion_rates'] ?? [];
cache()->set($cacheKey, $rates);

View File

@ -75,7 +75,8 @@ class SettingsSeeder extends Seeder
["type" => "plugin", "space" => "stripe", "name" => "status", "value" => "1", "json" => 0],
["type" => "plugin", "space" => "latest_products", "name" => "status", "value" => "1", "json" => 0],
["type" => "plugin", "space" => "flat_shipping", "name" => "status", "value" => "1", "json" => 0],
["type" => "plugin", "space" => "paypal", "name" => "status", "value" => "1", "json" => 0]
["type" => "plugin", "space" => "paypal", "name" => "status", "value" => "1", "json" => 0],
["type" => "system", "space" => "base", "name" => "rate_api_key", "value" => "", "json" => 0],
];
}

View File

@ -208,6 +208,9 @@
<x-admin-form-select title="{{ __('admin/setting.tax_address') }}" name="tax_address" :value="old('tax_address', system_setting('base.tax_address', 'shipping'))" :options="$tax_address">
</x-admin-form-select>
<x-admin-form-input name="rate_api_key" title="{{ __('admin/setting.rate_api_key') }}" value="{{ old('rate_api_key', system_setting('base.rate_api_key', '')) }}">
</x-admin-form-input>
</div>
@hook('admin.setting.after')

View File

@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'Das Platzhalterbild wird angezeigt, wenn kein Bild vorhanden ist oder das Bild nicht gefunden wird, empfohlene Größe: 500*500',
'head_code' => 'Code einfügen',
'head_code_info' => 'Der Code im Eingabefeld wird in den Kopf der Frontend-Seite eingefügt, die zum Zählen des Codes oder zum Hinzufügen spezieller Plug-Ins usw. verwendet werden kann',
'rate_api_key' => 'Tauschrate API KEY',
];

View File

@ -70,4 +70,5 @@ return [
'placeholder_image_info' => 'The placeholder image displayed when there is no image or the image is not found, recommended size: 500*500',
'head_code' => 'Insert code',
'head_code_info' => 'The code in the input box will be inserted into the head of the front-end page, which can be used to count the code or add special plug-ins, etc',
'rate_api_key' => 'Exchange rate API KEY',
];

View File

@ -70,4 +70,5 @@ return [
'placeholder_image_info' => 'La imagen del marcador de posición se muestra cuando no hay imagen o no se encuentra la imagen, tamaño recomendado: 500*500',
'head_code' => 'insertar código',
'head_code_info' => 'El código en el cuadro de entrada se insertará en el encabezado de la página principal, que se puede usar para contar el código o agregar complementos especiales, etc.',
'rate_api_key' => 'tipo de cambio API KEY',
];

View File

@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'L\'image d\'espace réservé s\'affiche lorsqu\'il n\'y a pas d\'image ou si l\'image n\'est pas trouvée, taille recommandée: 500*500',
'head_code' => 'insérer le code',
'head_code_info' => 'Le code dans la zone de saisie sera inséré dans l\'en-tête de la page frontale, qui peut être utilisé pour compter le code ou ajouter des plug-ins spéciaux, etc',
'rate_api_key' => 'taux de change API KEY',
];

View File

@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'Immagine segnaposto visualizzata quando non viene trovata alcuna immagine o immagine, dimensione consigliata: 500*500',
'head_code' => 'inserisci codice',
'head_code_info' => 'Il codice nella casella di input verrà inserito nell\'intestazione della pagina front-end, che può essere utilizzata per contare il codice o aggiungere plug-in speciali, ecc.',
'rate_api_key' => 'tasso di cambio API KEY',
];

View File

@ -69,4 +69,5 @@ return [
'placeholder_image_info' => '画像がない場合や画像が見つからない場合に表示されるプレースホルダー画像、推奨サイズ: 500*500',
'head_code' => '挿入コード',
'head_code_info' => '入力ボックスのコードはフロントエンド ページの先頭に挿入され、コードのカウントや特別なプラグインの追加などに使用できます',
'rate_api_key' => '為替レート API KEY',
];

View File

@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'Изображение-заполнитель, отображаемое, когда изображение отсутствует или изображение не найдено, рекомендуемый размер: 500*500',
'head_code' => 'вставить код',
'head_code_info' => 'Код из поля ввода будет вставлен в шапку страницы интерфейса, что можно использовать для подсчета кода или добавления специальных плагинов и т.д.',
'rate_api_key' => 'обменный курс API KEY',
];

View File

@ -68,4 +68,5 @@ return [
'placeholder_image' => '占位图',
'head_code' => '插入代码',
'head_code_info' => '会将输入框中的代码插入到前端页面 head 中,可用于统计代码或者添加特殊插件等',
'rate_api_key' => '汇率 API KEY',
];

View File

@ -69,4 +69,5 @@ return [
'placeholder_image_info' => '無圖片或圖片未找到時顯示的佔位圖建議尺寸500*500',
'head_code' => '插入代碼',
'head_code_info' => '會將輸入框中的代碼插入到前端頁面 head 中,可用於統計代碼或者添加特殊插件等',
'rate_api_key' => '匯率 API KEY',
];