3071f94f7c
- Introduced a new module for step definitions in `data/step-definitions.js` to manage shared step metadata. - Updated `sidepanel.html` to dynamically render steps based on the new step definitions module. - Refactored `sidepanel.js` to utilize the step definitions for rendering and managing step statuses. - Enhanced tests to validate the step definitions module and its integration with the sidepanel. - Cleaned up existing tests to ensure they align with the new structure and functionality.
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
(function attachStepDefinitions(root, factory) {
|
|
root.MultiPageStepDefinitions = factory();
|
|
})(typeof self !== 'undefined' ? self : globalThis, function createStepDefinitionsModule() {
|
|
const STEP_DEFINITIONS = [
|
|
{ id: 1, order: 10, key: 'open-chatgpt', title: '打开 ChatGPT 官网' },
|
|
{ id: 2, order: 20, key: 'submit-signup-email', title: '注册并输入邮箱' },
|
|
{ id: 3, order: 30, key: 'fill-password', title: '填写密码并继续' },
|
|
{ id: 4, order: 40, key: 'fetch-signup-code', title: '获取注册验证码' },
|
|
{ id: 5, order: 50, key: 'fill-profile', title: '填写姓名和生日' },
|
|
{ id: 6, order: 60, key: 'oauth-login', title: '刷新 OAuth 并登录' },
|
|
{ id: 7, order: 70, key: 'fetch-login-code', title: '获取登录验证码' },
|
|
{ id: 8, order: 80, key: 'confirm-oauth', title: '自动确认 OAuth' },
|
|
{ id: 9, order: 90, key: 'platform-verify', title: '平台回调验证' },
|
|
];
|
|
|
|
function getSteps() {
|
|
return STEP_DEFINITIONS.map((step) => ({ ...step }));
|
|
}
|
|
|
|
function getStepById(id) {
|
|
const numericId = Number(id);
|
|
const match = STEP_DEFINITIONS.find((step) => step.id === numericId);
|
|
return match ? { ...match } : null;
|
|
}
|
|
|
|
return {
|
|
STEP_DEFINITIONS,
|
|
getStepById,
|
|
getSteps,
|
|
};
|
|
});
|