MCPcopy Index your code
hub / github.com/su-kaka/gcli2api / createCredsManager

Function createCredsManager

front/common.js:46–360  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

44// 凭证管理器工厂
45// =====================================================================
46function createCredsManager(type) {
47 const modeParam = type === 'antigravity' ? 'mode=antigravity' : 'mode=geminicli';
48
49 return {
50 type: type,
51 data: {},
52 filteredData: {},
53 currentPage: 1,
54 pageSize: 20,
55 selectedFiles: new Set(),
56 totalCount: 0,
57 currentStatusFilter: 'all',
58 currentErrorCodeFilter: 'all',
59 currentCooldownFilter: 'all',
60 currentPreviewFilter: 'all',
61 currentTierFilter: 'all',
62 statsData: { total: 0, normal: 0, disabled: 0 },
63
64 // API端点
65 getEndpoint: (action) => {
66 const endpoints = {
67 status: `./creds/status`,
68 action: `./creds/action`,
69 batchAction: `./creds/batch-action`,
70 download: `./creds/download`,
71 downloadAll: `./creds/download-all`,
72 detail: `./creds/detail`,
73 fetchEmail: `./creds/fetch-email`,
74 refreshAllEmails: `./creds/refresh-all-emails`,
75 deduplicate: `./creds/deduplicate-by-email`,
76 verifyProject: `./creds/verify-project`,
77 quota: `./creds/quota`
78 };
79 return endpoints[action] || '';
80 },
81
82 // 获取mode参数
83 getModeParam: () => modeParam,
84
85 // DOM元素ID前缀
86 getElementId: (suffix) => {
87 // 普通凭证的ID首字母小写,如 credsLoading
88 // Antigravity的ID是 antigravity + 首字母大写,如 antigravityCredsLoading
89 if (type === 'antigravity') {
90 return 'antigravity' + suffix.charAt(0).toUpperCase() + suffix.slice(1);
91 }
92 return suffix.charAt(0).toLowerCase() + suffix.slice(1);
93 },
94
95 // 刷新凭证列表
96 async refresh() {
97 const loading = document.getElementById(this.getElementId('CredsLoading'));
98 const list = document.getElementById(this.getElementId('CredsList'));
99
100 try {
101 loading.style.display = 'block';
102 list.innerHTML = '';
103

Callers 1

common.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected