fix standby_time

This commit is contained in:
2026-02-01 23:30:45 +08:00
parent 566efbcf1f
commit 242d4cadf0
4 changed files with 45 additions and 41 deletions

View File

@@ -77,7 +77,7 @@ target="_blank"
>
</small></div><div class="form-group"><label class="form-label">自动熄屏时间</label><input
type="time"
id="screen-timeout-input"
id="standby-time-input"
class="form-control"
/><small class="text-muted">留空表示不自动熄屏</small></div><button class="btn btn-success" id="save-config-btn">
保存配置
@@ -228,10 +228,10 @@ const response = await mw.ajax.get("/config");
const data = JSON.parse(response);currentConfig = data;// 更新配置表单
if (data.city) {
mw.val(mw.$("#city-input"), data.city);
}if (data.screen_timeout) {
}if (data.standby_time) {
mw.val(
mw.$("#screen-timeout-input"),
data.screen_timeout,
mw.$("#standby-time-input"),
data.standby_time,
);
}// 更新配置表
updateConfigTable(data);
@@ -271,14 +271,14 @@ mw.text(cell2, value);
async function saveConfig() {
try {
const city = mw.val(mw.$("#city-input"));
const screenTimeout = mw.val(mw.$("#screen-timeout-input"));if (!city) {
const standbyTime = mw.val(mw.$("#standby-time-input"));if (!city) {
showMessage("城市名称不能为空", "error");
return;
}const configData = {
city: city,
};// 只有当输入了熄屏时间时才添加到配置中
if (screenTimeout !== "") {
configData.screen_timeout = screenTimeout;
if (standbyTime !== "") {
configData.standby_time = standbyTime;
}const response = await mw.ajax.post(
"/config/set",
configData,

View File

@@ -1,26 +1,26 @@
const MicroWeb={$:t=>document.querySelector(t),$$:t=>document.querySelectorAll(t),show:t=>t.style.display="block",hide:t=>t.style.display="none",toggle:t=>t.style.display="none"===t.style.display?"block":"none",text(t,e){if(void 0===e)return t.textContent;t.textContent=e},html(t,e){if(void 0===e)return t.innerHTML;t.innerHTML=e},val(t,e){if(void 0===e)return t.value;t.value=e},addClass:(t,e)=>t.classList.add(e),removeClass:(t,e)=>t.classList.remove(e),hasClass:(t,e)=>t.classList.contains(e),on(t,e,r,i){"function"==typeof r?(i=r,t.addEventListener(e,i)):t.addEventListener(e,t=>{t.target.matches(r)&&i.call(t.target,t)})},ajax:{async get(t){try{let e=await fetch(t);return await e.text()}catch(r){return console.error("GET failed:",r),null}},async post(t,e){try{let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await r.text()}catch(i){return console.error("POST failed:",i),null}},async postForm(t,e){let r=new FormData(e);try{let i=await fetch(t,{method:"POST",body:r});return await i.text()}catch(o){return console.error("Form POST failed:",o),null}}},bind(t,e=""){Object.keys(t).forEach(r=>{let i=document.querySelectorAll(`[data-bind="${e}${r}"]`);i.forEach(e=>{e.textContent=t[r]})})},render:(t,e)=>t.replace(/\{\{(\w+)\}\}/g,(t,r)=>void 0!==e[r]?e[r]:""),chart:{createProgress(t,e,r=100,i={}){let o=i.width||"100%",a=i.height||"20px",l=i.color||"#007bff",n=i.bgColor||"#f0f0f0",d=e/r*100,s=`
const MicroWeb={$:t=>document.querySelector(t),$$:t=>document.querySelectorAll(t),show:t=>t.style.display="block",hide:t=>t.style.display="none",toggle:t=>t.style.display="none"===t.style.display?"block":"none",text(t,e){if(void 0===e)return t.textContent;t.textContent=e},html(t,e){if(void 0===e)return t.innerHTML;t.innerHTML=e},val(t,e){if(void 0===e)return t.value;t.value=e},attr(t,e,r){if(void 0===r)return t.getAttribute(e);t.setAttribute(e,r)},addClass:(t,e)=>t.classList.add(e),removeClass:(t,e)=>t.classList.remove(e),hasClass:(t,e)=>t.classList.contains(e),replaceClass(t,e,r){t.classList.remove(e),t.classList.add(r)},on(t,e,r,i){"function"==typeof r?(i=r,t.addEventListener(e,i)):t.addEventListener(e,t=>{t.target.matches(r)&&i.call(t.target,t)})},ajax:{async get(t,e={}){try{let r=e.headers||{},i=await fetch(t,{headers:r});return await i.text()}catch(o){return console.error("GET failed:",o),null}},async post(t,e,r={}){try{let i=Object.assign({"Content-Type":"application/json"},r.headers||{}),o=await fetch(t,{method:"POST",headers:i,body:JSON.stringify(e)});return await o.text()}catch(a){return console.error("POST failed:",a),null}},async postForm(t,e){let r=new FormData(e);try{let i=await fetch(t,{method:"POST",body:r});return await i.text()}catch(o){return console.error("Form POST failed:",o),null}}},bind(t,e=""){Object.keys(t).forEach(r=>{let i=document.querySelectorAll(`[data-bind="${e}${r}"]`);i.forEach(e=>{e.textContent=t[r]})})},render:(t,e)=>t.replace(/\{\{(\w+)\}\}/g,(t,r)=>void 0!==e[r]?e[r]:""),chart:{createProgress(t,e,r=100,i={}){let o=i.width||"100%",a=i.height||"20px",l=i.color||"#007bff",n=i.bgColor||"#f0f0f0",s=e/r*100,d=`
<div style="
width: ${o};
height: ${a};
background: ${n};
border-radius: 10px;
width: ${o};
height: ${a};
background: ${n};
border-radius: 10px;
overflow: hidden;
margin: 5px 0;">
<div style="
width: ${d}%;
height: 100%;
background: ${l};
width: ${s}%;
height: 100%;
background: ${l};
transition: width 0.3s;
border-radius: 10px;">
</div>
</div>
<small>${e} / ${r} (${d.toFixed(1)}%)</small>
`;t.innerHTML=s},createBarChart(t,e,r={}){let i=Math.max(...e.values);r.width;let o=r.height||200,a=r.colors||["#007bff","#28a745","#ffc107","#dc3545"],l=`<div style="display: flex; align-items: flex-end; height: ${o}px; gap: 10px;">`;e.values.forEach((t,r)=>{let n=e.labels?e.labels[r]:`Item ${r+1}`,d=a[r%a.length];l+=`
<small>${e} / ${r} (${s.toFixed(1)}%)</small>
`;t.innerHTML=d},createBarChart(t,e,r={}){let i=Math.max(...e.values);r.width;let o=r.height||200,a=r.colors||["#007bff","#28a745","#ffc107","#dc3545",],l=`<div style="display: flex; align-items: flex-end; height: ${o}px; gap: 10px;">`;e.values.forEach((t,r)=>{let n=e.labels?e.labels[r]:`Item ${r+1}`,s=a[r%a.length];l+=`
<div style="text-align: center;">
<div style="
width: 40px;
height: ${t/i*(o-40)}px;
background: ${d};
width: 40px;
height: ${t/i*(o-40)}px;
background: ${s};
border-radius: 5px 5px 0 0;
margin: 0 auto;">
</div>
@@ -30,34 +30,34 @@ const MicroWeb={$:t=>document.querySelector(t),$$:t=>document.querySelectorAll(t
</div>
</div>
`}),l+="</div>",t.innerHTML=l},createGauge(t,e,r=100,i={}){let o=i.size||150,a=i.color||"#007bff",l=`
<div style="position: relative; width: ${o}px; height: ${o/2}px;
<div style="position: relative; width: ${o}px; height: ${o}px;
overflow: hidden; margin: 0 auto;">
<div style="
position: absolute;
width: ${o}px;
height: ${o}px;
border: ${o/10}px solid #f0f0f0;
border-radius: 50%;
border-bottom-color: transparent;
position: absolute;
width: ${o}px;
height: ${o}px;
border: ${o/10}px solid #f0f0f0;
border-radius: 50%;
border-bottom-color: transparent;
border-left-color: transparent;">
</div>
<div style="
position: absolute;
width: ${o}px;
height: ${o}px;
border: ${o/10}px solid ${a};
border-radius: 50%;
border-bottom-color: transparent;
position: absolute;
width: ${o}px;
height: ${o}px;
border: ${o/10}px solid ${a};
border-radius: 50%;
border-bottom-color: transparent;
border-left-color: transparent;
transform: rotate(${45+1.8*Math.min(e/r*100,100)}deg);
transition: transform 0.5s;">
</div>
<div style="
position: absolute;
width: 100%;
text-align: center;
top: ${o/2.5}px;
font-size: ${o/7}px;
position: absolute;
width: 100%;
text-align: center;
top: ${o/2.5}px;
font-size: ${o/7}px;
font-weight: bold;">
${e}
<div style="font-size: ${o/10}px; color: #666;">