diff --git a/gofaster/app/debug-call-chain.js b/gofaster/app/debug-call-chain.js new file mode 100644 index 0000000..6aaa07a --- /dev/null +++ b/gofaster/app/debug-call-chain.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node + +// 设置调试模式环境变量 +process.env.ROUTE_MAPPING_DEBUG = 'true' + +// 导入路由映射插件 +const routeMappingPlugin = require('./plugins/route-mapping-plugin.js') + +console.log('开始调试CallChainTracer...') +console.log('='.repeat(50)) + +try { + const plugin = routeMappingPlugin() + plugin.collectDirectMappings() + console.log('调试完成') +} catch (error) { + console.error('调试过程中发生错误:', error) + process.exit(1) +} diff --git a/gofaster/app/plugins/modules/call-chain-tracer.js b/gofaster/app/plugins/modules/call-chain-tracer.js index d0d943e..74a88b2 100644 --- a/gofaster/app/plugins/modules/call-chain-tracer.js +++ b/gofaster/app/plugins/modules/call-chain-tracer.js @@ -1,6 +1,6 @@ const { readFileSync, existsSync } = require('fs') const { resolve } = require('path') -const { parse } = require('@vue/compiler-dom') +const { parse } = require('@vue/compiler-sfc') const parser = require('@babel/parser') const traverse = require('@babel/traverse').default @@ -10,6 +10,23 @@ const traverse = require('@babel/traverse').default */ class CallChainTracer { constructor() { + this.debugMode = process.env.ROUTE_MAPPING_DEBUG === 'true' || process.argv.includes('--debug') + } + + /** + * 调试日志输出 + * @param {string} message - 日志消息 + * @param {any} data - 附加数据 + */ + debugLog(message, data = null) { + if (this.debugMode) { + const timestamp = new Date().toISOString() + if (data) { + console.log(`[${timestamp}] [CallChainTracer] ${message}`, data) + } else { + console.log(`[${timestamp}] [CallChainTracer] ${message}`) + } + } } /** @@ -18,21 +35,32 @@ class CallChainTracer { * @returns {Array} 增强的API映射数组 */ traceMethodTriggersToVisualComponents(apiMappings) { + this.debugLog('开始追溯method类型的触发源到可视控件') + this.debugLog('API映射数量', apiMappings.length) + const enhancedApiMappings = apiMappings.map(module => { + this.debugLog(`处理模块: ${module.module}`) + const enhancedApiMappings = module.apiMappings.map(api => { if (!api.triggerSources || api.triggerSources.length === 0) { + this.debugLog(`API ${api.apiMethodName} 没有触发源,跳过`) return api } + this.debugLog(`处理API: ${api.apiMethodName},触发源数量: ${api.triggerSources.length}`) + // 只处理triggerType为method的触发源 const enhancedTriggerSources = api.triggerSources.map(trigger => { if (trigger.triggerType === 'method') { - return this.traceMethodToVisualComponent( + this.debugLog(`追溯method类型触发源: ${trigger.triggerName} in ${trigger.component}`) + const result = this.traceMethodToVisualComponent( trigger, module.module, module.serviceName, api.apiMethodName ) + this.debugLog(`追溯结果:`, result) + return result } return trigger }) @@ -49,6 +77,7 @@ class CallChainTracer { } }) + this.debugLog('追溯完成') return enhancedApiMappings } @@ -61,21 +90,33 @@ class CallChainTracer { * @returns {Object} 增强的触发源对象 */ traceMethodToVisualComponent(trigger, moduleName, serviceName, apiMethodName) { + this.debugLog(`开始追溯method: ${trigger.triggerName} in ${trigger.component}`) + try { // 查找组件文件 const componentPath = this.findComponentFile(trigger.component, moduleName) + this.debugLog(`查找组件文件: ${trigger.component} in ${moduleName}`, componentPath) + if (!componentPath) { + this.debugLog(`未找到组件文件: ${trigger.component}`) return trigger } const content = readFileSync(componentPath, 'utf-8') + this.debugLog(`读取组件文件成功,内容长度: ${content.length}`) // 解析Vue组件 const ast = this.parseVueComponent(content) - if (!ast) return trigger + this.debugLog(`解析Vue组件结果:`, ast ? '成功' : '失败') + + if (!ast) { + this.debugLog(`Vue组件解析失败`) + return trigger + } // 建立函数调用关系映射 const functionCallMap = this.buildFunctionCallMap(ast) + this.debugLog(`建立函数调用关系映射,映射数量: ${functionCallMap.size}`) // 追溯method到可视控件 const visualContext = this.traceToVisualComponent( @@ -85,16 +126,22 @@ class CallChainTracer { trigger.component ) + this.debugLog(`追溯可视控件结果:`, visualContext) + if (visualContext) { - return { + const result = { ...trigger, triggerName: visualContext.triggerName, triggerType: visualContext.triggerType } + this.debugLog(`追溯成功,返回结果:`, result) + return result } + this.debugLog(`追溯失败,返回原始trigger`) return trigger } catch (error) { + this.debugLog(`追溯过程中发生错误:`, error.message) return trigger } } @@ -106,21 +153,28 @@ class CallChainTracer { * @returns {string|null} 组件文件路径 */ findComponentFile(componentName, moduleName) { + this.debugLog(`查找组件文件: ${componentName} in ${moduleName}`) + // 优先在指定模块中查找 if (moduleName) { // 检查views目录 const viewPath = resolve(__dirname, `../../src/renderer/modules/${moduleName}/views/${componentName}.vue`) + this.debugLog(`检查views路径: ${viewPath}`, existsSync(viewPath)) if (existsSync(viewPath)) { + this.debugLog(`找到组件文件: ${viewPath}`) return viewPath } // 检查components目录 const componentPath = resolve(__dirname, `../../src/renderer/modules/${moduleName}/components/${componentName}.vue`) + this.debugLog(`检查components路径: ${componentPath}`, existsSync(componentPath)) if (existsSync(componentPath)) { + this.debugLog(`找到组件文件: ${componentPath}`) return componentPath } } + this.debugLog(`未找到组件文件: ${componentName}`) return null } @@ -133,11 +187,15 @@ class CallChainTracer { try { // 提取script部分 const scriptMatch = content.match(/]*>([\s\S]*?)<\/script>/) + this.debugLog(`提取script部分:`, scriptMatch ? '成功' : '失败') + if (!scriptMatch) { + this.debugLog(`未找到script标签`) return null } const scriptContent = scriptMatch[1] + this.debugLog(`script内容长度: ${scriptContent.length}`) // 使用Babel解析JavaScript const ast = parser.parse(scriptContent, { @@ -145,8 +203,10 @@ class CallChainTracer { plugins: ['jsx', 'typescript'] }) + this.debugLog(`Babel解析结果:`, ast ? '成功' : '失败') return ast } catch (error) { + this.debugLog(`解析Vue组件时发生错误:`, error.message) return null } } @@ -220,21 +280,31 @@ class CallChainTracer { * @returns {Object|null} 可视控件上下文 */ traceToVisualComponent(methodName, functionCallMap, filePath, componentName) { + this.debugLog(`追溯method到可视控件: ${methodName}`) + try { // 读取组件文件内容 const content = readFileSync(filePath, 'utf-8') // 分析模板中的事件绑定 + this.debugLog(`分析模板中的事件绑定: ${methodName}`) const visualContext = this.analyzeTemplateForMethod(content, methodName, componentName, filePath) + this.debugLog(`模板分析结果:`, visualContext) + if (visualContext) { + this.debugLog(`在模板中找到事件绑定`) return visualContext } // 如果模板中没有找到,检查是否有其他方法调用了这个方法 + this.debugLog(`模板中未找到,检查方法调用关系`) const callerContext = this.findMethodCaller(methodName, functionCallMap) + this.debugLog(`找到调用者:`, callerContext) + if (callerContext) { // 检查调用者是否是生命周期钩子 if (this.isLifecycleHook(callerContext)) { + this.debugLog(`调用者是生命周期钩子: ${callerContext}`) return { triggerName: '', triggerType: 'page' @@ -242,11 +312,13 @@ class CallChainTracer { } // 继续递归追溯 + this.debugLog(`递归追溯调用者: ${callerContext}`) return this.traceToVisualComponent(callerContext, functionCallMap, filePath, componentName) } + this.debugLog(`未找到调用者,追溯失败`) } catch (error) { - // 静默处理错误 + this.debugLog(`追溯可视控件时发生错误:`, error.message) } return null @@ -261,24 +333,36 @@ class CallChainTracer { * @returns {Object|null} 可视控件上下文 */ analyzeTemplateForMethod(content, methodName, componentName, filePath) { + this.debugLog(`分析模板中的方法调用: ${methodName}`) + try { // 使用Vue编译器解析单文件组件 const { descriptor } = parse(content) + this.debugLog(`Vue编译器解析结果:`, descriptor ? '成功' : '失败') if (!descriptor.template) { + this.debugLog(`未找到template部分`) return null } // 解析模板AST const templateAst = descriptor.template.ast + this.debugLog(`模板AST解析结果:`, templateAst ? '成功' : '失败') + if (!templateAst) { + this.debugLog(`模板AST解析失败`) return null } // 遍历模板AST,查找事件绑定 - return this.findEventBindingInTemplate(templateAst, methodName, componentName, filePath) + this.debugLog(`开始遍历模板AST查找事件绑定`) + const result = this.findEventBindingInTemplate(templateAst, methodName, componentName, filePath) + this.debugLog(`模板AST遍历结果:`, result) + + return result } catch (error) { + this.debugLog(`分析模板时发生错误:`, error.message) return null } } @@ -292,29 +376,49 @@ class CallChainTracer { * @returns {Object|null} 可视组件上下文 */ findEventBindingInTemplate(node, methodName, componentName, filePath) { - if (!node) return null + this.debugLog(`查找事件绑定: ${methodName} in ${node.tag || 'root'}`) + + if (!node) { + this.debugLog(`节点为空`) + return null + } // 检查当前节点是否有事件绑定 if (node.props) { + this.debugLog(`检查节点属性,属性数量: ${node.props.length}`) + for (const prop of node.props) { if (prop.type === 7) { // DIRECTIVE类型 const eventName = prop.name + this.debugLog(`检查指令: ${eventName}`) + if (eventName === 'on' && prop.arg) { const eventType = prop.arg.content + this.debugLog(`检查事件类型: ${eventType}`) + if (['click', 'submit', 'change', 'input'].includes(eventType)) { + this.debugLog(`匹配事件类型: ${eventType}`) + // 检查事件处理函数 if (prop.exp && this.isMethodCall(prop.exp, methodName)) { + this.debugLog(`找到匹配的方法调用: ${methodName}`) + const context = this.createVisualContext(node, eventType, componentName, methodName, filePath) + this.debugLog(`创建可视上下文:`, context) // 如果找到的是form,需要查找其中的submit按钮 if (context.triggerType === 'form') { + this.debugLog(`找到form,查找submit按钮`) const submitButton = this.findSubmitButtonInForm(node, componentName, methodName, filePath) if (submitButton) { + this.debugLog(`找到submit按钮:`, submitButton) return submitButton } } return context + } else { + this.debugLog(`事件处理函数不匹配: ${methodName}`) } } } @@ -324,14 +428,20 @@ class CallChainTracer { // 递归检查子节点 if (node.children) { + this.debugLog(`递归检查子节点,子节点数量: ${node.children.length}`) + for (const child of node.children) { if (child.type === 1) { // ELEMENT类型 const result = this.findEventBindingInTemplate(child, methodName, componentName, filePath) - if (result) return result + if (result) { + this.debugLog(`在子节点中找到结果:`, result) + return result + } } } } + this.debugLog(`未找到事件绑定`) return null } @@ -388,24 +498,35 @@ class CallChainTracer { * @returns {boolean} 是否是方法调用 */ isMethodCall(exp, methodName) { - if (!exp) return false + this.debugLog(`检查表达式是否是方法调用: ${methodName}`) + this.debugLog(`表达式类型: ${exp.type}`, exp) + + if (!exp) { + this.debugLog(`表达式为空`) + return false + } // 简单的方法调用:methodName if (exp.type === 4 && exp.content === methodName) { // SIMPLE_EXPRESSION + this.debugLog(`匹配简单方法调用: ${methodName}`) return true } // 带参数的方法调用:methodName(...) - 检查content是否以methodName开头 if (exp.type === 4 && exp.content && exp.content.startsWith(methodName + '(')) { + this.debugLog(`匹配带参数的方法调用: ${methodName}`) return true } // 带参数的方法调用:methodName(...) if (exp.type === 8) { // COMPOUND_EXPRESSION + this.debugLog(`检查复合表达式`) const children = exp.children if (children && children.length >= 1) { const firstChild = children[0] + this.debugLog(`第一个子节点:`, firstChild) if (firstChild.type === 4 && firstChild.content === methodName) { + this.debugLog(`匹配复合表达式中的方法调用: ${methodName}`) return true } } @@ -413,9 +534,13 @@ class CallChainTracer { // 检查AST中的方法调用 if (exp.ast) { - return this.checkAstMethodCall(exp.ast, methodName) + this.debugLog(`检查AST中的方法调用`) + const result = this.checkAstMethodCall(exp.ast, methodName) + this.debugLog(`AST检查结果:`, result) + return result } + this.debugLog(`未匹配任何方法调用模式`) return false } diff --git a/gofaster/app/plugins/modules/data-cleaner.js b/gofaster/app/plugins/modules/data-cleaner.js index a859b57..1503844 100644 --- a/gofaster/app/plugins/modules/data-cleaner.js +++ b/gofaster/app/plugins/modules/data-cleaner.js @@ -76,26 +76,14 @@ class DataCleaner { const cleanedApiMappings = [] module.apiMappings.forEach(api => { - if (!api.triggerSources || api.triggerSources.length === 0) { - return - } - - // 1. 只保留triggerType为button的triggerSources - const buttonTriggerSources = api.triggerSources.filter(trigger => { - return trigger.triggerType === 'button' - }) - - // 2. 如果还有button类型的triggerSources,保留这个API - if (buttonTriggerSources.length > 0) { - const cleanedApi = { - ...api, - triggerSources: buttonTriggerSources - } - cleanedApiMappings.push(cleanedApi) + // 仅删除triggerSources列表为空的apiMapping + // 保留所有有triggerSources的apiMapping,不管triggerType是什么 + if (api.triggerSources && api.triggerSources.length > 0) { + cleanedApiMappings.push(api) } }) - // 3. 如果还有apiMappings,保留这个模块 + // 如果还有apiMappings,保留这个模块 if (cleanedApiMappings.length > 0) { const cleanedModule = { ...module, diff --git a/gofaster/app/plugins/modules/trigger-analyzer-simple.js b/gofaster/app/plugins/modules/trigger-analyzer-simple.js index 8df5cc5..210c66f 100644 --- a/gofaster/app/plugins/modules/trigger-analyzer-simple.js +++ b/gofaster/app/plugins/modules/trigger-analyzer-simple.js @@ -125,9 +125,9 @@ class TriggerAnalyzerSimple { return triggerSources } - // 检查组件的authType,如果是瀑布理财则跳过 + // 检查组件的authType,如果是public则跳过 const authType = this.getComponentAuthType(componentName, moduleName) - if (authType === '瀑布理财') { + if (authType === 'public') { return triggerSources } diff --git a/gofaster/app/plugins/route-mapping-plugin.js b/gofaster/app/plugins/route-mapping-plugin.js index e39d02b..d8b4031 100644 --- a/gofaster/app/plugins/route-mapping-plugin.js +++ b/gofaster/app/plugins/route-mapping-plugin.js @@ -149,15 +149,10 @@ function routeMappingPlugin() { // 生成包含triggerSources的文件 this._fileGenerator.generateRouteApiMappingFile(routes, tracedApiMappings) - // ========== 第三步:删除非button(暂时注释) ========== - // const DataCleaner = require('./modules/data-cleaner.js') - // const dataCleaner = new DataCleaner() - // const cleanedMappings = dataCleaner.cleanData() - - // ========== 第五步:改写Vue(暂时注释) ========== - // if (cleanedMappings && cleanedMappings.apiMappings) { - // this._triggerAnalyzer.addButtonAttributesToCleanedData(cleanedMappings.apiMappings) - // } + // ========== 第三步:删除triggerSources为空的apiMapping ========== + const DataCleaner = require('./modules/data-cleaner.js') + const dataCleaner = new DataCleaner() + const cleanedMappings = dataCleaner.cleanData() // 重置生成中标志并更新时间戳 this._generationInProgress = false diff --git a/gofaster/app/src/renderer/modules/route-sync/direct-route-mappings.js b/gofaster/app/src/renderer/modules/route-sync/direct-route-mappings.js index 28d1875..890db18 100644 --- a/gofaster/app/src/renderer/modules/route-sync/direct-route-mappings.js +++ b/gofaster/app/src/renderer/modules/route-sync/direct-route-mappings.js @@ -1,390 +1,322 @@ // 路由映射数据 - 构建时生成 export default { - // 路由配置 - routes: [ - { - "path": "/", - "component": "MainLayout", - "name": "Home", - "description": "首页" - }, - { - "path": "/user-management", - "component": "UserManagement", - "description": "用户管理" - }, - { - "path": "/settings", - "component": "Settings", - "description": "系统设置" - }, - { - "path": "/user-profile", - "component": "UserProfile", - "description": "个人资料" - }, - { - "path": "/role-management", - "component": "RoleManagement", - "description": "角色管理" - } -], - - // API映射配置 - apiMappings: [ - { - "module": "role-management", - "serviceName": "roleService", - "apiMappings": [ - { - "apiMethodName": "getRoles", - "method": "GET", - "path": "/api/auth/roles", - "triggerSources": [ - { - "component": "RoleManagement", - "triggerName": "loadRoles", - "triggerType": "method" - }, - { - "component": "UserRoleAssignment", - "triggerName": "loadRoles", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getRole", - "method": "GET", - "path": "/api/auth/roles/{id}", - "triggerSources": [ - { - "component": "PermissionManager", - "triggerName": "loadRolePermissions", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "createRole", - "method": "POST", - "path": "/api/auth/roles", - "triggerSources": [ - { - "component": "RoleManagement", - "triggerName": "saveRole", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "updateRole", - "method": "PUT", - "path": "/api/auth/roles/{id}", - "triggerSources": [ - { - "component": "RoleManagement", - "triggerName": "saveRole", - "triggerType": "method" - }, - { - "component": "PermissionManager", - "triggerName": "savePermissions", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "deleteRole", - "method": "DELETE", - "path": "/api/auth/roles/{id}", - "triggerSources": [ - { - "component": "RoleManagement", - "triggerName": "deleteRole", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getPermissions", - "method": "GET", - "path": "/api/auth/permissions", - "triggerSources": [ - { - "component": "PermissionManager", - "triggerName": "loadPermissions", - "triggerType": "method" - }, - { - "component": "RolePermissionAssignment", - "triggerName": "loadAllPermissions", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "assignRolesToUser", - "method": "POST", - "path": "/api/auth/roles/users/{userId}/assign", - "triggerSources": [ - { - "component": "UserRoleAssignment", - "triggerName": "saveRoleAssignment", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getUserRoles", - "method": "GET", - "path": "/api/auth/roles/users/{userId}", - "triggerSources": [ - { - "component": "UserRoleAssignment", - "triggerName": "loadUserRoles", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "removeRolesFromUser", - "method": "DELETE", - "path": "/api/auth/roles/users/{userId}/remove", - "triggerSources": [ - { - "component": "UserRoleAssignment", - "triggerName": "saveRoleAssignment", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getRolePermissions", - "method": "GET", - "path": "/api/auth/permissions/roles/{roleId}", - "triggerSources": [ - { - "component": "RolePermissionAssignment", - "triggerName": "loadRolePermissions", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "assignPermissionsToRole", - "method": "POST", - "path": "/api/auth/permissions/roles/{roleId}/assign", - "triggerSources": [ - { - "component": "RolePermissionAssignment", - "triggerName": "assignPermission", - "triggerType": "method" - }, - { - "component": "RolePermissionAssignment", - "triggerName": "assignSelectedPermissions", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "removePermissionsFromRole", - "method": "DELETE", - "path": "/api/auth/permissions/roles/{roleId}/remove", - "triggerSources": [ - { - "component": "RolePermissionAssignment", - "triggerName": "removePermission", - "triggerType": "method" - }, - { - "component": "RolePermissionAssignment", - "triggerName": "removeSelectedPermissions", - "triggerType": "method" - } - ] - } - ] - }, - { - "module": "user-management", - "serviceName": "userService", - "apiMappings": [ - { - "apiMethodName": "getUsers", - "method": "GET", - "path": "/api/auth/admin/users", - "triggerSources": [ - { - "component": "UserManagement", - "triggerName": "loadUsers", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getUser", - "method": "GET", - "path": "/api/auth/admin/users/{id}", - "triggerSources": [] - }, - { - "apiMethodName": "createUser", - "method": "POST", - "path": "/api/auth/admin/users", - "triggerSources": [ - { - "component": "UserManagement", - "triggerName": "submitUser", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "updateUser", - "method": "PUT", - "path": "/api/auth/admin/users/{id}", - "triggerSources": [ - { - "component": "UserManagement", - "triggerName": "submitUser", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "deleteUser", - "method": "DELETE", - "path": "/api/auth/admin/users/{id}", - "triggerSources": [ - { - "component": "UserManagement", - "triggerName": "deleteUser", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getRoles", - "method": "GET", - "path": "/api/auth/admin/roles", - "triggerSources": [] - }, - { - "apiMethodName": "changePassword", - "method": "POST", - "path": "/api/auth/change-password", - "triggerSources": [ - { - "component": "PasswordChangeModal", - "triggerName": "handleSubmit", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "getPasswordPolicy", - "method": "GET", - "path": "/api/auth/password-policy", - "triggerSources": [ - { - "component": "PasswordChangeModal", - "triggerName": "loadPasswordPolicy", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "validatePassword", - "method": "POST", - "path": "/api/auth/validate-password", - "triggerSources": [ - { - "component": "PasswordChangeModal", - "triggerName": "validatePassword", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "checkPasswordStatus", - "method": "GET", - "path": "/api/auth/password-status", - "triggerSources": [] - }, - { - "apiMethodName": "getPermissions", - "method": "GET", - "path": "/api/permissions", - "triggerSources": [] - }, - { - "apiMethodName": "getCaptcha", - "method": "GET", - "path": "/api/auth/captcha", - "triggerSources": [ - { - "component": "LoginModal", - "triggerName": "refreshCaptcha", - "triggerType": "method" - }, - { - "component": "LoginModal", - "triggerName": "refreshCaptchaWithoutClearError", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "login", - "method": "POST", - "path": "/api/auth/login", - "triggerSources": [ - { - "component": "LoginModal", - "triggerName": "handleLogin", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "logout", - "method": "POST", - "path": "/api/auth/logout", - "triggerSources": [] - }, - { - "apiMethodName": "getCurrentUser", - "method": "GET", - "path": "/api/auth/me", - "triggerSources": [ - { - "component": "UserProfile", - "triggerName": "loadUserProfile", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "changePassword", - "method": "POST", - "path": "/api/auth/change-password", - "triggerSources": [ - { - "component": "PasswordChangeModal", - "triggerName": "handleSubmit", - "triggerType": "method" - } - ] - }, - { - "apiMethodName": "resetPassword", - "method": "POST", - "path": "/api/auth/reset-password", - "triggerSources": [] - } - ] - } -] -} \ No newline at end of file + "routes": [ + { + "path": "/", + "component": "MainLayout", + "name": "Home", + "description": "首页" + }, + { + "path": "/user-management", + "component": "UserManagement", + "description": "用户管理" + }, + { + "path": "/settings", + "component": "Settings", + "description": "系统设置" + }, + { + "path": "/user-profile", + "component": "UserProfile", + "description": "个人资料" + }, + { + "path": "/role-management", + "component": "RoleManagement", + "description": "角色管理" + } + ], + "apiMappings": [ + { + "module": "role-management", + "serviceName": "roleService", + "apiMappings": [ + { + "apiMethodName": "getRoles", + "method": "GET", + "path": "/api/auth/roles", + "triggerSources": [ + { + "component": "RoleManagement", + "triggerName": "rolemanagement-submit-vkpa24", + "triggerType": "button" + }, + { + "component": "UserRoleAssignment", + "triggerName": "", + "triggerType": "page" + } + ] + }, + { + "apiMethodName": "getRole", + "method": "GET", + "path": "/api/auth/roles/{id}", + "triggerSources": [ + { + "component": "PermissionManager", + "triggerName": "", + "triggerType": "page" + } + ] + }, + { + "apiMethodName": "createRole", + "method": "POST", + "path": "/api/auth/roles", + "triggerSources": [ + { + "component": "RoleManagement", + "triggerName": "rolemanagement-submit-t64ch2", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "updateRole", + "method": "PUT", + "path": "/api/auth/roles/{id}", + "triggerSources": [ + { + "component": "RoleManagement", + "triggerName": "rolemanagement-submit-5jkynw", + "triggerType": "button" + }, + { + "component": "PermissionManager", + "triggerName": "permissionmanager-button-aemgfa", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "deleteRole", + "method": "DELETE", + "path": "/api/auth/roles/{id}", + "triggerSources": [ + { + "component": "RoleManagement", + "triggerName": "rolemanagement-button-u8kwcq", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "getPermissions", + "method": "GET", + "path": "/api/auth/permissions", + "triggerSources": [ + { + "component": "PermissionManager", + "triggerName": "", + "triggerType": "page" + }, + { + "component": "RolePermissionAssignment", + "triggerName": "", + "triggerType": "page" + } + ] + }, + { + "apiMethodName": "assignRolesToUser", + "method": "POST", + "path": "/api/auth/roles/users/{userId}/assign", + "triggerSources": [ + { + "component": "UserRoleAssignment", + "triggerName": "userroleassignment-button-ws5dcn", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "getUserRoles", + "method": "GET", + "path": "/api/auth/roles/users/{userId}", + "triggerSources": [ + { + "component": "UserRoleAssignment", + "triggerName": "", + "triggerType": "page" + } + ] + }, + { + "apiMethodName": "removeRolesFromUser", + "method": "DELETE", + "path": "/api/auth/roles/users/{userId}/remove", + "triggerSources": [ + { + "component": "UserRoleAssignment", + "triggerName": "userroleassignment-button-dz2004", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "getRolePermissions", + "method": "GET", + "path": "/api/auth/permissions/roles/{roleId}", + "triggerSources": [ + { + "component": "RolePermissionAssignment", + "triggerName": "", + "triggerType": "page" + } + ] + }, + { + "apiMethodName": "assignPermissionsToRole", + "method": "POST", + "path": "/api/auth/permissions/roles/{roleId}/assign", + "triggerSources": [ + { + "component": "RolePermissionAssignment", + "triggerName": "rolepermissionassignment-button-m0nq2i", + "triggerType": "button" + }, + { + "component": "RolePermissionAssignment", + "triggerName": "rolepermissionassignment-button-k2c65f", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "removePermissionsFromRole", + "method": "DELETE", + "path": "/api/auth/permissions/roles/{roleId}/remove", + "triggerSources": [ + { + "component": "RolePermissionAssignment", + "triggerName": "rolepermissionassignment-button-5fs10k", + "triggerType": "button" + }, + { + "component": "RolePermissionAssignment", + "triggerName": "rolepermissionassignment-button-9ld5tc", + "triggerType": "button" + } + ] + } + ] + }, + { + "module": "user-management", + "serviceName": "userService", + "apiMappings": [ + { + "apiMethodName": "getUsers", + "method": "GET", + "path": "/api/auth/admin/users", + "triggerSources": [ + { + "component": "UserManagement", + "triggerName": "usermanagement-a-n900tn", + "triggerType": "element" + } + ] + }, + { + "apiMethodName": "createUser", + "method": "POST", + "path": "/api/auth/admin/users", + "triggerSources": [ + { + "component": "UserManagement", + "triggerName": "usermanagement-submit-2t2744", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "updateUser", + "method": "PUT", + "path": "/api/auth/admin/users/{id}", + "triggerSources": [ + { + "component": "UserManagement", + "triggerName": "usermanagement-submit-goov4g", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "deleteUser", + "method": "DELETE", + "path": "/api/auth/admin/users/{id}", + "triggerSources": [ + { + "component": "UserManagement", + "triggerName": "usermanagement-button-a21wgq", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "changePassword", + "method": "POST", + "path": "/api/auth/change-password", + "triggerSources": [ + { + "component": "PasswordChangeModal", + "triggerName": "passwordchangemodal-submit-y40w1v", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "getPasswordPolicy", + "method": "GET", + "path": "/api/auth/password-policy", + "triggerSources": [ + { + "component": "PasswordChangeModal", + "triggerName": "", + "triggerType": "page" + } + ] + }, + { + "apiMethodName": "validatePassword", + "method": "POST", + "path": "/api/auth/validate-password", + "triggerSources": [ + { + "component": "PasswordChangeModal", + "triggerName": "passwordchangemodal-input-23dc8n", + "triggerType": "input" + } + ] + }, + { + "apiMethodName": "getCurrentUser", + "method": "GET", + "path": "/api/auth/me", + "triggerSources": [ + { + "component": "UserProfile", + "triggerName": "userprofile-button-yfevhp", + "triggerType": "button" + } + ] + }, + { + "apiMethodName": "changePassword", + "method": "POST", + "path": "/api/auth/change-password", + "triggerSources": [ + { + "component": "PasswordChangeModal", + "triggerName": "passwordchangemodal-submit-m67po9", + "triggerType": "button" + } + ] + } + ] + } + ] +}; \ No newline at end of file