Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.

Commit 948376f

Browse files
committed
fix: implement dynamic egg variable loading in handleEggChange and read user input on creation
1 parent 5fbf80d commit 948376f

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

public/js/app.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,25 @@ async function renderCreateServer() {
11351135
function handleEggChange() {
11361136
const varsEl = $('#egg-variables');
11371137
varsEl.innerHTML = '';
1138+
const eggVal = $('#custom-egg-trigger').dataset.value;
1139+
if (!eggVal) return;
1140+
const [eggId, nestId] = eggVal.split(',').map(Number);
1141+
const egg = eggCache.find(e => e.eggId === eggId && e.nestId === nestId);
1142+
if (!egg || !egg.variables || egg.variables.length === 0) return;
1143+
const userViewable = egg.variables.filter(v => v.userViewable !== 0);
1144+
if (userViewable.length === 0) return;
1145+
let htmlStr = '<div class="card" style="margin-top:20px;padding:20px"><h3 style="font-size:0.95rem;font-weight:700;margin-bottom:16px">Egg Variables</h3>';
1146+
for (const v of userViewable) {
1147+
const isEditable = v.userEditable !== 0;
1148+
const desc = v.description ? `<p style="font-size:0.75rem;color:var(--text-muted);margin-top:2px">${v.description}</p>` : '';
1149+
if (isEditable) {
1150+
htmlStr += `<div class="form-group"><label for="egg-var-${v.envVariable}">${v.name}</label><input type="text" id="egg-var-${v.envVariable}" value="${v.defaultValue || ''}" placeholder="${v.name}" />${desc}</div>`;
1151+
} else {
1152+
htmlStr += `<div class="form-group"><label>${v.name}</label><input type="text" value="${v.defaultValue || ''}" disabled />${desc}</div>`;
1153+
}
1154+
}
1155+
htmlStr += '</div>';
1156+
varsEl.innerHTML = htmlStr;
11381157
}
11391158

11401159
async function handleCreateServer(e) {
@@ -1158,7 +1177,8 @@ async function handleCreateServer(e) {
11581177
const environment = {};
11591178
if (egg && egg.variables) {
11601179
for (const v of egg.variables) {
1161-
environment[v.envVariable] = v.defaultValue || '';
1180+
const input = document.getElementById(`egg-var-${v.envVariable}`);
1181+
environment[v.envVariable] = input ? input.value.trim() : (v.defaultValue || '');
11621182
}
11631183
}
11641184

0 commit comments

Comments
 (0)