Browse Source

中间修改结果暂存

master
hejl 1 day ago
parent
commit
066333c267
  1. 30
      gofaster/app/plugins/modules/api-collector.js
  2. 53
      gofaster/app/plugins/modules/call-chain-tracer.js
  3. 23
      gofaster/app/plugins/modules/file-generator.js
  4. 14
      gofaster/app/plugins/modules/trigger-analyzer-simple.js
  5. 7
      gofaster/app/src/renderer/modules/route-sync/RouteCollector.js
  6. 35
      gofaster/app/src/renderer/modules/route-sync/RouteSyncManager.js
  7. 145
      gofaster/app/src/renderer/modules/route-sync/RouteSyncService.js
  8. 186
      gofaster/app/src/renderer/modules/route-sync/direct-route-mappings.js

30
gofaster/app/plugins/modules/api-collector.js

@ -53,17 +53,26 @@ class ApiCollector {
collectApiMappings(moduleDirs) { collectApiMappings(moduleDirs) {
this.apiMappings = [] this.apiMappings = []
console.log('🔍 开始收集API映射,模块列表:', moduleDirs)
moduleDirs.forEach(moduleName => { moduleDirs.forEach(moduleName => {
console.log(`🔍 处理模块: ${moduleName}`)
const moduleApiMappings = this.collectModuleApiMappings(moduleName) const moduleApiMappings = this.collectModuleApiMappings(moduleName)
console.log(`🔍 模块 ${moduleName} 收集到 ${moduleApiMappings.length} 个API映射`)
if (moduleApiMappings.length > 0) { if (moduleApiMappings.length > 0) {
// 将 serviceName 和 module 下沉到每个 API 映射中
moduleApiMappings.forEach(apiMapping => {
this.apiMappings.push({ this.apiMappings.push({
module: moduleName, ...apiMapping,
serviceName: moduleApiMappings.serviceName, serviceName: moduleApiMappings.serviceName,
apiMappings: moduleApiMappings module: moduleName
})
}) })
} }
}) })
console.log(`🔍 总共收集到 ${this.apiMappings.length} 个API映射`)
return this.apiMappings return this.apiMappings
} }
@ -75,11 +84,16 @@ class ApiCollector {
collectModuleApiMappings(moduleName) { collectModuleApiMappings(moduleName) {
const servicesPath = resolve(__dirname, '../../src/renderer/modules', moduleName, 'services') const servicesPath = resolve(__dirname, '../../src/renderer/modules', moduleName, 'services')
console.log(`🔍 检查服务路径: ${servicesPath}`)
if (!existsSync(servicesPath)) { if (!existsSync(servicesPath)) {
console.log(`🔍 服务路径不存在: ${servicesPath}`)
return [] return []
} }
const serviceFiles = readdirSync(servicesPath).filter(file => file.endsWith('.js')) const serviceFiles = readdirSync(servicesPath).filter(file => file.endsWith('.js'))
console.log(`🔍 找到服务文件:`, serviceFiles)
const moduleApiMappings = [] const moduleApiMappings = []
let firstServiceName = null let firstServiceName = null
@ -88,6 +102,8 @@ class ApiCollector {
const servicePath = resolve(servicesPath, serviceFile) const servicePath = resolve(servicesPath, serviceFile)
const serviceName = serviceFile.replace('.js', '') const serviceName = serviceFile.replace('.js', '')
console.log(`🔍 分析服务文件: ${serviceFile}`)
// 记录第一个服务名称(第一层需要) // 记录第一个服务名称(第一层需要)
if (!firstServiceName) { if (!firstServiceName) {
firstServiceName = serviceName firstServiceName = serviceName
@ -95,18 +111,16 @@ class ApiCollector {
try { try {
const serviceApiMappings = this.analyzeServiceFile(servicePath, serviceName, moduleName) const serviceApiMappings = this.analyzeServiceFile(servicePath, serviceName, moduleName)
console.log(`🔍 服务 ${serviceName} 收集到 ${serviceApiMappings.length} 个API映射`)
// 不再为每个API映射添加serviceName(第二层冗余信息) // 不再为每个API映射添加serviceName(第二层冗余信息)
moduleApiMappings.push(...serviceApiMappings) moduleApiMappings.push(...serviceApiMappings)
} catch (error) { } catch (error) {
// 静默处理错误 console.error(`🔍 分析服务文件失败: ${serviceFile}`, error.message)
} }
}) })
// 为模块API映射添加serviceName(第一层需要) console.log(`🔍 模块 ${moduleName} 总共收集到 ${moduleApiMappings.length} 个API映射`)
if (firstServiceName) { // 返回模块API映射数组,serviceName 将在 collectApiMappings 中添加到每个API映射
moduleApiMappings.serviceName = firstServiceName
}
return moduleApiMappings return moduleApiMappings
} }

53
gofaster/app/plugins/modules/call-chain-tracer.js

@ -10,25 +10,9 @@ const traverse = require('@babel/traverse').default
*/ */
class CallChainTracer { class CallChainTracer {
constructor() { constructor() {
this.debugMode = process.env.ROUTE_MAPPING_DEBUG === 'true' || process.argv.includes('--debug')
this.processedFiles = new Set() // 跟踪已处理的文件,避免重复处理 this.processedFiles = new Set() // 跟踪已处理的文件,避免重复处理
} }
/**
* 调试日志输出
* @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}`)
}
}
}
/** /**
* 清理已处理文件的记录 * 清理已处理文件的记录
@ -36,7 +20,6 @@ class CallChainTracer {
*/ */
clearProcessedFiles() { clearProcessedFiles() {
this.processedFiles.clear() this.processedFiles.clear()
this.debugLog('已清理已处理文件记录')
} }
/** /**
@ -45,8 +28,7 @@ class CallChainTracer {
* @returns {Array} 增强的API映射数组 * @returns {Array} 增强的API映射数组
*/ */
traceMethodTriggersToVisualComponents(apiMappings) { traceMethodTriggersToVisualComponents(apiMappings) {
const enhancedApiMappings = apiMappings.map(module => { const enhancedApiMappings = apiMappings.map(api => {
const enhancedApiMappings = module.apiMappings.map(api => {
if (!api.triggerSources || api.triggerSources.length === 0) { if (!api.triggerSources || api.triggerSources.length === 0) {
return api return api
} }
@ -56,8 +38,8 @@ class CallChainTracer {
if (trigger.triggerType === 'method') { if (trigger.triggerType === 'method') {
const result = this.traceMethodToVisualComponent( const result = this.traceMethodToVisualComponent(
trigger, trigger,
module.module, api.module,
module.serviceName, api.serviceName,
api.apiMethodName api.apiMethodName
) )
return result return result
@ -71,15 +53,10 @@ class CallChainTracer {
} }
}) })
return {
...module,
apiMappings: enhancedApiMappings
}
})
return enhancedApiMappings return enhancedApiMappings
} }
/** /**
* 追溯单个method到可视控件 * 追溯单个method到可视控件
* @param {Object} trigger - 触发源对象 * @param {Object} trigger - 触发源对象
@ -611,19 +588,15 @@ class CallChainTracer {
// 检查文件是否已经被处理过,避免重复处理 // 检查文件是否已经被处理过,避免重复处理
const fileKey = `${filePath}-${nameValue}` const fileKey = `${filePath}-${nameValue}`
if (this.processedFiles.has(fileKey)) { if (this.processedFiles.has(fileKey)) {
this.debugLog(`文件 ${filePath}${nameValue} 已被处理过,跳过`)
return return
} }
const content = readFileSync(filePath, 'utf-8') const content = readFileSync(filePath, 'utf-8')
this.debugLog(`开始修改Vue文件: ${filePath}`)
this.debugLog(`目标节点: ${node.tag}, name: ${nameValue}, type: ${triggerType}`)
// 获取节点的位置信息 // 获取节点的位置信息
const loc = node.loc const loc = node.loc
if (!loc) { if (!loc) {
this.debugLog(`节点没有位置信息,无法修改Vue元素`)
return return
} }
@ -632,7 +605,6 @@ class CallChainTracer {
const endLine = loc.end.line const endLine = loc.end.line
const endColumn = loc.end.column const endColumn = loc.end.column
this.debugLog(`节点位置: 第${startLine}行第${startColumn}列 到 第${endLine}行第${endColumn}`)
const lines = content.split('\n') const lines = content.split('\n')
@ -640,7 +612,6 @@ class CallChainTracer {
const targetLine = lines[startLine - 1] const targetLine = lines[startLine - 1]
if (targetLine.includes(`name="`) || targetLine.includes(`name='`) || if (targetLine.includes(`name="`) || targetLine.includes(`name='`) ||
targetLine.includes(`:visible="false"`) || targetLine.includes(`:visible='false'`)) { targetLine.includes(`:visible="false"`) || targetLine.includes(`:visible='false'`)) {
this.debugLog(`元素已包含name或:visible属性,跳过修改`)
return return
} }
@ -659,12 +630,9 @@ class CallChainTracer {
// 标记文件为已处理 // 标记文件为已处理
this.processedFiles.add(fileKey) this.processedFiles.add(fileKey)
this.debugLog(`已成功修改Vue文件: ${filePath}`)
this.debugLog(`添加的属性: name="${nameValue}"${triggerType === 'button' ? ', :visible="false"' : ', :disabled="true"'}`)
} catch (error) { } catch (error) {
this.debugLog(`修改Vue元素时出错:`, error.message) // 静默处理错误
this.debugLog(`错误堆栈:`, error.stack)
} }
} }
@ -679,12 +647,10 @@ class CallChainTracer {
*/ */
modifySingleLineElement(lines, lineIndex, startCol, endCol, nameValue, triggerType) { modifySingleLineElement(lines, lineIndex, startCol, endCol, nameValue, triggerType) {
const line = lines[lineIndex] const line = lines[lineIndex]
this.debugLog(`修改单行元素: ${line}`)
// 检查是否已经存在name属性或:visible属性,避免重复修改 // 检查是否已经存在name属性或:visible属性,避免重复修改
if (line.includes(`name="`) || line.includes(`name='`) || if (line.includes(`name="`) || line.includes(`name='`) ||
line.includes(`:visible="false"`) || line.includes(`:visible='false'`)) { line.includes(`:visible="false"`) || line.includes(`:visible='false'`)) {
this.debugLog(`单行元素已包含name或:visible属性,跳过修改`)
return return
} }
@ -706,7 +672,6 @@ class CallChainTracer {
} }
lines[lineIndex] = `${beforeTag}${newAttributes}${afterTag}` lines[lineIndex] = `${beforeTag}${newAttributes}${afterTag}`
this.debugLog(`单行元素修改完成: ${lines[lineIndex]}`)
} }
} }
@ -722,7 +687,6 @@ class CallChainTracer {
*/ */
modifyMultiLineElement(lines, startLineIndex, startCol, endLineIndex, endCol, nameValue, triggerType) { modifyMultiLineElement(lines, startLineIndex, startCol, endLineIndex, endCol, nameValue, triggerType) {
const startLine = lines[startLineIndex] const startLine = lines[startLineIndex]
this.debugLog(`修改多行元素开始行: ${startLine}`)
// 检查整个多行元素是否已经存在name属性或:visible属性,避免重复修改 // 检查整个多行元素是否已经存在name属性或:visible属性,避免重复修改
let hasExistingAttributes = false let hasExistingAttributes = false
@ -736,7 +700,6 @@ class CallChainTracer {
} }
if (hasExistingAttributes) { if (hasExistingAttributes) {
this.debugLog(`多行元素已包含name或:visible属性,跳过修改`)
return return
} }
@ -748,14 +711,12 @@ class CallChainTracer {
// 如果当前行没有找到结束标签,查找后续行 // 如果当前行没有找到结束标签,查找后续行
if (tagStart !== -1 && tagEnd === -1) { if (tagStart !== -1 && tagEnd === -1) {
this.debugLog(`当前行没有找到结束标签,查找后续行`)
for (let i = startLineIndex; i <= endLineIndex && i < lines.length; i++) { for (let i = startLineIndex; i <= endLineIndex && i < lines.length; i++) {
const line = lines[i] const line = lines[i]
const endPos = line.indexOf('>') const endPos = line.indexOf('>')
if (endPos !== -1) { if (endPos !== -1) {
tagEnd = endPos tagEnd = endPos
tagEndLineIndex = i tagEndLineIndex = i
this.debugLog(`在第${i + 1}行找到结束标签,位置: ${endPos}`)
break break
} }
} }
@ -776,12 +737,9 @@ class CallChainTracer {
const afterEndTag = endLine.substring(tagEnd) const afterEndTag = endLine.substring(tagEnd)
lines[tagEndLineIndex] = `${beforeEndTag}${newAttributes}${afterEndTag}` lines[tagEndLineIndex] = `${beforeEndTag}${newAttributes}${afterEndTag}`
this.debugLog(`多行元素修改完成: ${lines[tagEndLineIndex]}`)
} else { } else {
this.debugLog(`未找到有效的标签位置: tagStart=${tagStart}, tagEnd=${tagEnd}`)
// 如果找不到结束标签,尝试在开始标签后直接添加 // 如果找不到结束标签,尝试在开始标签后直接添加
if (tagStart !== -1) { if (tagStart !== -1) {
this.debugLog(`尝试在开始标签后直接添加属性`)
const beforeTag = startLine.substring(0, tagStart + 1) // 包含 < 字符 const beforeTag = startLine.substring(0, tagStart + 1) // 包含 < 字符
const afterTag = startLine.substring(tagStart + 1) const afterTag = startLine.substring(tagStart + 1)
@ -793,7 +751,6 @@ class CallChainTracer {
} }
lines[startLineIndex] = `${beforeTag}${newAttributes} ${afterTag}` lines[startLineIndex] = `${beforeTag}${newAttributes} ${afterTag}`
this.debugLog(`多行元素修改完成(备用方案): ${lines[startLineIndex]}`)
} }
} }
} }

23
gofaster/app/plugins/modules/file-generator.js

@ -139,20 +139,18 @@ export default {
* @returns {Array} 瘦身后的API映射数组 * @returns {Array} 瘦身后的API映射数组
*/ */
slimApiMappings(apiMappings) { slimApiMappings(apiMappings) {
return apiMappings.map(moduleMapping => ({ return apiMappings.map(api => ({
module: moduleMapping.module,
serviceName: moduleMapping.serviceName,
apiMappings: moduleMapping.apiMappings.map(api => ({
apiMethodName: api.apiMethodName, apiMethodName: api.apiMethodName,
method: api.method, method: api.method,
path: api.path, path: api.path,
serviceName: api.serviceName,
module: api.module,
triggerSources: api.triggerSources.map(trigger => ({ triggerSources: api.triggerSources.map(trigger => ({
component: trigger.component, component: trigger.component,
triggerName: trigger.triggerName, triggerName: trigger.triggerName,
triggerType: trigger.triggerType triggerType: trigger.triggerType
})) }))
})) }))
}))
} }
/** /**
@ -164,10 +162,7 @@ export default {
const optimizedApiMappings = [] const optimizedApiMappings = []
let totalRemoved = 0 let totalRemoved = 0
apiMappings.forEach(moduleMapping => { apiMappings.forEach(apiMapping => {
const deduplicatedApiMappings = []
moduleMapping.apiMappings.forEach(apiMapping => {
// 删除无触发器的API映射 // 删除无触发器的API映射
if (!apiMapping.triggerSources || apiMapping.triggerSources.length === 0) { if (!apiMapping.triggerSources || apiMapping.triggerSources.length === 0) {
totalRemoved++ totalRemoved++
@ -177,20 +172,12 @@ export default {
// 去重触发器源 // 去重触发器源
const uniqueTriggerSources = this.deduplicateTriggerSources(apiMapping.triggerSources) const uniqueTriggerSources = this.deduplicateTriggerSources(apiMapping.triggerSources)
deduplicatedApiMappings.push({ optimizedApiMappings.push({
...apiMapping, ...apiMapping,
triggerSources: uniqueTriggerSources triggerSources: uniqueTriggerSources
}) })
}) })
if (deduplicatedApiMappings.length > 0) {
optimizedApiMappings.push({
...moduleMapping,
apiMappings: deduplicatedApiMappings
})
}
})
return optimizedApiMappings return optimizedApiMappings
} }

14
gofaster/app/plugins/modules/trigger-analyzer-simple.js

@ -20,13 +20,12 @@ class TriggerAnalyzerSimple {
* @returns {Array} 增强的API映射数组 * @returns {Array} 增强的API映射数组
*/ */
findTriggerSourcesForApiMappings(apiMappings, routes) { findTriggerSourcesForApiMappings(apiMappings, routes) {
const enhancedApiMappings = apiMappings.map(module => { const enhancedApiMappings = apiMappings.map(api => {
const enhancedApiMappings = module.apiMappings.map(api => {
// 查找该API的触发源 // 查找该API的触发源
const triggerSources = this.findTriggerSourcesForApiMethod( const triggerSources = this.findTriggerSourcesForApiMethod(
module.serviceName, api.serviceName,
api.apiMethodName, api.apiMethodName,
module.module api.module
) )
return { return {
@ -35,15 +34,10 @@ class TriggerAnalyzerSimple {
} }
}) })
return {
...module,
apiMappings: enhancedApiMappings
}
})
return enhancedApiMappings return enhancedApiMappings
} }
/** /**
* 查找API方法的触发源 * 查找API方法的触发源
* @param {string} serviceName - 服务名称 * @param {string} serviceName - 服务名称

7
gofaster/app/src/renderer/modules/route-sync/RouteCollector.js

@ -69,9 +69,8 @@ export class RouteCollector {
if (moduleMapping.module === route.module) { if (moduleMapping.module === route.module) {
moduleMapping.apiMappings.forEach(apiMapping => { moduleMapping.apiMappings.forEach(apiMapping => {
// 检查API调用是否与当前路由相关 // 检查API调用是否与当前路由相关
const isRelated = apiMapping.callingComponents.some(component => const isRelated = apiMapping.triggerSources.some(trigger =>
component.component === route.component || trigger.component === route.component
component.path === route.path
) )
if (isRelated) { if (isRelated) {
@ -79,7 +78,7 @@ export class RouteCollector {
type: 'api', type: 'api',
method: apiMapping.method, method: apiMapping.method,
path: apiMapping.path, path: apiMapping.path,
methodName: apiMapping.methodName, methodName: apiMapping.apiMethodName,
serviceName: moduleMapping.serviceName serviceName: moduleMapping.serviceName
}) })
} }

35
gofaster/app/src/renderer/modules/route-sync/RouteSyncManager.js

@ -80,33 +80,21 @@ export class RouteSyncManager {
try { try {
console.log('🔄 开始执行初始路由同步...') console.log('🔄 开始执行初始路由同步...')
// 收集前端路由 // 直接从 direct-route-mappings.js 文件同步
const frontendRoutes = this.routeCollector.collectRoutes() const directMappings = await this._loadDirectMappings()
// console.log(`📊 收集到 ${frontendRoutes.length} 个前端路由:`, frontendRoutes)
if (frontendRoutes.length === 0) { if (!directMappings) {
console.error('❌ 没有收集到前端路由') console.error('❌ 无法加载 direct-route-mappings.js 文件')
return
}
// 生成路由映射
const routeMappings = this.routeMapper.generateRouteMappings(frontendRoutes)
// console.log(`📊 生成了 ${routeMappings.length} 个路由映射:`, routeMappings)
if (routeMappings.length === 0) {
console.error('❌ 没有生成路由映射')
// console.log('🔍 调试信息:')
// console.log(' - frontendRoutes:', frontendRoutes)
// console.log(' - routeMapper:', this.routeMapper)
return return
} }
// 同步到后端 // 同步到后端
console.log('🔄 开始同步到后端...') console.log('🔄 开始同步到后端...')
const result = await this.routeSyncService.syncRoutes(routeMappings) const result = await this.routeSyncService.syncFromDirectMappings(directMappings)
if (result.success) { if (result.success) {
console.log('✅ 初始路由同步成功') console.log('✅ 初始路由同步成功')
console.log(`📊 同步了 ${Object.keys(result.details).length} 个模块`)
} else { } else {
console.error('❌ 初始路由同步失败:', result.errors) console.error('❌ 初始路由同步失败:', result.errors)
} }
@ -116,6 +104,17 @@ export class RouteSyncManager {
} }
} }
// 加载 direct-route-mappings.js 文件
async _loadDirectMappings() {
try {
const { default: directMappings } = await import('./direct-route-mappings.js')
return directMappings
} catch (error) {
console.error('❌ 加载 direct-route-mappings.js 失败:', error)
return null
}
}
// 停止同步 // 停止同步
stop() { stop() {
if (this.syncTimer) { if (this.syncTimer) {

145
gofaster/app/src/renderer/modules/route-sync/RouteSyncService.js

@ -54,6 +54,45 @@ export class RouteSyncService {
} }
} }
// 从 direct-route-mappings.js 格式同步路由
async syncFromDirectMappings(directMappings) {
try {
if (!directMappings || !directMappings.routes || !directMappings.apiMappings) {
return { success: false, errors: ['direct-route-mappings.js 格式不正确'] }
}
const results = {
success: true,
errors: [],
details: {}
}
// 处理每个模块的API映射
for (const moduleMapping of directMappings.apiMappings) {
try {
const result = await this._syncModuleFromDirectMappings(moduleMapping, directMappings.routes)
results.details[moduleMapping.module] = result
if (!result.success) {
results.success = false
results.errors.push(...result.errors)
}
} catch (error) {
results.success = false
results.errors.push(`模块 "${moduleMapping.module}" 同步失败: ${error.message}`)
results.details[moduleMapping.module] = { success: false, error: error.message }
}
}
return results
} catch (error) {
return {
success: false,
errors: [`同步失败: ${error.message}`]
}
}
}
// 按模块分组映射 // 按模块分组映射
_groupMappingsByModule(mappings) { _groupMappingsByModule(mappings) {
const groups = {} const groups = {}
@ -102,7 +141,113 @@ export class RouteSyncService {
} }
} }
// 从 direct-route-mappings 格式同步单个模块
async _syncModuleFromDirectMappings(moduleMapping, routes) {
try {
// 构建前端路由数据 // 构建前端路由数据
const frontendRouteData = this._buildFrontendRouteDataFromDirectMappings(moduleMapping, routes)
if (frontendRouteData.length === 0) {
return { success: false, errors: [`模块 "${moduleMapping.module}" 没有有效的前端路由数据`] }
}
// 发送到后端
const response = await this.axios.post('/api/frontend-routes/batch-sync', frontendRouteData)
return {
success: true,
data: response.data,
count: frontendRouteData.length
}
} catch (error) {
if (error.response) {
return {
success: false,
errors: [`HTTP ${error.response.status}: ${error.response.data?.message || error.message}`]
}
} else {
return {
success: false,
errors: [`网络错误: ${error.message}`]
}
}
}
}
// 从 direct-route-mappings 格式构建前端路由数据
_buildFrontendRouteDataFromDirectMappings(moduleMapping, routes) {
const frontendRouteGroups = {}
// 根据模块名称推断对应的路由路径
const modulePathMap = {
'role-management': '/role-management',
'user-management': '/user-management',
'user-profile': '/user-profile',
'settings': '/settings'
}
const modulePath = modulePathMap[moduleMapping.module]
if (!modulePath) {
console.warn(` 未找到模块 "${moduleMapping.module}" 对应的路由路径`)
return []
}
// 找到该模块对应的路由
const moduleRoutes = routes.filter(route => route.path === modulePath)
// 为每个路由创建基础结构
moduleRoutes.forEach(route => {
frontendRouteGroups[route.path] = {
path: route.path,
name: route.name || route.component,
component: route.component,
module: moduleMapping.module,
description: route.description || `${route.name || route.component}页面`,
sort: this._generateSort(moduleMapping.module),
backend_routes: []
}
})
// 处理API映射
moduleMapping.apiMappings.forEach(apiMapping => {
// 为每个 triggerSource 创建后端路由关联
apiMapping.triggerSources.forEach(trigger => {
// 找到对应的前端路由
const frontendRoute = moduleRoutes.find(route => route.component === trigger.component)
if (frontendRoute && frontendRouteGroups[frontendRoute.path]) {
// 检查是否已存在相同的后端路由
const existingRoute = frontendRouteGroups[frontendRoute.path].backend_routes.find(
route => route.backend_route === apiMapping.path &&
route.http_method === apiMapping.method
)
if (!existingRoute) {
frontendRouteGroups[frontendRoute.path].backend_routes.push({
backend_route: apiMapping.path,
http_method: apiMapping.method,
module: moduleMapping.module,
description: apiMapping.apiMethodName || 'unknown'
})
}
}
})
})
return Object.values(frontendRouteGroups)
}
// 生成排序值
_generateSort(module) {
const moduleSortMap = {
'user-management': 1,
'role-management': 2,
'system-settings': 3
}
return moduleSortMap[module] || 99
}
// 构建前端路由数据(原有方法,保持兼容性)
_buildFrontendRouteData(module, mappings) { _buildFrontendRouteData(module, mappings) {
const frontendRouteGroups = {} const frontendRouteGroups = {}

186
gofaster/app/src/renderer/modules/route-sync/direct-route-mappings.js

@ -28,189 +28,5 @@ export default {
"description": "角色管理" "description": "角色管理"
} }
], ],
"apiMappings": [ "apiMappings": []
{
"module": "role-management",
"serviceName": "roleService",
"apiMappings": [
{
"apiMethodName": "createRole",
"method": "POST",
"path": "/api/auth/roles",
"triggerSources": [
{
"component": "RoleManagement",
"triggerName": "rolemanagement-submit-lhm6fs",
"triggerType": "button"
}
]
},
{
"apiMethodName": "updateRole",
"method": "PUT",
"path": "/api/auth/roles/{id}",
"triggerSources": [
{
"component": "RoleManagement",
"triggerName": "rolemanagement-submit-lhm6fs",
"triggerType": "button"
},
{
"component": "PermissionManager",
"triggerName": "permissionmanager-button-k7wqyp",
"triggerType": "button"
}
]
},
{
"apiMethodName": "deleteRole",
"method": "DELETE",
"path": "/api/auth/roles/{id}",
"triggerSources": [
{
"component": "RoleManagement",
"triggerName": "rolemanagement-button-0eqx80",
"triggerType": "button"
}
]
},
{
"apiMethodName": "assignRolesToUser",
"method": "POST",
"path": "/api/auth/roles/users/{userId}/assign",
"triggerSources": [
{
"component": "UserRoleAssignment",
"triggerName": "userroleassignment-button-3npmn8",
"triggerType": "button"
}
]
},
{
"apiMethodName": "removeRolesFromUser",
"method": "DELETE",
"path": "/api/auth/roles/users/{userId}/remove",
"triggerSources": [
{
"component": "UserRoleAssignment",
"triggerName": "userroleassignment-button-3npmn8",
"triggerType": "button"
}
]
},
{
"apiMethodName": "assignPermissionsToRole",
"method": "POST",
"path": "/api/auth/permissions/roles/{roleId}/assign",
"triggerSources": [
{
"component": "RolePermissionAssignment",
"triggerName": "rolepermissionassignment-button-7uizm5",
"triggerType": "button"
},
{
"component": "RolePermissionAssignment",
"triggerName": "rolepermissionassignment-button-a0nyh8",
"triggerType": "button"
}
]
},
{
"apiMethodName": "removePermissionsFromRole",
"method": "DELETE",
"path": "/api/auth/permissions/roles/{roleId}/remove",
"triggerSources": [
{
"component": "RolePermissionAssignment",
"triggerName": "rolepermissionassignment-button-q86qi4",
"triggerType": "button"
},
{
"component": "RolePermissionAssignment",
"triggerName": "rolepermissionassignment-button-sj6qb7",
"triggerType": "button"
}
]
}
]
},
{
"module": "user-management",
"serviceName": "userService",
"apiMappings": [
{
"apiMethodName": "createUser",
"method": "POST",
"path": "/api/auth/admin/users",
"triggerSources": [
{
"component": "UserManagement",
"triggerName": "usermanagement-submit-fksbqh",
"triggerType": "button"
}
]
},
{
"apiMethodName": "updateUser",
"method": "PUT",
"path": "/api/auth/admin/users/{id}",
"triggerSources": [
{
"component": "UserManagement",
"triggerName": "usermanagement-submit-fksbqh",
"triggerType": "button"
}
]
},
{
"apiMethodName": "deleteUser",
"method": "DELETE",
"path": "/api/auth/admin/users/{id}",
"triggerSources": [
{
"component": "UserManagement",
"triggerName": "usermanagement-button-tvncrr",
"triggerType": "button"
}
]
},
{
"apiMethodName": "changePassword",
"method": "POST",
"path": "/api/auth/change-password",
"triggerSources": [
{
"component": "PasswordChangeModal",
"triggerName": "passwordchangemodal-submit-2p704c",
"triggerType": "button"
}
]
},
{
"apiMethodName": "validatePassword",
"method": "POST",
"path": "/api/auth/validate-password",
"triggerSources": [
{
"component": "PasswordChangeModal",
"triggerName": "passwordchangemodal-input-b0ca4h",
"triggerType": "input"
}
]
},
{
"apiMethodName": "changePassword",
"method": "POST",
"path": "/api/auth/change-password",
"triggerSources": [
{
"component": "PasswordChangeModal",
"triggerName": "passwordchangemodal-submit-2p704c",
"triggerType": "button"
}
]
}
]
}
]
}; };
Loading…
Cancel
Save