values() ->map(fn (int $exp, int $index): array => [ 'level' => $index + 1, 'exp' => $exp, 'increment' => $index === 0 ? $exp : $exp - $rawThresholds[$index - 1], ]); return view('admin.level-exp-configs.index', [ 'thresholds' => $thresholds, 'maxLevel' => $maxLevel, ]); } /** * 方法功能:保存等级经验阈值配置,并同步刷新缓存。 */ public function update(UpdateLevelExpConfigRequest $request): RedirectResponse { $thresholds = $request->validated('thresholds'); // 将列表页提交的阈值重新拼成兼容旧逻辑的逗号字符串。 $body = implode(',', $thresholds); Sysparam::updateOrCreate( ['alias' => 'levelexp'], [ 'body' => $body, 'guidetxt' => '按列表逐级维护升级所需的累计经验阈值', ] ); // 同步更新 Redis / Cache,确保前台经验等级计算即时生效。 $this->chatState->setSysParam('levelexp', $body); Sysparam::clearCache('levelexp'); return redirect()->route('admin.level-exp-configs.index')->with('success', '等级经验阈值已保存并生效!'); } }