diff --git a/demo/README-LOCAL.md b/demo/README-LOCAL.md index ba94d25..5aee428 100644 --- a/demo/README-LOCAL.md +++ b/demo/README-LOCAL.md @@ -273,23 +273,23 @@ export default { methods: { example() { // 成功提示 - this.$uiTool.success('操作成功') + this.$ window.framework.uiTool.success('操作成功') // 错误提示 - this.$uiTool.error('操作失败') + this.$ window.framework.uiTool.error('操作失败') // 警告提示 - this.$uiTool.warning('警告信息') + this.$ window.framework.uiTool.warning('警告信息') // 确认对话框 - this.$uiTool.confirm('确定删除吗?').then(() => { + this.$ window.framework.uiTool.confirm('确定删除吗?').then(() => { // 确认后的操作 }).catch(() => { // 取消后的操作 }) // Loading - const loading = this.$uiTool.loading('加载中...') + const loading = this.$ window.framework.uiTool.loading('加载中...') setTimeout(() => loading.close(), 2000) } } diff --git a/demo/README.md b/demo/README.md index 0c208b9..b136051 100644 --- a/demo/README.md +++ b/demo/README.md @@ -188,13 +188,13 @@ tools.throttle(fn, 500) const uiTool = framework.uiTool // 成功提示 -uiTool.success('操作成功') + window.framework.uiTool.success('操作成功') // 错误提示 -uiTool.error('操作失败') + window.framework.uiTool.error('操作失败') // 确认对话框 -uiTool.confirm('确定删除吗?').then(() => { + window.framework.uiTool.confirm('确定删除吗?').then(() => { // 确认后的操作 }) ``` diff --git a/demo/src/api/ball/game_participants_server.js b/demo/src/api/ball/game_participants_server.js index c1ca2d7..deddcec 100644 --- a/demo/src/api/ball/game_participants_server.js +++ b/demo/src/api/ball/game_participants_server.js @@ -1,6 +1,6 @@ import http from '@/libs/http' -export default { +const gameParticipantsServer = { // 获取球局参与者列表 getGameParticipantsList: (params) => { return window.framework.http.post('/game_participants/page', params) @@ -45,4 +45,14 @@ export default { updateParticipantStatus: (params) => { return window.framework.http.post('/game_participants/update_status', params) } -} \ No newline at end of file +} + +// 添加简写方法名别名,保持向后兼容 +gameParticipantsServer.page = gameParticipantsServer.getGameParticipantsList +gameParticipantsServer.all = gameParticipantsServer.getAllGameParticipants +gameParticipantsServer.add = gameParticipantsServer.addGameParticipant +gameParticipantsServer.edit = gameParticipantsServer.updateGameParticipant +gameParticipantsServer.del = gameParticipantsServer.deleteGameParticipant +gameParticipantsServer.exportCsv = gameParticipantsServer.exportGameParticipants + +export default gameParticipantsServer \ No newline at end of file diff --git a/demo/src/components/CustomPage.vue b/demo/src/components/CustomPage.vue index 177e63f..31ad6b6 100644 --- a/demo/src/components/CustomPage.vue +++ b/demo/src/components/CustomPage.vue @@ -123,19 +123,19 @@ export default { // UI 工具测试 showSuccess() { - this.$uiTool.success('这是一个成功提示') + window.framework.uiTool.success('这是一个成功提示') }, showWarning() { - this.$uiTool.warning('这是一个警告提示') + window.framework.uiTool.warning('这是一个警告提示') }, showError() { - this.$uiTool.error('这是一个错误提示') + window.framework.uiTool.error('这是一个错误提示') }, showConfirm() { - this.$uiTool.confirm('确定要执行此操作吗?').then(() => { + window.framework.uiTool.confirm('确定要执行此操作吗?').then(() => { this.$Message.success('已确认') }).catch(() => { this.$Message.info('已取消') diff --git a/demo/src/router/component-map.js b/demo/src/router/component-map.js index ab88e8b..a6f5d1f 100644 --- a/demo/src/router/component-map.js +++ b/demo/src/router/component-map.js @@ -35,6 +35,8 @@ import Resources from '../views/statistics/resources.vue' import RecommendBlocks from '../views/users/recommend_blocks.vue' import UserFollows from '../views/users/user_follows.vue' import UserTracking from '../views/users/user_tracking.vue' +import WchCities from '../views/users/wch_cities.vue' +import WchProfessions from '../views/users/wch_professions.vue' // ========== 自定义组件 ========== import CustomPage from '../components/CustomPage.vue' @@ -98,6 +100,10 @@ const componentMap = { 'users/user_follows.vue': UserFollows, 'users/user_tracking': UserTracking, 'users/user_tracking.vue': UserTracking, + "users/wch_cities.vue": WchCities, + "users/wch_cities": WchCities, + "users/wch_professions.vue": WchProfessions, + "users/wch_professions": WchProfessions, // ===== 自定义组件 ===== 'custom/page': CustomPage, diff --git a/demo/src/views/ai/ai_messages.vue b/demo/src/views/ai/ai_messages.vue index b6f19c9..2fc7bce 100644 --- a/demo/src/views/ai/ai_messages.vue +++ b/demo/src/views/ai/ai_messages.vue @@ -40,8 +40,8 @@ -``` - -## 四、完整的页面示例 - -```vue - - - - - -``` - -## 五、全局可用的对象 - -在任何 Vue 组件中,都可以使用以下对象: - -| 对象 | 说明 | 使用示例 | -|-----|------|---------| -| `this.$http` | HTTP 请求实例 | `this.$http.get('/api/users')` | -| `this.$tools` | 工具函数集合 | `this.$tools.formatDate(new Date())` | -| `this.$uiTool` | UI 工具函数 | `this.$uiTool.success('成功')` | -| `this.$config` | 配置对象 | `this.$config.apiUrl` | -| `this.$router` | 路由实例 | `this.$router.push({ path: '/home' })` | -| `this.$store` | Vuex Store | `this.$store.state.user.userName` | -| `window.framework` | 框架实例 | `window.framework.version` | -| `window.app` | Vue 根实例 | `window.app.$router` | - -## 六、注意事项 - -1. ❌ **不要尝试导入框架内部模块** - ```javascript - import http from '@/utils/admin-framework.js' // ❌ 错误 - import tools from 'admin-framework/tools' // ❌ 错误 - ``` - -2. ✅ **使用 Vue 实例上的属性** - ```javascript - this.$http // ✅ 正确 - this.$tools // ✅ 正确 - this.$uiTool // ✅ 正确 - ``` - -3. ✅ **或使用全局对象** - ```javascript - window.framework.http // ✅ 正确 - window.framework.tools // ✅ 正确 - window.framework.uiTool // ✅ 正确 - ``` - -4. **路由跳转使用 path 而不是 name** - ```javascript - this.$router.push({ path: '/ball/games' }) // ✅ 正确 - this.$router.push({ name: '球赛管理' }) // ❌ 错误(name 可能不存在) - ``` - -## 七、快速开始检查清单 - -- [ ] 框架已构建:`npm run build` -- [ ] Demo 依赖已安装:`cd demo && npm install` -- [ ] 组件映射表已配置:`demo/src/router/component-map.js` -- [ ] API 地址已配置:`demo/src/main.js` 中的 `config.apiUrl` -- [ ] 页面中使用 `this.$http` 而不是 `import http` -- [ ] 路由跳转使用 `path` 而不是 `name` - diff --git a/demo/快速修复指南.md b/demo/快速修复指南.md deleted file mode 100644 index 400bfc0..0000000 --- a/demo/快速修复指南.md +++ /dev/null @@ -1,145 +0,0 @@ -# 🚀 快速修复指南 - -## ❌ 常见错误用法 - -### 1. 错误的 HTTP 导入 -```javascript -// ❌ 错误!不要这样写 -import http from '@/utils/admin-framework.js' -import { http } from 'admin-framework' - -// ✅ 正确!直接使用 -this.$http.get('/api/xxx') -window.framework.http.get('/api/xxx') -``` - -### 2. 错误的工具函数导入 -```javascript -// ❌ 错误!不要这样写 -import tools from 'admin-framework/tools' - -// ✅ 正确!直接使用 -this.$tools.formatDate(new Date()) -window.framework.tools.formatDate(new Date()) -``` - -## ✅ 正确的使用方式 - -### 在 Vue 组件中 - -```vue - -``` - -### 在 API 模块中 - -```javascript -// src/api/ball/gamesServer.js - -class GamesServer { - async getList(params) { - // ✅ 使用 window.framework.http - return await window.framework.http.post('/games/page', params) - } -} - -export default new GamesServer() -``` - -### 在组件中使用 API - -```vue - -``` - -## 📝 修改步骤 - -### 步骤1:修改所有 API 文件 - -查找并替换: -```javascript -// 查找 -import http from '@/utils/admin-framework.js' -http.http.get(...) - -// 替换为 -window.framework.http.get(...) -``` - -### 步骤2:修改路由跳转 - -查找并替换: -```javascript -// 查找 -this.$router.push({ name: 'xxx' }) - -// 替换为 -this.$router.push({ path: '/xxx/yyy' }) -``` - -### 步骤3:重新构建框架 - -```bash -# 在项目根目录 -npm run build -``` - -### 步骤4:测试 - -```bash -# 在 demo 目录 -cd demo -npm run dev -``` - -## 🔍 检查清单 - -- [ ] 所有 API 文件都使用 `window.framework.http` -- [ ] 所有路由跳转都使用 `path` 而不是 `name` -- [ ] 组件中使用 `this.$http`、`this.$tools`、`this.$uiTool` -- [ ] 组件映射表已配置(`demo/src/router/component-map.js`) -- [ ] 框架已重新构建(`npm run build`) -- [ ] Demo 可以正常运行(`cd demo && npm run dev`) - -## 📚 更多说明 - -详细使用说明请查看: -- `demo/使用说明.md` - 完整的使用指南 -- `demo/src/api/ball/gamesServer.js` - API 模块示例 -- `_doc/完整使用文档.md` - 框架完整文档 -