MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / executeSub2ApiStep9

Function executeSub2ApiStep9

background/steps/platform-verify.js:92–157  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

90 }
91
92 async function executeSub2ApiStep9(state) {
93 if (state.localhostUrl && !isLocalhostOAuthCallbackUrl(state.localhostUrl)) {
94 throw new Error('步骤 8 捕获到的 localhost OAuth 回调地址无效,请重新执行步骤 8。');
95 }
96 if (!state.localhostUrl) {
97 throw new Error('缺少 localhost 回调地址,请先完成步骤 8。');
98 }
99 if (!state.sub2apiSessionId) {
100 throw new Error('缺少 SUB2API 会话信息,请重新执行步骤 1。');
101 }
102 if (!state.sub2apiEmail) {
103 throw new Error('尚未配置 SUB2API 登录邮箱,请先在侧边栏填写。');
104 }
105 if (!state.sub2apiPassword) {
106 throw new Error('尚未配置 SUB2API 登录密码,请先在侧边栏填写。');
107 }
108
109 const sub2apiUrl = normalizeSub2ApiUrl(state.sub2apiUrl);
110 const injectFiles = ['content/utils.js', 'content/sub2api-panel.js'];
111
112 await addLog('步骤 9:正在打开 SUB2API 后台...');
113
114 let tabId = await getTabId('sub2api-panel');
115 const alive = tabId && await isTabAlive('sub2api-panel');
116
117 if (!alive) {
118 tabId = await reuseOrCreateTab('sub2api-panel', sub2apiUrl, {
119 inject: injectFiles,
120 injectSource: 'sub2api-panel',
121 reloadIfSameUrl: true,
122 });
123 } else {
124 await closeConflictingTabsForSource('sub2api-panel', sub2apiUrl, { excludeTabIds: [tabId] });
125 await chrome.tabs.update(tabId, { active: true });
126 await rememberSourceLastUrl('sub2api-panel', sub2apiUrl);
127 }
128
129 await ensureContentScriptReadyOnTab('sub2api-panel', tabId, {
130 inject: injectFiles,
131 injectSource: 'sub2api-panel',
132 });
133
134 await addLog('步骤 9:正在向 SUB2API 提交回调并创建账号...');
135 const result = await sendToContentScript('sub2api-panel', {
136 type: 'EXECUTE_STEP',
137 step: 9,
138 source: 'background',
139 payload: {
140 localhostUrl: state.localhostUrl,
141 sub2apiUrl,
142 sub2apiEmail: state.sub2apiEmail,
143 sub2apiPassword: state.sub2apiPassword,
144 sub2apiGroupName: state.sub2apiGroupName,
145 sub2apiSessionId: state.sub2apiSessionId,
146 sub2apiOAuthState: state.sub2apiOAuthState,
147 sub2apiGroupId: state.sub2apiGroupId,
148 sub2apiDraftName: state.sub2apiDraftName,
149 },

Callers 1

executeStep9Function · 0.85

Calls 10

normalizeSub2ApiUrlFunction · 0.50
addLogFunction · 0.50
getTabIdFunction · 0.50
isTabAliveFunction · 0.50
reuseOrCreateTabFunction · 0.50
rememberSourceLastUrlFunction · 0.50
sendToContentScriptFunction · 0.50

Tested by

no test coverage detected