Compare commits
No commits in common. '3233c78219cc8f8c9b1393b4429bcaaa2890e79f' and '8ed92aa21db9559c295bc3ccc6504346040e87f1' have entirely different histories.
3233c78219
...
8ed92aa21d
17 changed files with 1381 additions and 7288 deletions
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,548 @@ |
|||||||
|
<template> |
||||||
|
<div class="role-api-test"> |
||||||
|
<div class="page-header"> |
||||||
|
<h2>角色管理API测试</h2> |
||||||
|
<div class="header-actions"> |
||||||
|
<button |
||||||
|
class="btn btn-secondary" |
||||||
|
@click="toggleTestMode" |
||||||
|
:title="testMode ? '当前为测试模式(无需认证)' : '当前为正式模式(需要认证)'" |
||||||
|
> |
||||||
|
<i class="fas fa-flask"></i> |
||||||
|
{{ testMode ? '测试模式' : '正式模式' }} |
||||||
|
</button> |
||||||
|
<button class="btn btn-primary" @click="runAllTests"> |
||||||
|
<i class="fas fa-play"></i> 运行所有测试 |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="test-content"> |
||||||
|
<!-- API配置信息 --> |
||||||
|
<div class="test-section"> |
||||||
|
<h3>API配置信息</h3> |
||||||
|
<div class="config-info"> |
||||||
|
<div class="config-item"> |
||||||
|
<label>API基础地址:</label> |
||||||
|
<span>{{ apiBaseUrl }}</span> |
||||||
|
</div> |
||||||
|
<div class="config-item"> |
||||||
|
<label>当前模式:</label> |
||||||
|
<span :class="testMode ? 'test-mode' : 'prod-mode'"> |
||||||
|
{{ testMode ? '测试模式' : '正式模式' }} |
||||||
|
</span> |
||||||
|
</div> |
||||||
|
<div class="config-item"> |
||||||
|
<label>API路径:</label> |
||||||
|
<span>{{ currentApiPath }}</span> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- 测试结果 --> |
||||||
|
<div class="test-section"> |
||||||
|
<h3>测试结果</h3> |
||||||
|
<div class="test-results"> |
||||||
|
<div |
||||||
|
v-for="(result, index) in testResults" |
||||||
|
:key="index" |
||||||
|
class="test-result-item" |
||||||
|
:class="result.status" |
||||||
|
> |
||||||
|
<div class="test-header"> |
||||||
|
<span class="test-name">{{ result.name }}</span> |
||||||
|
<span class="test-status">{{ getStatusText(result.status) }}</span> |
||||||
|
</div> |
||||||
|
<div v-if="result.message" class="test-message"> |
||||||
|
{{ result.message }} |
||||||
|
</div> |
||||||
|
<div v-if="result.data" class="test-data"> |
||||||
|
<pre>{{ JSON.stringify(result.data, null, 2) }}</pre> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- 手动测试 --> |
||||||
|
<div class="test-section"> |
||||||
|
<h3>手动测试</h3> |
||||||
|
<div class="manual-tests"> |
||||||
|
<div class="test-group"> |
||||||
|
<h4>获取角色列表</h4> |
||||||
|
<button @click="testGetRoles" :disabled="testing"> |
||||||
|
{{ testing ? '测试中...' : '测试获取角色列表' }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="test-group"> |
||||||
|
<h4>创建角色</h4> |
||||||
|
<div class="form-group"> |
||||||
|
<label>角色名称:</label> |
||||||
|
<input v-model="testRole.name" type="text" placeholder="测试角色" /> |
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<label>角色代码:</label> |
||||||
|
<input v-model="testRole.code" type="text" placeholder="TEST_ROLE" /> |
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<label>描述:</label> |
||||||
|
<input v-model="testRole.description" type="text" placeholder="测试角色描述" /> |
||||||
|
</div> |
||||||
|
<button @click="testCreateRole" :disabled="testing"> |
||||||
|
{{ testing ? '测试中...' : '测试创建角色' }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="test-group"> |
||||||
|
<h4>更新角色</h4> |
||||||
|
<div class="form-group"> |
||||||
|
<label>角色ID:</label> |
||||||
|
<input v-model="updateRoleId" type="number" placeholder="输入角色ID" /> |
||||||
|
</div> |
||||||
|
<button @click="testUpdateRole" :disabled="testing || !updateRoleId"> |
||||||
|
{{ testing ? '测试中...' : '测试更新角色' }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="test-group"> |
||||||
|
<h4>删除角色</h4> |
||||||
|
<div class="form-group"> |
||||||
|
<label>角色ID:</label> |
||||||
|
<input v-model="deleteRoleId" type="number" placeholder="输入角色ID" /> |
||||||
|
</div> |
||||||
|
<button @click="testDeleteRole" :disabled="testing || !deleteRoleId"> |
||||||
|
{{ testing ? '测试中...' : '测试删除角色' }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import { ref, reactive, computed, onMounted } from 'vue' |
||||||
|
import { roleService } from '../services/roleService.js' |
||||||
|
import { getFinalConfig } from '../../../../config/app.config.js' |
||||||
|
|
||||||
|
export default { |
||||||
|
name: 'RoleApiTest', |
||||||
|
setup() { |
||||||
|
const testing = ref(false) |
||||||
|
const testMode = ref(false) |
||||||
|
const testResults = ref([]) |
||||||
|
|
||||||
|
const updateRoleId = ref('') |
||||||
|
const deleteRoleId = ref('') |
||||||
|
|
||||||
|
const testRole = reactive({ |
||||||
|
name: '测试角色', |
||||||
|
code: 'TEST_ROLE', |
||||||
|
description: '这是一个测试角色' |
||||||
|
}) |
||||||
|
|
||||||
|
const apiBaseUrl = computed(() => getFinalConfig().apiBaseUrl) |
||||||
|
const currentApiPath = computed(() => testMode.value ? '/auth/roles/test' : '/auth/roles') |
||||||
|
|
||||||
|
// 切换测试模式 |
||||||
|
const toggleTestMode = () => { |
||||||
|
testMode.value = roleService.toggleTestMode() |
||||||
|
addTestResult('模式切换', 'success', `已切换到${testMode.value ? '测试' : '正式'}模式`) |
||||||
|
} |
||||||
|
|
||||||
|
// 添加测试结果 |
||||||
|
const addTestResult = (name, status, message, data = null) => { |
||||||
|
testResults.value.unshift({ |
||||||
|
name, |
||||||
|
status, |
||||||
|
message, |
||||||
|
data, |
||||||
|
timestamp: new Date().toLocaleString() |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
// 获取状态文本 |
||||||
|
const getStatusText = (status) => { |
||||||
|
const statusMap = { |
||||||
|
'success': '成功', |
||||||
|
'error': '失败', |
||||||
|
'warning': '警告' |
||||||
|
} |
||||||
|
return statusMap[status] || status |
||||||
|
} |
||||||
|
|
||||||
|
// 测试获取角色列表 |
||||||
|
const testGetRoles = async () => { |
||||||
|
testing.value = true |
||||||
|
try { |
||||||
|
const response = await roleService.getRoles(1, 10) |
||||||
|
if (response.code === 200) { |
||||||
|
addTestResult('获取角色列表', 'success', '获取角色列表成功', response.data) |
||||||
|
} else { |
||||||
|
addTestResult('获取角色列表', 'error', `获取失败: ${response.message}`, response) |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
addTestResult('获取角色列表', 'error', `请求失败: ${error.message || error.error}`, error) |
||||||
|
} finally { |
||||||
|
testing.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 测试创建角色 |
||||||
|
const testCreateRole = async () => { |
||||||
|
testing.value = true |
||||||
|
try { |
||||||
|
const response = await roleService.createRole(testRole) |
||||||
|
if (response.code === 200) { |
||||||
|
addTestResult('创建角色', 'success', '创建角色成功', response.data) |
||||||
|
} else { |
||||||
|
addTestResult('创建角色', 'error', `创建失败: ${response.message}`, response) |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
addTestResult('创建角色', 'error', `请求失败: ${error.message || error.error}`, error) |
||||||
|
} finally { |
||||||
|
testing.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 测试更新角色 |
||||||
|
const testUpdateRole = async () => { |
||||||
|
if (!updateRoleId.value) { |
||||||
|
addTestResult('更新角色', 'warning', '请输入角色ID') |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
testing.value = true |
||||||
|
try { |
||||||
|
const updateData = { |
||||||
|
name: `${testRole.name}_更新`, |
||||||
|
code: `${testRole.code}_UPDATED`, |
||||||
|
description: `${testRole.description}_更新` |
||||||
|
} |
||||||
|
const response = await roleService.updateRole(updateRoleId.value, updateData) |
||||||
|
if (response.code === 200) { |
||||||
|
addTestResult('更新角色', 'success', '更新角色成功', response.data) |
||||||
|
} else { |
||||||
|
addTestResult('更新角色', 'error', `更新失败: ${response.message}`, response) |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
addTestResult('更新角色', 'error', `请求失败: ${error.message || error.error}`, error) |
||||||
|
} finally { |
||||||
|
testing.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 测试删除角色 |
||||||
|
const testDeleteRole = async () => { |
||||||
|
if (!deleteRoleId.value) { |
||||||
|
addTestResult('删除角色', 'warning', '请输入角色ID') |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
testing.value = true |
||||||
|
try { |
||||||
|
const response = await roleService.deleteRole(deleteRoleId.value) |
||||||
|
if (response.code === 200) { |
||||||
|
addTestResult('删除角色', 'success', '删除角色成功', response.data) |
||||||
|
} else { |
||||||
|
addTestResult('删除角色', 'error', `删除失败: ${response.message}`, response) |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
addTestResult('删除角色', 'error', `请求失败: ${error.message || error.error}`, error) |
||||||
|
} finally { |
||||||
|
testing.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 运行所有测试 |
||||||
|
const runAllTests = async () => { |
||||||
|
addTestResult('测试开始', 'success', '开始运行所有API测试') |
||||||
|
|
||||||
|
await testGetRoles() |
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000)) // 等待1秒 |
||||||
|
await testCreateRole() |
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000)) // 等待1秒 |
||||||
|
|
||||||
|
addTestResult('测试完成', 'success', '所有API测试已完成') |
||||||
|
} |
||||||
|
|
||||||
|
onMounted(() => { |
||||||
|
testMode.value = roleService.getTestModeStatus() |
||||||
|
addTestResult('页面加载', 'success', '角色管理API测试页面已加载') |
||||||
|
}) |
||||||
|
|
||||||
|
return { |
||||||
|
testing, |
||||||
|
testMode, |
||||||
|
testResults, |
||||||
|
updateRoleId, |
||||||
|
deleteRoleId, |
||||||
|
testRole, |
||||||
|
apiBaseUrl, |
||||||
|
currentApiPath, |
||||||
|
toggleTestMode, |
||||||
|
testGetRoles, |
||||||
|
testCreateRole, |
||||||
|
testUpdateRole, |
||||||
|
testDeleteRole, |
||||||
|
runAllTests, |
||||||
|
getStatusText |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
.role-api-test { |
||||||
|
padding: 20px; |
||||||
|
height: 100%; |
||||||
|
overflow-y: auto; |
||||||
|
} |
||||||
|
|
||||||
|
.page-header { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.page-header h2 { |
||||||
|
margin: 0; |
||||||
|
color: var(--text-primary); |
||||||
|
} |
||||||
|
|
||||||
|
.header-actions { |
||||||
|
display: flex; |
||||||
|
gap: 12px; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
.test-content { |
||||||
|
max-width: 1200px; |
||||||
|
} |
||||||
|
|
||||||
|
.test-section { |
||||||
|
background: var(--card-bg); |
||||||
|
border-radius: 8px; |
||||||
|
padding: 24px; |
||||||
|
margin-bottom: 24px; |
||||||
|
box-shadow: 0 2px 8px var(--shadow-color); |
||||||
|
} |
||||||
|
|
||||||
|
.test-section h3 { |
||||||
|
margin: 0 0 20px 0; |
||||||
|
color: var(--text-primary); |
||||||
|
font-size: 18px; |
||||||
|
border-bottom: 2px solid var(--border-color); |
||||||
|
padding-bottom: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
.config-info { |
||||||
|
display: grid; |
||||||
|
gap: 12px; |
||||||
|
} |
||||||
|
|
||||||
|
.config-item { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
padding: 12px; |
||||||
|
background: var(--bg-secondary); |
||||||
|
border-radius: 4px; |
||||||
|
} |
||||||
|
|
||||||
|
.config-item label { |
||||||
|
font-weight: 500; |
||||||
|
color: var(--text-primary); |
||||||
|
} |
||||||
|
|
||||||
|
.config-item span { |
||||||
|
color: var(--text-secondary); |
||||||
|
font-family: monospace; |
||||||
|
} |
||||||
|
|
||||||
|
.test-mode { |
||||||
|
color: #ff9800 !important; |
||||||
|
font-weight: bold; |
||||||
|
} |
||||||
|
|
||||||
|
.prod-mode { |
||||||
|
color: #4caf50 !important; |
||||||
|
font-weight: bold; |
||||||
|
} |
||||||
|
|
||||||
|
.test-results { |
||||||
|
max-height: 400px; |
||||||
|
overflow-y: auto; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item { |
||||||
|
margin-bottom: 16px; |
||||||
|
padding: 16px; |
||||||
|
border-radius: 6px; |
||||||
|
border-left: 4px solid; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item.success { |
||||||
|
background: rgba(76, 175, 80, 0.1); |
||||||
|
border-left-color: #4caf50; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item.error { |
||||||
|
background: rgba(244, 67, 54, 0.1); |
||||||
|
border-left-color: #f44336; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item.warning { |
||||||
|
background: rgba(255, 152, 0, 0.1); |
||||||
|
border-left-color: #ff9800; |
||||||
|
} |
||||||
|
|
||||||
|
.test-header { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
margin-bottom: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
.test-name { |
||||||
|
font-weight: 500; |
||||||
|
color: var(--text-primary); |
||||||
|
} |
||||||
|
|
||||||
|
.test-status { |
||||||
|
font-size: 12px; |
||||||
|
padding: 4px 8px; |
||||||
|
border-radius: 4px; |
||||||
|
font-weight: 500; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item.success .test-status { |
||||||
|
background: #4caf50; |
||||||
|
color: white; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item.error .test-status { |
||||||
|
background: #f44336; |
||||||
|
color: white; |
||||||
|
} |
||||||
|
|
||||||
|
.test-result-item.warning .test-status { |
||||||
|
background: #ff9800; |
||||||
|
color: white; |
||||||
|
} |
||||||
|
|
||||||
|
.test-message { |
||||||
|
color: var(--text-secondary); |
||||||
|
margin-bottom: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
.test-data { |
||||||
|
background: var(--bg-secondary); |
||||||
|
padding: 12px; |
||||||
|
border-radius: 4px; |
||||||
|
overflow-x: auto; |
||||||
|
} |
||||||
|
|
||||||
|
.test-data pre { |
||||||
|
margin: 0; |
||||||
|
font-size: 12px; |
||||||
|
color: var(--text-secondary); |
||||||
|
} |
||||||
|
|
||||||
|
.manual-tests { |
||||||
|
display: grid; |
||||||
|
gap: 24px; |
||||||
|
} |
||||||
|
|
||||||
|
.test-group { |
||||||
|
padding: 16px; |
||||||
|
background: var(--bg-secondary); |
||||||
|
border-radius: 6px; |
||||||
|
} |
||||||
|
|
||||||
|
.test-group h4 { |
||||||
|
margin: 0 0 16px 0; |
||||||
|
color: var(--text-primary); |
||||||
|
} |
||||||
|
|
||||||
|
.form-group { |
||||||
|
margin-bottom: 12px; |
||||||
|
} |
||||||
|
|
||||||
|
.form-group label { |
||||||
|
display: block; |
||||||
|
margin-bottom: 4px; |
||||||
|
font-weight: 500; |
||||||
|
color: var(--text-primary); |
||||||
|
} |
||||||
|
|
||||||
|
.form-group input { |
||||||
|
width: 100%; |
||||||
|
padding: 8px 12px; |
||||||
|
border: 1px solid var(--border-color); |
||||||
|
border-radius: 4px; |
||||||
|
background: var(--input-bg); |
||||||
|
color: var(--input-text); |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
.btn { |
||||||
|
padding: 8px 16px; |
||||||
|
border: none; |
||||||
|
border-radius: 4px; |
||||||
|
cursor: pointer; |
||||||
|
font-size: 14px; |
||||||
|
display: inline-flex; |
||||||
|
align-items: center; |
||||||
|
gap: 6px; |
||||||
|
transition: all 0.2s; |
||||||
|
} |
||||||
|
|
||||||
|
.btn-primary { |
||||||
|
background: var(--accent-color); |
||||||
|
color: white; |
||||||
|
} |
||||||
|
|
||||||
|
.btn-primary:hover { |
||||||
|
background: var(--accent-hover); |
||||||
|
} |
||||||
|
|
||||||
|
.btn-secondary { |
||||||
|
background: #757575; |
||||||
|
color: white; |
||||||
|
} |
||||||
|
|
||||||
|
.btn-secondary:hover { |
||||||
|
background: #616161; |
||||||
|
} |
||||||
|
|
||||||
|
.btn:hover { |
||||||
|
opacity: 0.9; |
||||||
|
} |
||||||
|
|
||||||
|
.btn:disabled { |
||||||
|
opacity: 0.5; |
||||||
|
cursor: not-allowed; |
||||||
|
} |
||||||
|
|
||||||
|
button { |
||||||
|
background: var(--accent-color); |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 8px 16px; |
||||||
|
border-radius: 4px; |
||||||
|
cursor: pointer; |
||||||
|
font-size: 14px; |
||||||
|
transition: all 0.2s; |
||||||
|
} |
||||||
|
|
||||||
|
button:hover:not(:disabled) { |
||||||
|
background: var(--accent-hover); |
||||||
|
} |
||||||
|
|
||||||
|
button:disabled { |
||||||
|
opacity: 0.5; |
||||||
|
cursor: not-allowed; |
||||||
|
} |
||||||
|
</style> |
@ -1,352 +0,0 @@ |
|||||||
// 直接路由映射文件
|
|
||||||
// 此文件由 route-mapping-plugin 在构建时生成
|
|
||||||
// 包含路由配置分析结果和API收集结果
|
|
||||||
// 请勿手动修改
|
|
||||||
|
|
||||||
export const directRouteMappings = { |
|
||||||
// 路由配置分析结果
|
|
||||||
routes: [ |
|
||||||
{ |
|
||||||
"path": "/", |
|
||||||
"component": "MainLayout", |
|
||||||
"module": "home", |
|
||||||
"description": "首页" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"path": "/user-management", |
|
||||||
"name": "UserManagement", |
|
||||||
"component": "UserManagement", |
|
||||||
"module": "user-management", |
|
||||||
"description": "用户管理" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"path": "/settings", |
|
||||||
"name": "Settings", |
|
||||||
"component": "Settings", |
|
||||||
"module": "settings", |
|
||||||
"description": "用户设置" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"path": "/user-profile", |
|
||||||
"name": "UserProfile", |
|
||||||
"component": "UserProfile", |
|
||||||
"module": "user-management", |
|
||||||
"description": "用户管理" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"path": "/role-management", |
|
||||||
"name": "RoleManagement", |
|
||||||
"component": "RoleManagement", |
|
||||||
"module": "role-management", |
|
||||||
"description": "角色管理" |
|
||||||
} |
|
||||||
], |
|
||||||
|
|
||||||
// API收集结果(包含页面关联和路径完善)
|
|
||||||
apiMappings: [ |
|
||||||
{ |
|
||||||
"module": "user-management", |
|
||||||
"serviceName": "userService", |
|
||||||
"servicePath": "D:\\aigc\\manta\\gofaster\\app\\src\\renderer\\modules\\user-management\\services\\userService.js", |
|
||||||
"apiMappings": [ |
|
||||||
{ |
|
||||||
"methodName": "getUsers", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/admin/users", |
|
||||||
"line": 51, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserManagement", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "createUser", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/admin/users", |
|
||||||
"line": 73, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserManagement", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "updateUser", |
|
||||||
"method": "PUT", |
|
||||||
"path": "/auth/admin/users/{Identifier}", |
|
||||||
"line": 83, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserManagement", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "deleteUser", |
|
||||||
"method": "DELETE", |
|
||||||
"path": "/auth/admin/users/{Identifier}", |
|
||||||
"line": 93, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserManagement", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "changePassword", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/change-password", |
|
||||||
"line": 113, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "PasswordChangeModal", |
|
||||||
"path": "/" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getPasswordPolicy", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/password-policy", |
|
||||||
"line": 123, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "PasswordChangeModal", |
|
||||||
"path": "/" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "validatePassword", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/validate-password", |
|
||||||
"line": 133, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "PasswordChangeModal", |
|
||||||
"path": "/" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getCaptcha", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/captcha", |
|
||||||
"line": 163, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "LoginModal", |
|
||||||
"path": "/" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "login", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/login", |
|
||||||
"line": 182, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "LoginModal", |
|
||||||
"path": "/" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getCurrentUser", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/userinfo", |
|
||||||
"line": 245, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserProfile", |
|
||||||
"path": "/user-profile" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "changePassword", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/change-password", |
|
||||||
"line": 259, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "PasswordChangeModal", |
|
||||||
"path": "/" |
|
||||||
} |
|
||||||
] |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"module": "role-management", |
|
||||||
"serviceName": "roleService", |
|
||||||
"servicePath": "D:\\aigc\\manta\\gofaster\\app\\src\\renderer\\modules\\role-management\\services\\roleService.js", |
|
||||||
"apiMappings": [ |
|
||||||
{ |
|
||||||
"methodName": "getRoles", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/roles", |
|
||||||
"line": 48, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RoleManagement", |
|
||||||
"path": "/role-management" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"component": "UserRoleAssignment", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getRole", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/roles/{Identifier}", |
|
||||||
"line": 60, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "PermissionManager", |
|
||||||
"path": null |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "createRole", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/roles", |
|
||||||
"line": 70, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RoleManagement", |
|
||||||
"path": "/role-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "updateRole", |
|
||||||
"method": "PUT", |
|
||||||
"path": "/auth/roles/{Identifier}", |
|
||||||
"line": 80, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RoleManagement", |
|
||||||
"path": "/role-management" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"component": "PermissionManager", |
|
||||||
"path": null |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "deleteRole", |
|
||||||
"method": "DELETE", |
|
||||||
"path": "/auth/roles/{Identifier}", |
|
||||||
"line": 90, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RoleManagement", |
|
||||||
"path": "/role-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getPermissions", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/permissions", |
|
||||||
"line": 100, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "PermissionManager", |
|
||||||
"path": null |
|
||||||
}, |
|
||||||
{ |
|
||||||
"component": "RolePermissionAssignment", |
|
||||||
"path": "/role-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "assignRolesToUser", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/roles/users/{Identifier}/assign", |
|
||||||
"line": 110, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserRoleAssignment", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getUserRoles", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/roles/users/{Identifier}", |
|
||||||
"line": 122, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserRoleAssignment", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "removeRolesFromUser", |
|
||||||
"method": "DELETE", |
|
||||||
"path": "/auth/roles/users/{Identifier}/remove", |
|
||||||
"line": 132, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "UserRoleAssignment", |
|
||||||
"path": "/user-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "getRolePermissions", |
|
||||||
"method": "GET", |
|
||||||
"path": "/auth/permissions/roles/{Identifier}", |
|
||||||
"line": 144, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RolePermissionAssignment", |
|
||||||
"path": "/role-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "assignPermissionsToRole", |
|
||||||
"method": "POST", |
|
||||||
"path": "/auth/permissions/roles/{Identifier}/assign", |
|
||||||
"line": 154, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RolePermissionAssignment", |
|
||||||
"path": "/role-management" |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"methodName": "removePermissionsFromRole", |
|
||||||
"method": "DELETE", |
|
||||||
"path": "/auth/permissions/roles/{Identifier}/remove", |
|
||||||
"line": 166, |
|
||||||
"callingComponents": [ |
|
||||||
{ |
|
||||||
"component": "RolePermissionAssignment", |
|
||||||
"path": "/role-management" |
|
||||||
} |
|
||||||
] |
|
||||||
} |
|
||||||
] |
|
||||||
} |
|
||||||
] |
|
||||||
} |
|
||||||
|
|
||||||
export default directRouteMappings |
|
@ -1,92 +0,0 @@ |
|||||||
# 测试路由同步修复效果 |
|
||||||
# 检查direct-route-mappings.js文件读取和路由映射生成问题 |
|
||||||
|
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
||||||
Write-Host " 路由同步修复测试脚本" -ForegroundColor Cyan |
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
||||||
Write-Host "" |
|
||||||
|
|
||||||
# 设置编码 |
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
|
||||||
$OutputEncoding = [System.Text.Encoding]::UTF8 |
|
||||||
|
|
||||||
# 检查文件是否存在 |
|
||||||
Write-Host "🔍 检查关键文件..." -ForegroundColor Yellow |
|
||||||
|
|
||||||
$mappingFile = "app\src\renderer\modules\route-sync\direct-route-mappings.js" |
|
||||||
if (Test-Path $mappingFile) { |
|
||||||
Write-Host "✅ direct-route-mappings.js 文件存在" -ForegroundColor Green |
|
||||||
|
|
||||||
# 检查文件内容 |
|
||||||
$content = Get-Content $mappingFile -Raw |
|
||||||
if ($content -match "export const directRouteMappings") { |
|
||||||
Write-Host "✅ 文件包含正确的导出" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ 文件缺少正确的导出" -ForegroundColor Red |
|
||||||
} |
|
||||||
|
|
||||||
if ($content -match "pageMappings") { |
|
||||||
Write-Host "✅ 文件包含pageMappings" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ 文件缺少pageMappings" -ForegroundColor Red |
|
||||||
} |
|
||||||
} else { |
|
||||||
Write-Host "❌ direct-route-mappings.js 文件不存在" -ForegroundColor Red |
|
||||||
} |
|
||||||
|
|
||||||
# 检查RouteConfig文件 |
|
||||||
$configFile = "app\src\renderer\modules\route-sync\RouteConfig.js" |
|
||||||
if (Test-Path $configFile) { |
|
||||||
Write-Host "✅ RouteConfig.js 文件存在" -ForegroundColor Green |
|
||||||
|
|
||||||
$configContent = Get-Content $configFile -Raw |
|
||||||
if ($configContent -match "defaultApiMappings") { |
|
||||||
Write-Host "✅ RouteConfig包含defaultApiMappings" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ RouteConfig缺少defaultApiMappings" -ForegroundColor Red |
|
||||||
} |
|
||||||
} else { |
|
||||||
Write-Host "❌ RouteConfig.js 文件不存在" -ForegroundColor Red |
|
||||||
} |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "🔧 测试路由映射生成..." -ForegroundColor Yellow |
|
||||||
|
|
||||||
# 进入app目录 |
|
||||||
Set-Location "app" |
|
||||||
|
|
||||||
# 测试生成脚本 |
|
||||||
try { |
|
||||||
Write-Host "运行路由映射生成脚本..." -ForegroundColor Cyan |
|
||||||
node scripts/generate-route-mappings.js |
|
||||||
if ($LASTEXITCODE -eq 0) { |
|
||||||
Write-Host "✅ 路由映射生成脚本执行成功" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ 路由映射生成脚本执行失败" -ForegroundColor Red |
|
||||||
} |
|
||||||
} catch { |
|
||||||
Write-Host "❌ 路由映射生成脚本执行异常: $($_.Exception.Message)" -ForegroundColor Red |
|
||||||
} |
|
||||||
|
|
||||||
# 返回根目录 |
|
||||||
Set-Location ".." |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "📊 修复总结:" -ForegroundColor Yellow |
|
||||||
Write-Host "1. ✅ 添加了defaultApiMappings配置到RouteConfig" -ForegroundColor Green |
|
||||||
Write-Host "2. ✅ 修复了RouteMapper中的API映射生成逻辑" -ForegroundColor Green |
|
||||||
Write-Host "3. ✅ 添加了_createApiMappingFromDirectCall方法" -ForegroundColor Green |
|
||||||
Write-Host "4. ✅ 添加了详细的调试日志" -ForegroundColor Green |
|
||||||
Write-Host "5. ✅ 优化了路由收集和映射生成流程" -ForegroundColor Green |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "🎯 预期效果:" -ForegroundColor Yellow |
|
||||||
Write-Host "- 能够正确读取direct-route-mappings.js文件" -ForegroundColor White |
|
||||||
Write-Host "- 能够正确生成路由映射" -ForegroundColor White |
|
||||||
Write-Host "- 不再出现'没有生成路由映射'错误" -ForegroundColor White |
|
||||||
Write-Host "- 路由同步逻辑能够正常执行" -ForegroundColor White |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
||||||
Write-Host "修复完成!现在可以重新启动应用测试" -ForegroundColor Green |
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
@ -1,88 +0,0 @@ |
|||||||
# 测试路由同步优化效果 |
|
||||||
# 检查死循环问题是否已解决 |
|
||||||
|
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
||||||
Write-Host " 路由同步优化测试脚本" -ForegroundColor Cyan |
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
||||||
Write-Host "" |
|
||||||
|
|
||||||
# 设置编码 |
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
|
||||||
$OutputEncoding = [System.Text.Encoding]::UTF8 |
|
||||||
|
|
||||||
# 检查优化后的文件 |
|
||||||
Write-Host "🔍 检查优化后的文件..." -ForegroundColor Yellow |
|
||||||
|
|
||||||
$filesToCheck = @( |
|
||||||
"app\plugins\route-mapping-plugin.js", |
|
||||||
"app\scripts\generate-route-mappings.js", |
|
||||||
"app\vue.config.js", |
|
||||||
"app\src\renderer\modules\route-sync\RouteSyncManager.js", |
|
||||||
"app\src\renderer\main.js", |
|
||||||
"dev-full.ps1" |
|
||||||
) |
|
||||||
|
|
||||||
foreach ($file in $filesToCheck) { |
|
||||||
if (Test-Path $file) { |
|
||||||
Write-Host "✅ $file 存在" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ $file 不存在" -ForegroundColor Red |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "🔧 测试路由映射生成脚本..." -ForegroundColor Yellow |
|
||||||
|
|
||||||
# 进入app目录 |
|
||||||
Set-Location "app" |
|
||||||
|
|
||||||
# 测试检查模式 |
|
||||||
Write-Host "测试 --check-only 模式..." -ForegroundColor Cyan |
|
||||||
try { |
|
||||||
node scripts/generate-route-mappings.js --check-only |
|
||||||
if ($LASTEXITCODE -eq 0) { |
|
||||||
Write-Host "✅ 检查模式测试通过" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ 检查模式测试失败" -ForegroundColor Red |
|
||||||
} |
|
||||||
} catch { |
|
||||||
Write-Host "❌ 检查模式测试异常: $($_.Exception.Message)" -ForegroundColor Red |
|
||||||
} |
|
||||||
|
|
||||||
# 测试正常生成模式 |
|
||||||
Write-Host "测试正常生成模式..." -ForegroundColor Cyan |
|
||||||
try { |
|
||||||
node scripts/generate-route-mappings.js |
|
||||||
if ($LASTEXITCODE -eq 0) { |
|
||||||
Write-Host "✅ 正常生成模式测试通过" -ForegroundColor Green |
|
||||||
} else { |
|
||||||
Write-Host "❌ 正常生成模式测试失败" -ForegroundColor Red |
|
||||||
} |
|
||||||
} catch { |
|
||||||
Write-Host "❌ 正常生成模式测试异常: $($_.Exception.Message)" -ForegroundColor Red |
|
||||||
} |
|
||||||
|
|
||||||
# 返回根目录 |
|
||||||
Set-Location ".." |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "📊 优化总结:" -ForegroundColor Yellow |
|
||||||
Write-Host "1. ✅ 添加了防重复生成机制(5秒冷却时间)" -ForegroundColor Green |
|
||||||
Write-Host "2. ✅ 添加了文件变化检测,只在必要时重新生成" -ForegroundColor Green |
|
||||||
Write-Host "3. ✅ 添加了文件内容比较,避免无意义的文件写入" -ForegroundColor Green |
|
||||||
Write-Host "4. ✅ 优化了启动脚本,避免重复生成" -ForegroundColor Green |
|
||||||
Write-Host "5. ✅ 添加了webpack监听排除规则" -ForegroundColor Green |
|
||||||
Write-Host "6. ✅ 实现了路由同步管理器单例模式" -ForegroundColor Green |
|
||||||
Write-Host "7. ✅ 添加了防重复初始化机制" -ForegroundColor Green |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "🎯 预期效果:" -ForegroundColor Yellow |
|
||||||
Write-Host "- 启动时只生成一次路由映射文件" -ForegroundColor White |
|
||||||
Write-Host "- 热加载时不会重复生成文件" -ForegroundColor White |
|
||||||
Write-Host "- 避免了死循环问题" -ForegroundColor White |
|
||||||
Write-Host "- 提高了开发体验" -ForegroundColor White |
|
||||||
|
|
||||||
Write-Host "" |
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
||||||
Write-Host "测试完成!现在可以尝试启动选项3(热加载监控模式)" -ForegroundColor Green |
|
||||||
Write-Host "========================================" -ForegroundColor Cyan |
|
Loading…
Reference in new issue