MCPcopy
hub / github.com/ys1231/MoveCertificate / renderModeConfig

Function renderModeConfig

webdev/src/ui-renderer.ts:133–195  ·  view source on GitHub ↗
(
    containerId: string,
    currentMode: RunMode,
    onSwitch: SwitchModeHandler,
)

Source from the content-addressed store, hash-verified

131 * 显示当前运行模式,提供切换按钮,并附上两种模式的说明
132 */
133export function renderModeConfig(
134 containerId: string,
135 currentMode: RunMode,
136 onSwitch: SwitchModeHandler,
137): void {
138 const el = document.getElementById(containerId);
139 if (!el) return;
140
141 // 两种模式的名称(从 i18n 获取)
142 const modeNames: Record<RunMode, string> = {
143 compatible: t('compatibleMode'),
144 builtin: t('builtinMode'),
145 };
146
147 // 构建整个模式配置页面的 HTML
148 el.innerHTML = `
149 <!-- 当前模式状态卡片 -->
150 <div class="groupbox">
151 <span class="groupbox-title">${t('currentMode')}</span>
152 <div class="mode-status">
153 <span class="mode-badge ${currentMode}">${modeNames[currentMode]}</span>
154 <span class="mode-desc">${t('modeDesc')}</span>
155 </div>
156 <button class="mode-switch-btn" id="switchModeBtn">
157 ${t('switchTo')}${currentMode === 'compatible' ? t('builtinMode') : t('compatibleMode')}
158 </button>
159 <p class="mode-hint">${t('modeHint')}</p>
160 </div>
161
162 <!-- 两种模式的详细说明 -->
163 <div class="groupbox">
164 <span class="groupbox-title">${t('modeExplain')}</span>
165 <div class="mode-explain">
166 <div class="mode-explain-item">
167 <h4>${t('compatibleTitle')}</h4>
168 <p>
169 ${t('compatibleDesc')}<br>
170 <strong>${t('compatibleSuitable')}</strong>${t('compatibleSuitableVal')}<br>
171 <strong>${t('compatibleFeature')}</strong>${t('compatibleFeatureVal')}
172 </p>
173 </div>
174 <div class="mode-explain-item">
175 <h4>${t('builtinTitle')}</h4>
176 <p>
177 ${t('builtinDesc')}<br>
178 <strong>${t('compatibleSuitable')}</strong>${t('builtinSuitableVal')}<br>
179 <strong>${t('compatibleFeature')}</strong>${t('builtinFeatureVal')}
180 </p>
181 </div>
182 </div>
183 </div>
184 `;
185
186 // 绑定切换按钮的点击事件
187 const switchBtn = document.getElementById('switchModeBtn');
188 if (switchBtn) {
189 switchBtn.onclick = () => {
190 // 计算切换后的新模式

Callers 2

switchModeHandlerFunction · 0.85
loadModeTabFunction · 0.85

Calls 1

tFunction · 0.85

Tested by

no test coverage detected