仰望星辰工作室

better-staridc-MNBT

Z zfhsh first commit 2 个月前
1<style>
2.host-console { padding: 0; }
3.host-console .info-row { display: flex; align-items: center; padding: 15px 0; border-bottom: 1px solid #f0f0f0; gap: 12px; }
4.host-console .info-row:last-child { border-bottom: none; }
5.host-console .info-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
6.host-console .info-icon.url { background: #e6f4ff; color: #1677ff; }
7.host-console .info-icon.user { background: #f6ffed; color: #52c41a; }
8.host-console .info-icon.pwd { background: #fff7e6; color: #fa8c16; }
9.host-console .info-icon.stat { background: #f0f0f0; color: #666; }
10.host-console .info-icon.stat.on { background: #f6ffed; color: #52c41a; }
11.host-console .info-icon.stat.suspend { background: #fff2f0; color: #ff4d4f; }
12.host-console .info-icon.stat.unknown { background: #f0f0f0; color: #999; }
13.host-console .info-body { flex: 1; min-width: 0; }
14.host-console .info-label { color: #999; font-size: 12px; margin-bottom: 2px; }
15.host-console .info-value { font-size: 14px; word-break: break-all; color: #333; }
16.host-console .info-value code { background: #f5f5f5; padding: 2px 8px; border-radius: 4px; font-size: 13px; color: #d4380d; }
17.host-console .copy-btn { flex-shrink: 0; width: 28px; height: 28px; border: 1px solid #d9d9d9; border-radius: 6px; background: #fff; color: #999; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; transition: all .2s; }
18.host-console .copy-btn:hover { border-color: #1677ff; color: #1677ff; }
19.host-console .copy-btn.copied { border-color: #52c41a; color: #52c41a; background: #f6ffed; }
20.host-console .status-text { font-size: 14px; color: #333; }
21.host-console .quota-item { padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
22.host-console .quota-item:last-child { border-bottom: none; }
23.host-console .quota-head { display: flex; justify-content: space-between; font-size: 13px; color: #666; margin-bottom: 8px; }
24.host-console .quota-bar { height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
25.host-console .quota-fill { height: 100%; border-radius: 4px; transition: width .3s; }
26.host-console .quota-fill.ok { background: #52c41a; }
27.host-console .quota-fill.warn { background: #fa8c16; }
28.host-console .quota-fill.danger{ background: #ff4d4f; }
29.host-console .quota-unlimited { color: #999; font-size: 13px; }
30.host-console .btn-area { margin-top: 16px; }
31</style>
32
33<div class="card">
34 <div class="card-body host-console">
35
36 <div class="info-row">
37 <div class="info-icon url">🌐</div>
38 <div class="info-body">
39 <div class="info-label">控制台地址</div>
40 <div class="info-value">
41 {if condition="!empty($console_url)"}
42 <a href="{$console_url}" target="_blank">{$console_url}</a>
43 {else /}
44 <span style="color:#999">未配置</span>
45 {/if}
46 </div>
47 </div>
48 {if condition="!empty($console_url)"}
49 <button class="copy-btn" data-copy="{$console_url}" onclick="hostCopy(this)" title="复制">📋</button>
50 {/if}
51 </div>
52
53 <div class="info-row">
54 <div class="info-icon user">👤</div>
55 <div class="info-body">
56 <div class="info-label">登录账号</div>
57 <div class="info-value"><code>{$username|default='—'}</code></div>
58 </div>
59 {if condition="!empty($username)"}
60 <button class="copy-btn" data-copy="{$username}" onclick="hostCopy(this)" title="复制">📋</button>
61 {/if}
62 </div>
63
64 <div class="info-row">
65 <div class="info-icon pwd">🔑</div>
66 <div class="info-body">
67 <div class="info-label">登录密码</div>
68 <div class="info-value"><input type="hidden" id="hostPasswordPlain" value="{$password}">
69<code id="hostPassword" style="user-select:none">{$password_mask|default='—'}</code>
70 {if condition="!empty($password)"}
71 <a href="javascript:void(0)" onclick="hostTogglePwd(this)" style="margin-left:6px;font-size:12px;">显示</a>
72 {/if}
73 </div>
74 </div>
75 {if condition="!empty($password)"}
76 <button class="copy-btn" data-copy="{$password}" onclick="hostCopy(this)" title="复制">📋</button>
77 {/if}
78 </div>
79
80 <div class="info-row">
81 <div class="info-icon stat {$status_class}">📊</div>
82 <div class="info-body">
83 <div class="info-label">主机状态</div>
84 <div class="status-text">{$status_text}</div>
85 </div>
86 </div>
87
88 {if condition="$quota"}
89 <div style="margin-top:14px;border-top:1px solid #f0f0f0;padding-top:6px;">
90 <div class="info-label" style="margin:10px 0 4px;">配额用量</div>
91
92 <div class="quota-item">
93 <div class="quota-head">
94 <span>网站空间</span>
95 <span>{$quota.web_size_used} / {if condition="$quota.web_size_max==0"}不限{else /}{$quota.web_size_max}{/if} MB</span>
96 </div>
97 {if condition="$quota.web_size_max>0"}
98 <div class="quota-bar">
99 <div class="quota-fill {$quota_pct.web_size.cls}" style="width:{$quota_pct.web_size.pct}%"></div>
100 </div>
101 {else /}
102 <div class="quota-unlimited">不限制</div>
103 {/if}
104 </div>
105
106 <div class="quota-item">
107 <div class="quota-head">
108 <span>数据库空间</span>
109 <span>{$quota.sql_size_used} / {if condition="$quota.sql_size_max==0"}不限{else /}{$quota.sql_size_max}{/if} MB</span>
110 </div>
111 {if condition="$quota.sql_size_max>0"}
112 <div class="quota-bar">
113 <div class="quota-fill {$quota_pct.sql_size.cls}" style="width:{$quota_pct.sql_size.pct}%"></div>
114 </div>
115 {else /}
116 <div class="quota-unlimited">不限制</div>
117 {/if}
118 </div>
119
120 <div class="quota-item">
121 <div class="quota-head">
122 <span>流量</span>
123 <span>{$quota.flow_used} / {if condition="$quota.flow_max==0"}不限{else /}{$quota.flow_max}{/if} MB</span>
124 </div>
125 {if condition="$quota.flow_max>0"}
126 <div class="quota-bar">
127 <div class="quota-fill {$quota_pct.flow.cls}" style="width:{$quota_pct.flow.pct}%"></div>
128 </div>
129 {else /}
130 <div class="quota-unlimited">不限制</div>
131 {/if}
132 </div>
133 </div>
134 {/if}
135
136 {if condition="!empty($console_url)"}
137 <div class="btn-area">
138 <a href="{$console_url}" target="_blank" class="btn btn-primary btn-sm">前往控制台</a>
139 </div>
140 {/if}
141
142 </div>
143</div>
144
145<script>
146// 复制:从 data-copy 属性取值,避免将值拼进 JS 字符串导致注入
147function hostCopy(btn) {
148 var text = btn.getAttribute('data-copy') || '';
149 var ta = document.createElement('textarea');
150 ta.value = text;
151 ta.style.position = 'fixed'; ta.style.left = '-9999px';
152 document.body.appendChild(ta);
153 ta.select(); document.execCommand('copy');
154 document.body.removeChild(ta);
155 btn.classList.add('copied');
156 btn.innerHTML = '✓';
157 setTimeout(function(){ btn.classList.remove('copied'); btn.innerHTML = '📋'; }, 1500);
158}
159
160// 密码显示/隐藏切换
161function hostTogglePwd(link) {
162 var el = document.getElementById('hostPassword');
163 if (!el) return;
164 if (el.dataset.show !== '1') {
165 el.dataset.plain = el.textContent = document.getElementById('hostPasswordPlain').value;
166 el.dataset.show = '1';
167 link.textContent = '隐藏';
168 } else {
169 el.textContent = '••••••••';
170 el.dataset.show = '0';
171 link.textContent = '显示';
172 }
173}
174</script>