Skip to content

Commit

Permalink
support disable theme
Browse files Browse the repository at this point in the history
  • Loading branch information
yushine committed Oct 30, 2024
1 parent 848c0c0 commit 887b484
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion innopacks/panel/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
Route::put('/locales/{country}/active', [Controllers\LocaleController::class, 'active'])->name('locales.active');

Route::get('/themes', [Controllers\ThemeController::class, 'index'])->name('themes.index');
Route::put('/themes/{country}/active', [Controllers\ThemeController::class, 'enable'])->name('themes.active');
Route::put('/themes/{code}/active', [Controllers\ThemeController::class, 'enable'])->name('themes.active');
Route::get('/themes/settings', [Controllers\ThemeController::class, 'settings'])->name('themes_settings.index');
Route::put('/themes/settings', [Controllers\ThemeController::class, 'updateSettings'])->name('themes_settings.update');

Expand Down
15 changes: 11 additions & 4 deletions innopacks/panel/src/Controllers/ThemeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use InnoShop\Common\Repositories\PageRepo;
use InnoShop\Common\Repositories\SettingRepo;
use InnoShop\Panel\Repositories\ThemeRepo;
use Throwable;

class ThemeController extends BaseController
{
Expand Down Expand Up @@ -49,7 +50,7 @@ public function settings(): mixed
/**
* @param Request $request
* @return mixed
* @throws \Throwable
* @throws Throwable
*/
public function updateSettings(Request $request): mixed
{
Expand All @@ -68,14 +69,20 @@ public function updateSettings(Request $request): mixed
}

/**
* @param Request $request
* @param string $themeCode
* @return JsonResponse
* @throws \Throwable
* @throws Throwable
*/
public function enable(string $themeCode): JsonResponse
public function enable(Request $request, string $themeCode): JsonResponse
{
try {
SettingRepo::getInstance()->updateSystemValue('theme', $themeCode);
$status = $request->get('status');
if (empty($status)) {
SettingRepo::getInstance()->updateSystemValue('theme', '');
} else {
SettingRepo::getInstance()->updateSystemValue('theme', $themeCode);
}

return json_success(panel_trans('common.updated_success'));
} catch (\Exception $e) {
Expand Down

0 comments on commit 887b484

Please sign in to comment.