|
|
|
@ -13819,10 +13819,12 @@ __webpack_require__.r(__webpack_exports__);
@@ -13819,10 +13819,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
|
|
|
/* harmony export */ RouteCollector: () => (/* binding */ RouteCollector) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
/* harmony import */ var _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generated-route-mapping.js */ "./src/renderer/modules/route-sync/generated-route-mapping.js"); |
|
|
|
|
Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()); |
|
|
|
|
/* harmony import */ var _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RouteConfig.js */ "./src/renderer/modules/route-sync/RouteConfig.js"); |
|
|
|
|
// 路由收集器 - 收集前端路由信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 路由收集器
|
|
|
|
|
class RouteCollector { |
|
|
|
|
constructor() { |
|
|
|
@ -13833,16 +13835,16 @@ class RouteCollector {
@@ -13833,16 +13835,16 @@ class RouteCollector {
|
|
|
|
|
collectRoutes() { |
|
|
|
|
try { |
|
|
|
|
// 从生成的路由映射文件收集
|
|
|
|
|
if (!_generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__.mainRoutes || !Array.isArray(_generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__.mainRoutes)) { |
|
|
|
|
if (!Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()) || !Array.isArray(Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()))) { |
|
|
|
|
console.warn('⚠️ 生成的路由映射文件格式不正确') |
|
|
|
|
return [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 转换为主入口路由格式
|
|
|
|
|
const frontendRoutes = _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__.mainRoutes.map(route => { |
|
|
|
|
const frontendRoutes = Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()).map(route => { |
|
|
|
|
// 确保模块信息正确
|
|
|
|
|
if (!route.module) { |
|
|
|
|
route.module = this._extractModuleFromPath(route.path) |
|
|
|
|
route.module = _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.extractModuleFromPath(route.path) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
@ -13862,28 +13864,6 @@ class RouteCollector {
@@ -13862,28 +13864,6 @@ class RouteCollector {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 从路径提取模块名
|
|
|
|
|
_extractModuleFromPath(path) { |
|
|
|
|
if (path === '/' || path === '') return 'home' |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) return 'home' |
|
|
|
|
|
|
|
|
|
// 获取第一个段作为模块名
|
|
|
|
|
const module = segments[0] |
|
|
|
|
|
|
|
|
|
// 映射模块名
|
|
|
|
|
const moduleMap = { |
|
|
|
|
'user-management': 'user-management', |
|
|
|
|
'role-management': 'role-management', |
|
|
|
|
'settings': 'system-settings', |
|
|
|
|
'user-profile': 'user-management', |
|
|
|
|
'route-sync': 'route-sync' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return moduleMap[module] || module |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取菜单路由
|
|
|
|
|
getMenuRoutes() { |
|
|
|
|
return this.routes.filter(route => route.name && route.name !== '') |
|
|
|
@ -13911,6 +13891,139 @@ class RouteCollector {
@@ -13911,6 +13891,139 @@ class RouteCollector {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }), |
|
|
|
|
|
|
|
|
|
/***/ "./src/renderer/modules/route-sync/RouteConfig.js": |
|
|
|
|
/*!********************************************************!*\ |
|
|
|
|
!*** ./src/renderer/modules/route-sync/RouteConfig.js ***! |
|
|
|
|
\********************************************************/ |
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
|
|
|
|
|
|
|
|
|
"use strict"; |
|
|
|
|
__webpack_require__.r(__webpack_exports__); |
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
|
|
|
/* harmony export */ RouteConfig: () => (/* binding */ RouteConfig), |
|
|
|
|
/* harmony export */ RouteUtils: () => (/* binding */ RouteUtils) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
// 路由配置和映射 - 统一管理所有路由相关的配置
|
|
|
|
|
const RouteConfig = { |
|
|
|
|
// 路由描述映射
|
|
|
|
|
descriptions: { |
|
|
|
|
'home': '首页', |
|
|
|
|
'user-management': '用户管理', |
|
|
|
|
'role-management': '角色管理', |
|
|
|
|
'system-settings': '系统设置', |
|
|
|
|
'route-sync': '路由同步测试' |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 路由类型映射
|
|
|
|
|
typeMap: { |
|
|
|
|
'user-management': 'list', |
|
|
|
|
'role-management': 'list', |
|
|
|
|
'system-settings': 'form', |
|
|
|
|
'route-sync': 'test' |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 排序值映射
|
|
|
|
|
sortMap: { |
|
|
|
|
'home': 1, |
|
|
|
|
'user-management': 10, |
|
|
|
|
'role-management': 20, |
|
|
|
|
'system-settings': 30, |
|
|
|
|
'route-sync': 100 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 路由工具类
|
|
|
|
|
class RouteUtils { |
|
|
|
|
// 从路径提取模块名
|
|
|
|
|
static extractModuleFromPath(path) { |
|
|
|
|
if (path === '/' || path === '') { |
|
|
|
|
return 'core' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) { |
|
|
|
|
return 'core' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const firstPart = segments[0] |
|
|
|
|
return firstPart |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成路由描述
|
|
|
|
|
static generateDescription(name, module) { |
|
|
|
|
return RouteConfig.descriptions[module] || `${name}页面` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 确定路由类型
|
|
|
|
|
static determineRouteType(path, module) { |
|
|
|
|
if (path === '/' || path === '') return 'home' |
|
|
|
|
return RouteConfig.typeMap[module] || 'list' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成排序值
|
|
|
|
|
static generateSort(module) { |
|
|
|
|
return RouteConfig.sortMap[module] || 50 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 提取路由名称
|
|
|
|
|
static extractRouteName(path) { |
|
|
|
|
if (path === '/' || path === '') return 'Home' |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) return 'Home' |
|
|
|
|
|
|
|
|
|
const lastSegment = segments[segments.length - 1] |
|
|
|
|
return lastSegment.charAt(0).toUpperCase() + lastSegment.slice(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成组件名称
|
|
|
|
|
static generateComponent(path, module) { |
|
|
|
|
if (path === '/' || path === '') return 'Home' |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) return 'Home' |
|
|
|
|
|
|
|
|
|
const lastSegment = segments[segments.length - 1] |
|
|
|
|
const componentName = lastSegment.charAt(0).toUpperCase() + lastSegment.slice(1) |
|
|
|
|
|
|
|
|
|
// 特殊处理某些路径
|
|
|
|
|
if (path === '/route-sync') { |
|
|
|
|
return 'RouteSync' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return componentName |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 验证映射
|
|
|
|
|
static validateMapping(mapping, index) { |
|
|
|
|
const errors = [] |
|
|
|
|
|
|
|
|
|
if (!mapping.frontend_route) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少前端路由`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!mapping.backend_route) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少后端路由`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!mapping.http_method) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少HTTP方法`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!mapping.module) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少模块信息`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
isValid: errors.length === 0, |
|
|
|
|
errors: errors |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }), |
|
|
|
|
|
|
|
|
|
/***/ "./src/renderer/modules/route-sync/RouteMapper.js": |
|
|
|
@ -13924,52 +14037,15 @@ __webpack_require__.r(__webpack_exports__);
@@ -13924,52 +14037,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
|
|
|
/* harmony export */ RouteMapper: () => (/* binding */ RouteMapper) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
/* harmony import */ var _RouteUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./RouteUtils.js */ "./src/renderer/modules/route-sync/RouteUtils.js"); |
|
|
|
|
/* harmony import */ var _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./generated-route-mapping.js */ "./src/renderer/modules/route-sync/generated-route-mapping.js"); |
|
|
|
|
/* harmony import */ var _RouteConfig_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./RouteConfig.js */ "./src/renderer/modules/route-sync/RouteConfig.js"); |
|
|
|
|
Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()); |
|
|
|
|
// 路由映射器 - 将前端路由映射到后端API
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RouteMapper { |
|
|
|
|
constructor() { |
|
|
|
|
this.defaultApiMappings = { |
|
|
|
|
'user-management': { |
|
|
|
|
basePath: '/auth/admin/users', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
create: { path: '', method: 'POST' }, |
|
|
|
|
update: { path: '/:id', method: 'PUT' }, |
|
|
|
|
delete: { path: '/:id', method: 'DELETE' }, |
|
|
|
|
detail: { path: '/:id', method: 'GET' }, |
|
|
|
|
getRoles: { path: '/roles', method: 'GET' } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'role-management': { |
|
|
|
|
basePath: '/auth/roles', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
create: { path: '', method: 'POST' }, |
|
|
|
|
update: { path: '/:id', method: 'PUT' }, |
|
|
|
|
delete: { path: '/:id', method: 'DELETE' }, |
|
|
|
|
detail: { path: '/:id', method: 'GET' } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'system-settings': { |
|
|
|
|
basePath: '/auth/settings', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
update: { path: '', method: 'PUT' } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'route-sync': { |
|
|
|
|
basePath: '/auth/route-sync', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
test: { path: '/test', method: 'POST' }, |
|
|
|
|
status: { path: '/status', method: 'GET' } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.defaultApiMappings = _RouteConfig_js__WEBPACK_IMPORTED_MODULE_0__.RouteConfig.defaultApiMappings |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成路由映射
|
|
|
|
@ -14044,25 +14120,45 @@ class RouteMapper {
@@ -14044,25 +14120,45 @@ class RouteMapper {
|
|
|
|
|
// 获取子路由映射
|
|
|
|
|
_getSubRouteMapping(routePath) { |
|
|
|
|
try { |
|
|
|
|
return _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_1__.subRouteMappings[routePath] || null |
|
|
|
|
return Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())[routePath] || null |
|
|
|
|
} catch (error) { |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取模块的API配置
|
|
|
|
|
// 获取模块的API配置 - 合并生成的文件和默认配置
|
|
|
|
|
_getApiConfigForModule(module) { |
|
|
|
|
let apiConfig = null |
|
|
|
|
|
|
|
|
|
// 首先尝试从生成的路由映射文件获取
|
|
|
|
|
try { |
|
|
|
|
if (_generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_1__.moduleApiMappings && _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_1__.moduleApiMappings[module]) { |
|
|
|
|
return _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_1__.moduleApiMappings[module] |
|
|
|
|
if (Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()) && Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())[module]) { |
|
|
|
|
apiConfig = { ...Object(function webpackMissingModule() { var e = new Error("Cannot find module './generated-route-mapping.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())[module] } |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
// 如果获取失败,使用默认配置
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 使用默认配置
|
|
|
|
|
return this.defaultApiMappings[module] |
|
|
|
|
// 如果没有从生成文件获取到,使用默认配置
|
|
|
|
|
if (!apiConfig) { |
|
|
|
|
apiConfig = { ...this.defaultApiMappings[module] } |
|
|
|
|
} else { |
|
|
|
|
// 合并默认配置中的缺失操作
|
|
|
|
|
const defaultConfig = this.defaultApiMappings[module] |
|
|
|
|
if (defaultConfig && defaultConfig.operations) { |
|
|
|
|
if (!apiConfig.operations) { |
|
|
|
|
apiConfig.operations = {} |
|
|
|
|
} |
|
|
|
|
// 只添加生成文件中没有的操作
|
|
|
|
|
Object.keys(defaultConfig.operations).forEach(operation => { |
|
|
|
|
if (!apiConfig.operations[operation]) { |
|
|
|
|
apiConfig.operations[operation] = defaultConfig.operations[operation] |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return apiConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 验证映射完整性
|
|
|
|
@ -14070,17 +14166,9 @@ class RouteMapper {
@@ -14070,17 +14166,9 @@ class RouteMapper {
|
|
|
|
|
const errors = [] |
|
|
|
|
|
|
|
|
|
mappings.forEach((mapping, index) => { |
|
|
|
|
if (!mapping.frontend_route) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少前端路由`) |
|
|
|
|
} |
|
|
|
|
if (!mapping.backend_route) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少后端路由`) |
|
|
|
|
} |
|
|
|
|
if (!mapping.http_method) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少HTTP方法`) |
|
|
|
|
} |
|
|
|
|
if (!mapping.module) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少模块信息`) |
|
|
|
|
const validation = _RouteConfig_js__WEBPACK_IMPORTED_MODULE_0__.RouteUtils.validateMapping(mapping, index) |
|
|
|
|
if (!validation.isValid) { |
|
|
|
|
errors.push(...validation.errors) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
@ -14156,11 +14244,6 @@ class RouteSyncManager {
@@ -14156,11 +14244,6 @@ class RouteSyncManager {
|
|
|
|
|
await this.performInitialSync() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 注释掉定时同步,只执行一次初始同步
|
|
|
|
|
// if (this.config.syncInterval > 0) {
|
|
|
|
|
// this.setupPeriodicSync()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
this.isInitialized = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -14196,90 +14279,6 @@ class RouteSyncManager {
@@ -14196,90 +14279,6 @@ class RouteSyncManager {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 重试同步
|
|
|
|
|
async retrySync(attempt = 1) { |
|
|
|
|
if (attempt > this.config.retryAttempts) { |
|
|
|
|
console.error(`❌ 重试次数已达上限 (${this.config.retryAttempts})`) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
await new Promise(resolve => setTimeout(resolve, this.config.retryDelay)) |
|
|
|
|
|
|
|
|
|
const frontendRoutes = this.routeCollector.collectRoutes() |
|
|
|
|
const routeMappings = this.routeMapper.generateRouteMappings(frontendRoutes) |
|
|
|
|
const result = await this.routeSyncService.syncRoutes(routeMappings) |
|
|
|
|
|
|
|
|
|
if (result.success) { |
|
|
|
|
return true |
|
|
|
|
} else { |
|
|
|
|
return await this.retrySync(attempt + 1) |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(`❌ 重试同步失败 (${attempt}/${this.config.retryAttempts}):`, error) |
|
|
|
|
return await this.retrySync(attempt + 1) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 设置定时同步
|
|
|
|
|
setupPeriodicSync() { |
|
|
|
|
if (this.syncTimer) { |
|
|
|
|
clearInterval(this.syncTimer) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.syncTimer = setInterval(async () => { |
|
|
|
|
try { |
|
|
|
|
const frontendRoutes = this.routeCollector.collectRoutes() |
|
|
|
|
const routeMappings = this.routeMapper.generateRouteMappings(frontendRoutes) |
|
|
|
|
await this.routeSyncService.syncRoutes(routeMappings) |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error('❌ 定时路由同步失败:', error) |
|
|
|
|
} |
|
|
|
|
}, this.config.syncInterval) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 手动触发同步
|
|
|
|
|
async manualSync() { |
|
|
|
|
if (!this.isInitialized) { |
|
|
|
|
console.error('❌ 路由同步管理器未初始化') |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const frontendRoutes = this.routeCollector.collectRoutes() |
|
|
|
|
const routeMappings = this.routeMapper.generateRouteMappings(frontendRoutes) |
|
|
|
|
const result = await this.routeSyncService.syncRoutes(routeMappings) |
|
|
|
|
|
|
|
|
|
return result.success |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error('❌ 手动同步失败:', error) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取同步状态
|
|
|
|
|
getSyncStatus() { |
|
|
|
|
return { |
|
|
|
|
isInitialized: this.isInitialized, |
|
|
|
|
hasSyncTimer: !!this.syncTimer, |
|
|
|
|
syncInterval: this.config.syncInterval, |
|
|
|
|
autoSync: this.config.autoSync |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新配置
|
|
|
|
|
updateConfig(newConfig) { |
|
|
|
|
this.config = { |
|
|
|
|
...this.config, |
|
|
|
|
...newConfig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 如果修改了同步间隔,重新设置定时器
|
|
|
|
|
if (newConfig.syncInterval !== undefined) { |
|
|
|
|
this.setupPeriodicSync() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 停止同步
|
|
|
|
|
stop() { |
|
|
|
|
if (this.syncTimer) { |
|
|
|
@ -14313,9 +14312,11 @@ __webpack_require__.r(__webpack_exports__);
@@ -14313,9 +14312,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
/* harmony export */ RouteSyncService: () => (/* binding */ RouteSyncService) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/lib/axios.js"); |
|
|
|
|
/* harmony import */ var _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RouteConfig.js */ "./src/renderer/modules/route-sync/RouteConfig.js"); |
|
|
|
|
// 路由同步服务 - 负责与后端API通信并同步路由信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 路由同步服务
|
|
|
|
|
class RouteSyncService { |
|
|
|
|
constructor(apiBaseUrl = 'http://localhost:8080') { |
|
|
|
@ -14426,12 +14427,12 @@ class RouteSyncService {
@@ -14426,12 +14427,12 @@ class RouteSyncService {
|
|
|
|
|
if (!frontendRouteGroups[frontendRoute]) { |
|
|
|
|
frontendRouteGroups[frontendRoute] = { |
|
|
|
|
path: frontendRoute, |
|
|
|
|
name: this._extractRouteName(frontendRoute), |
|
|
|
|
component: this._generateComponent(frontendRoute, module), |
|
|
|
|
name: _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.extractRouteName(frontendRoute), |
|
|
|
|
component: _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.generateComponent(frontendRoute, module), |
|
|
|
|
module: module, |
|
|
|
|
description: this._generateDescription(frontendRoute, module), |
|
|
|
|
sort: this._generateSort(frontendRoute, module), |
|
|
|
|
type: this._determineRouteType(frontendRoute, module), |
|
|
|
|
description: _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.generateDescription(_RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.extractRouteName(frontendRoute), module), |
|
|
|
|
sort: _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.generateSort(module), |
|
|
|
|
type: _RouteConfig_js__WEBPACK_IMPORTED_MODULE_1__.RouteUtils.determineRouteType(frontendRoute, module), |
|
|
|
|
backend_routes: [] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -14455,79 +14456,6 @@ class RouteSyncService {
@@ -14455,79 +14456,6 @@ class RouteSyncService {
|
|
|
|
|
return Object.values(frontendRouteGroups) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 提取路由名称
|
|
|
|
|
_extractRouteName(path) { |
|
|
|
|
if (path === '/' || path === '') return 'Home' |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) return 'Home' |
|
|
|
|
|
|
|
|
|
const lastSegment = segments[segments.length - 1] |
|
|
|
|
return lastSegment.charAt(0).toUpperCase() + lastSegment.slice(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成描述
|
|
|
|
|
_generateDescription(path, module) { |
|
|
|
|
const descriptions = { |
|
|
|
|
'home': '首页', |
|
|
|
|
'user-management': '用户管理', |
|
|
|
|
'role-management': '角色管理', |
|
|
|
|
'system-settings': '系统设置', |
|
|
|
|
'route-sync': '路由同步测试' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return descriptions[module] || `${this._extractRouteName(path)}页面` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 确定路由类型
|
|
|
|
|
_determineRouteType(path, module) { |
|
|
|
|
if (path === '/' || path === '') return 'home' |
|
|
|
|
|
|
|
|
|
const typeMap = { |
|
|
|
|
'user-management': 'list', |
|
|
|
|
'role-management': 'list', |
|
|
|
|
'system-settings': 'form', |
|
|
|
|
'route-sync': 'test' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return typeMap[module] || 'list' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成组件名称
|
|
|
|
|
_generateComponent(path, module) { |
|
|
|
|
if (path === '/' || path === '') return 'Home' |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) return 'Home' |
|
|
|
|
|
|
|
|
|
const lastSegment = segments[segments.length - 1] |
|
|
|
|
const componentName = lastSegment.charAt(0).toUpperCase() + lastSegment.slice(1) |
|
|
|
|
|
|
|
|
|
// 特殊处理某些路径
|
|
|
|
|
if (path === '/route-sync') { |
|
|
|
|
return 'RouteSync' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return componentName |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成排序值
|
|
|
|
|
_generateSort(path, module) { |
|
|
|
|
const sortMap = { |
|
|
|
|
'home': 1, |
|
|
|
|
'user-management': 10, |
|
|
|
|
'role-management': 20, |
|
|
|
|
'system-settings': 30, |
|
|
|
|
'route-sync': 100 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return sortMap[module] || 50 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 手动触发同步
|
|
|
|
|
async manualSync(routeMappings) { |
|
|
|
|
return await this.syncRoutes(routeMappings) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取同步状态
|
|
|
|
|
getSyncStatus() { |
|
|
|
@ -14539,248 +14467,6 @@ class RouteSyncService {
@@ -14539,248 +14467,6 @@ class RouteSyncService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }), |
|
|
|
|
|
|
|
|
|
/***/ "./src/renderer/modules/route-sync/RouteUtils.js": |
|
|
|
|
/*!*******************************************************!*\ |
|
|
|
|
!*** ./src/renderer/modules/route-sync/RouteUtils.js ***! |
|
|
|
|
\*******************************************************/ |
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
|
|
|
|
|
|
|
|
|
"use strict"; |
|
|
|
|
__webpack_require__.r(__webpack_exports__); |
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
|
|
|
/* harmony export */ RouteUtils: () => (/* binding */ RouteUtils) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
/* harmony import */ var _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generated-route-mapping.js */ "./src/renderer/modules/route-sync/generated-route-mapping.js"); |
|
|
|
|
// 路由工具类
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RouteUtils { |
|
|
|
|
// 从路径提取模块名
|
|
|
|
|
static extractModuleFromPath(path) { |
|
|
|
|
if (path === '/' || path === '') { |
|
|
|
|
return 'core' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const segments = path.split('/').filter(Boolean) |
|
|
|
|
if (segments.length === 0) { |
|
|
|
|
return 'core' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取第一个段作为模块名
|
|
|
|
|
const firstPart = segments[0] |
|
|
|
|
|
|
|
|
|
// 映射模块名
|
|
|
|
|
const moduleMap = { |
|
|
|
|
'user-management': 'user-management', |
|
|
|
|
'role-management': 'role-management', |
|
|
|
|
'settings': 'system-settings', |
|
|
|
|
'user-profile': 'user-management', |
|
|
|
|
'route-sync': 'route-sync' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return moduleMap[firstPart] || firstPart |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 加载生成的路由映射文件
|
|
|
|
|
static loadGeneratedMapping() { |
|
|
|
|
try { |
|
|
|
|
// 直接返回导入的数据
|
|
|
|
|
return Promise.resolve({ |
|
|
|
|
mainRoutes: _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__.mainRoutes, |
|
|
|
|
moduleApiMappings: _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__.moduleApiMappings, |
|
|
|
|
subRouteMappings: _generated_route_mapping_js__WEBPACK_IMPORTED_MODULE_0__.subRouteMappings |
|
|
|
|
}) |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error('❌ 加载生成的路由映射文件失败:', error) |
|
|
|
|
return Promise.resolve(null) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 验证映射
|
|
|
|
|
static validateMapping(mapping, index) { |
|
|
|
|
const errors = [] |
|
|
|
|
|
|
|
|
|
if (!mapping.frontend_route) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少前端路由`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!mapping.backend_route) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少后端路由`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!mapping.http_method) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少HTTP方法`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!mapping.module) { |
|
|
|
|
errors.push(`映射 ${index}: 缺少模块信息`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
isValid: errors.length === 0, |
|
|
|
|
errors: errors |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成路由描述
|
|
|
|
|
static generateDescription(name, module) { |
|
|
|
|
const descriptions = { |
|
|
|
|
'home': '首页', |
|
|
|
|
'user-management': '用户管理', |
|
|
|
|
'role-management': '角色管理', |
|
|
|
|
'system-settings': '系统设置', |
|
|
|
|
'route-sync': '路由同步测试' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return descriptions[module] || `${name}页面` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 确定路由类型
|
|
|
|
|
static determineRouteType(path, module) { |
|
|
|
|
if (path === '/' || path === '') return 'home' |
|
|
|
|
|
|
|
|
|
const typeMap = { |
|
|
|
|
'user-management': 'list', |
|
|
|
|
'role-management': 'list', |
|
|
|
|
'system-settings': 'form', |
|
|
|
|
'route-sync': 'test' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return typeMap[module] || 'list' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }), |
|
|
|
|
|
|
|
|
|
/***/ "./src/renderer/modules/route-sync/generated-route-mapping.js": |
|
|
|
|
/*!********************************************************************!*\ |
|
|
|
|
!*** ./src/renderer/modules/route-sync/generated-route-mapping.js ***! |
|
|
|
|
\********************************************************************/ |
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
|
|
|
|
|
|
|
|
|
"use strict"; |
|
|
|
|
__webpack_require__.r(__webpack_exports__); |
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
|
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), |
|
|
|
|
/* harmony export */ mainRoutes: () => (/* binding */ mainRoutes), |
|
|
|
|
/* harmony export */ moduleApiMappings: () => (/* binding */ moduleApiMappings), |
|
|
|
|
/* harmony export */ subRouteMappings: () => (/* binding */ subRouteMappings) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
// 自动生成的路由映射文件
|
|
|
|
|
// 此文件由 route-mapping-plugin 在构建时生成
|
|
|
|
|
// 请勿手动修改
|
|
|
|
|
|
|
|
|
|
const mainRoutes = [ |
|
|
|
|
{ |
|
|
|
|
"path": "/", |
|
|
|
|
"name": "Home", |
|
|
|
|
"module": "home", |
|
|
|
|
"description": "首页", |
|
|
|
|
"type": "home" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"path": "/user-management", |
|
|
|
|
"name": "UserManagement", |
|
|
|
|
"module": "user-management", |
|
|
|
|
"description": "用户管理", |
|
|
|
|
"type": "list" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"path": "/settings", |
|
|
|
|
"name": "Settings", |
|
|
|
|
"module": "system-settings", |
|
|
|
|
"description": "系统设置", |
|
|
|
|
"type": "form" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"path": "/user-profile", |
|
|
|
|
"name": "UserProfile", |
|
|
|
|
"module": "user-management", |
|
|
|
|
"description": "用户管理", |
|
|
|
|
"type": "list" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"path": "/role-management", |
|
|
|
|
"name": "RoleManagement", |
|
|
|
|
"module": "role-management", |
|
|
|
|
"description": "角色管理", |
|
|
|
|
"type": "list" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"path": "/route-sync", |
|
|
|
|
"name": "RouteSyncTest", |
|
|
|
|
"module": "route-sync", |
|
|
|
|
"description": "路由同步测试", |
|
|
|
|
"type": "test" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
// 模块到API映射配置
|
|
|
|
|
const moduleApiMappings = { |
|
|
|
|
'user-management': { |
|
|
|
|
basePath: '/auth/admin/users', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
search: { path: '/search', method: 'POST' }, |
|
|
|
|
filter: { path: '/filter', method: 'POST' }, |
|
|
|
|
create: { path: '', method: 'POST' }, |
|
|
|
|
update: { path: '/:id', method: 'PUT' }, |
|
|
|
|
detail: { path: '/:id', method: 'GET' }, |
|
|
|
|
delete: { path: '/:id', method: 'DELETE' }, |
|
|
|
|
getRoles: { path: '/roles', method: 'GET' } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'role-management': { |
|
|
|
|
basePath: '/auth/roles', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
search: { path: '/search', method: 'POST' }, |
|
|
|
|
filter: { path: '/filter', method: 'POST' }, |
|
|
|
|
create: { path: '', method: 'POST' }, |
|
|
|
|
update: { path: '/:id', method: 'PUT' }, |
|
|
|
|
detail: { path: '/:id', method: 'GET' }, |
|
|
|
|
delete: { path: '/:id', method: 'DELETE' } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'system-settings': { |
|
|
|
|
basePath: '/auth/settings', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
update: { path: '', method: 'PUT' } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'route-sync': { |
|
|
|
|
basePath: '/auth/route-sync', |
|
|
|
|
operations: { |
|
|
|
|
list: { path: '', method: 'GET' }, |
|
|
|
|
test: { path: '/test', method: 'POST' }, |
|
|
|
|
status: { path: '/status', method: 'GET' } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 子路由到主路由的映射
|
|
|
|
|
const subRouteMappings = { |
|
|
|
|
'/user-management/create': { mainRoute: '/user-management', operation: 'create' }, |
|
|
|
|
'/user-management/edit': { mainRoute: '/user-management', operation: 'update' }, |
|
|
|
|
'/user-management/delete': { mainRoute: '/user-management', operation: 'delete' }, |
|
|
|
|
'/user-management/detail': { mainRoute: '/user-management', operation: 'detail' }, |
|
|
|
|
'/role-management/create': { mainRoute: '/role-management', operation: 'create' }, |
|
|
|
|
'/role-management/edit': { mainRoute: '/role-management', operation: 'update' }, |
|
|
|
|
'/role-management/delete': { mainRoute: '/role-management', operation: 'delete' }, |
|
|
|
|
'/role-management/detail': { mainRoute: '/role-management', operation: 'detail' } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ |
|
|
|
|
mainRoutes, |
|
|
|
|
moduleApiMappings, |
|
|
|
|
subRouteMappings |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }), |
|
|
|
|
|
|
|
|
|
/***/ "./src/renderer/modules/route-sync/index.js": |
|
|
|
@ -14793,15 +14479,18 @@ const subRouteMappings = {
@@ -14793,15 +14479,18 @@ const subRouteMappings = {
|
|
|
|
|
__webpack_require__.r(__webpack_exports__); |
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
|
|
|
/* harmony export */ RouteCollector: () => (/* reexport safe */ _RouteCollector__WEBPACK_IMPORTED_MODULE_1__.RouteCollector), |
|
|
|
|
/* harmony export */ RouteConfig: () => (/* reexport safe */ _RouteConfig__WEBPACK_IMPORTED_MODULE_4__.RouteConfig), |
|
|
|
|
/* harmony export */ RouteMapper: () => (/* reexport safe */ _RouteMapper__WEBPACK_IMPORTED_MODULE_2__.RouteMapper), |
|
|
|
|
/* harmony export */ RouteSyncManager: () => (/* reexport safe */ _RouteSyncManager__WEBPACK_IMPORTED_MODULE_3__.RouteSyncManager), |
|
|
|
|
/* harmony export */ RouteSyncService: () => (/* reexport safe */ _RouteSyncService__WEBPACK_IMPORTED_MODULE_0__.RouteSyncService), |
|
|
|
|
/* harmony export */ RouteUtils: () => (/* reexport safe */ _RouteConfig__WEBPACK_IMPORTED_MODULE_4__.RouteUtils), |
|
|
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) |
|
|
|
|
/* harmony export */ }); |
|
|
|
|
/* harmony import */ var _RouteSyncService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./RouteSyncService */ "./src/renderer/modules/route-sync/RouteSyncService.js"); |
|
|
|
|
/* harmony import */ var _RouteCollector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RouteCollector */ "./src/renderer/modules/route-sync/RouteCollector.js"); |
|
|
|
|
/* harmony import */ var _RouteMapper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RouteMapper */ "./src/renderer/modules/route-sync/RouteMapper.js"); |
|
|
|
|
/* harmony import */ var _RouteSyncManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./RouteSyncManager */ "./src/renderer/modules/route-sync/RouteSyncManager.js"); |
|
|
|
|
/* harmony import */ var _RouteConfig__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RouteConfig */ "./src/renderer/modules/route-sync/RouteConfig.js"); |
|
|
|
|
// 路由同步模块
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -14810,6 +14499,7 @@ __webpack_require__.r(__webpack_exports__);
@@ -14810,6 +14499,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 默认导出路由同步管理器
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_RouteSyncManager__WEBPACK_IMPORTED_MODULE_3__.RouteSyncManager); |
|
|
|
|
|
|
|
|
@ -16131,7 +15821,7 @@ __webpack_require__.r(__webpack_exports__);
@@ -16131,7 +15821,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
/******/
|
|
|
|
|
/******/ /* webpack/runtime/getFullHash */ |
|
|
|
|
/******/ (() => { |
|
|
|
|
/******/ __webpack_require__.h = () => ("78f195cd268ee251") |
|
|
|
|
/******/ __webpack_require__.h = () => ("a79c70d541afd8fd") |
|
|
|
|
/******/ })(); |
|
|
|
|
/******/
|
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
|
|
|