fix: 修复前端设置初始化时未返回 domains 数组导致的 undefined 错误 (#997)

This commit is contained in:
bhwa233
2026-04-23 11:57:31 +08:00
committed by GitHub
parent 063b6be2b1
commit 1e50bb0933
3 changed files with 7 additions and 2 deletions

View File

@@ -62,8 +62,9 @@ const apiFetch = async (path, options = {}) => {
const getOpenSettings = async (message, notification) => {
try {
const res = await api.fetch("/open_api/settings");
const domains = Array.isArray(res["domains"]) ? res["domains"] : [];
const domainLabels = res["domainLabels"] || [];
if (res["domains"]?.length < 1) {
if (domains.length < 1) {
message.error("No domains found, please check your worker settings");
}
Object.assign(openSettings.value, {
@@ -75,7 +76,7 @@ const getOpenSettings = async (message, notification) => {
needAuth: res["needAuth"] || false,
defaultDomains: res["defaultDomains"] || [],
randomSubdomainDomains: res["randomSubdomainDomains"] || [],
domains: res["domains"].map((domain, index) => {
domains: domains.map((domain, index) => {
return {
label: domainLabels.length > index ? domainLabels[index] : domain,
value: domain