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

Function loadCertsTab

webdev/src/main.ts:197–249  ·  view source on GitHub ↗

* 加载证书管理页的数据 * 包括模块版本信息和证书列表

()

Source from the content-addressed store, hash-verified

195 * 包括模块版本信息和证书列表
196 */
197async function loadCertsTab(): Promise<void> {
198 showSkeleton('versionInfo', 1);
199 showSkeleton('certificateList', 4);
200
201 try {
202 // 并行请求版本信息和证书列表,加快加载速度
203 const [versionResult, certResult] = await Promise.allSettled([
204 getVersionInfo(),
205 getInstallCertResults(),
206 ]);
207
208 // 渲染版本信息
209 hideSkeleton('versionInfo');
210 if (versionResult.status === 'fulfilled') {
211 renderVersionInfo('versionInfo', versionResult.value);
212 } else {
213 renderVersionInfo('versionInfo', [t('getVersionInfoFailed')]);
214 }
215
216 // 渲染证书列表
217 hideSkeleton('certificateList');
218 if (certResult.status === 'fulfilled' && certResult.value.length > 0) {
219 // 创建删除确认模态框
220 const modal = createModal('deleteModal');
221
222 // 用户确认删除后的操作
223 modal.onConfirm(async (fileName: string) => {
224 try {
225 await deleteCert(fileName);
226 toast(t('deletedReboot', fileName));
227 // 删除后重新加载证书列表
228 const updatedCerts = await getInstallCertResults();
229 renderCertList('certificateList', updatedCerts, handleDelete);
230 } catch (e) {
231 console.error('删除证书失败:', e);
232 toast(t('deleteFailed'));
233 }
234 });
235
236 // 点击删除按钮时弹出确认框
237 function handleDelete(fileName: string, liElement: HTMLLIElement): void {
238 modal.show(fileName);
239 }
240
241 renderCertList('certificateList', certResult.value, handleDelete);
242 }
243 } catch (e) {
244 console.error('加载证书管理页失败:', e);
245 hideSkeleton('versionInfo');
246 hideSkeleton('certificateList');
247 toast(t('loadFailedRoot'));
248 }
249}
250
251/**
252 * 加载模式配置页的数据

Callers 1

main.tsFile · 0.85

Calls 9

showSkeletonFunction · 0.85
getVersionInfoFunction · 0.85
getInstallCertResultsFunction · 0.85
hideSkeletonFunction · 0.85
renderVersionInfoFunction · 0.85
tFunction · 0.85
createModalFunction · 0.85
deleteCertFunction · 0.85
renderCertListFunction · 0.85

Tested by

no test coverage detected