This commit is contained in:
张成
2025-10-28 14:10:05 +08:00
parent b101f49048
commit 5bea5f8c02
21 changed files with 105 additions and 151 deletions

View File

@@ -65,11 +65,9 @@ npm run dev
首先需要构建 admin-framework
```bash
# 生产构建(压缩,无 sourcemap
# 在项目根目录执行
cd ..
npm run build
# 开发构建(不压缩,有 sourcemap
npm run build:dev
```
### 2. 启动示例
@@ -109,16 +107,26 @@ const config = {
}
```
### 初始化框架
### 初始化框架(新版本 - 推荐)
```javascript
framework.install(Vue, {
config: config, // 配置对象
ViewUI: iview, // iView 实例
VueRouter: VueRouter, // Vue Router
Vuex: Vuex, // Vuex
createPersistedState: null, // Vuex 持久化插件(可选)
componentMap: {} // 自定义组件映射
// 引入 Admin Framework
import AdminFramework from '../../dist/admin-framework.js'
// 引入组件映射表
import componentMap from './router/component-map.js'
// 创建应用
const app = AdminFramework.createApp({
title: '我的管理系统',
apiUrl: 'http://localhost:9098/admin_api/',
componentMap: componentMap,
onReady() {
console.log('应用已准备就绪!')
}
})
// 挂载应用
app.$mount('#app')
```
## 内置功能
@@ -146,28 +154,30 @@ framework.install(Vue, {
### HTTP 请求
```javascript
// GET 请求
framework.http.get('/api/users').then(res => {
window.framework.http.get('/api/users').then(res => {
console.log(res.data)
})
// POST 请求
framework.http.post('/api/users', {
window.framework.http.post('/api/users', {
name: '张三',
age: 25
}).then(res => {
console.log(res.data)
})
// 在件中使用
this.$http.get('/api/users').then(res => {
console.log(res.data)
})
// 在 API 文件中使用
class UserServer {
async getList(params) {
return await window.framework.http.get('/api/users', params)
}
}
```
### 工具函数
```javascript
// 使用框架提供的工具函数
const tools = framework.tools
const tools = window.framework.tools
// 日期格式化
tools.formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
@@ -185,7 +195,7 @@ tools.throttle(fn, 500)
### UI 工具
```javascript
// 使用 UI 工具
const uiTool = framework.uiTool
const uiTool = window.framework.uiTool
// 成功提示
window.framework.uiTool.success('操作成功')

View File

@@ -1,33 +1,24 @@
import request from '@/libs/http'
/**
* 业务游戏管理 API
*
* 使用说明:
* 1. 不需要 import http
* 2. 直接使用 window.framework.http 调用接口
* 3. 所有方法返回 Promise
*/
export const getList = (params) => {
return request({
url: '/business/games/page',
method: 'get',
params
})
return window.framework.http.get('/business/games/page', params)
}
export const add = (data) => {
return request({
url: '/business/games',
method: 'post',
data
})
return window.framework.http.post('/business/games/add', data)
}
export const edit = (data) => {
return request({
url: '/business/games',
method: 'put',
data
})
return window.framework.http.post('/business/games/edit', data)
}
export const del = (params) => {
return request({
url: '/business/games',
method: 'delete',
params
})
return window.framework.http.post('/business/games/del', params)
}

View File

@@ -3,7 +3,7 @@
export default {
// 获取消息通知列表
page: (params) => {
return http.post('/msg_notifications/page', params)
return window.framework.http.post('/msg_notifications/page', params)
},
// 新增消息通知

View File

@@ -1,33 +1,24 @@
import request from '@/libs/http'
/**
* 系统文件管理 API
*
* 使用说明:
* 1. 不需要 import http
* 2. 直接使用 window.framework.http 调用接口
* 3. 所有方法返回 Promise
*/
export const getList = (params) => {
return request({
url: '/sys_file/page',
method: 'get',
params
})
return window.framework.http.get('/sys_file/page', params)
}
export const add = (data) => {
return request({
url: '/sys_file',
method: 'post',
data
})
return window.framework.http.post('/sys_file/add', data)
}
export const edit = (data) => {
return request({
url: '/sys_file',
method: 'put',
data
})
return window.framework.http.post('/sys_file/edit', data)
}
export const del = (params) => {
return request({
url: '/sys_file',
method: 'delete',
params
})
return window.framework.http.post('/sys_file/del', params)
}

View File

@@ -1,57 +1,41 @@
/**
* 球局统计 API
*
* 使用说明:
* 1. 不需要 import http
* 2. 直接使用 window.framework.http 调用接口
* 3. 所有方法返回 Promise
*/
// 获取球局统计列表
export const getList = (params) => {
return http.request({
url: '/admin/game_statistics/list',
method: 'post',
data: params
})
return window.framework.http.post('/admin/game_statistics/list', params)
}
// 获取球局统计详情
export const getDetail = (params) => {
return http.request({
url: '/admin/game_statistics/detail',
method: 'post',
data: params
})
return window.framework.http.post('/admin/game_statistics/detail', params)
}
// 添加球局统计
export const add = (params) => {
return http.request({
url: '/admin/game_statistics/add',
method: 'post',
data: params
})
return window.framework.http.post('/admin/game_statistics/add', params)
}
// 编辑球局统计
export const edit = (params) => {
return http.request({
url: '/admin/game_statistics/edit',
method: 'post',
data: params
})
return window.framework.http.post('/admin/game_statistics/edit', params)
}
// 删除球局统计
export const del = (params) => {
return http.request({
url: '/admin/game_statistics/del',
method: 'post',
data: params
})
return window.framework.http.post('/admin/game_statistics/del', params)
}
// 导出球局统计
export const exportData = (params) => {
return http.request({
url: '/admin/game_statistics/export',
method: 'post',
data: params,
responseType: 'blob'
})
return window.framework.http.fileExport('/admin/game_statistics/export', params)
}

View File

@@ -1,66 +1,46 @@
/**
* 营收统计 API
*
* 使用说明:
* 1. 不需要 import http
* 2. 直接使用 window.framework.http 调用接口
* 3. 所有方法返回 Promise
*/
// 获取营收统计列表
export const getList = (params) => {
return http.request({
url: '/admin/revenue_statistics/list',
method: 'post',
data: params
})
return window.framework.http.post('/admin/revenue_statistics/list', params)
}
// 获取营收统计详情
export const getDetail = (params) => {
return http.request({
url: '/admin/revenue_statistics/detail',
method: 'post',
data: params
})
return window.framework.http.post('/admin/revenue_statistics/detail', params)
}
// 获取营收统计概览
export const getOverview = (params) => {
return http.request({
url: '/admin/revenue_statistics/overview',
method: 'post',
data: params
})
return window.framework.http.post('/admin/revenue_statistics/overview', params)
}
// 添加营收统计
export const add = (params) => {
return http.request({
url: '/admin/revenue_statistics/add',
method: 'post',
data: params
})
return window.framework.http.post('/admin/revenue_statistics/add', params)
}
// 编辑营收统计
export const edit = (params) => {
return http.request({
url: '/admin/revenue_statistics/edit',
method: 'post',
data: params
})
return window.framework.http.post('/admin/revenue_statistics/edit', params)
}
// 删除营收统计
export const del = (params) => {
return http.request({
url: '/admin/revenue_statistics/del',
method: 'post',
data: params
})
return window.framework.http.post('/admin/revenue_statistics/del', params)
}
// 导出营收统计
export const exportData = (params) => {
return http.request({
url: '/admin/revenue_statistics/export',
method: 'post',
data: params,
responseType: 'blob'
})
return window.framework.http.fileExport('/admin/revenue_statistics/export', params)
}

View File

@@ -1,6 +1,7 @@
// 引入 Admin Framework框架内部已包含所有依赖和样式
import AdminFramework from '../../dist/admin-framework.js'
// 引入组件映射表
import componentMap from './router/component-map.js'

View File

@@ -146,7 +146,7 @@ export default {
},
exportCsv() {
ai_messagesServer.exportCsv(this.gridOption.param).then(res => {
window.framework.funTool.downloadFile(res, 'AI消息管理.csv');
window.framework.tools.downloadFile(res, 'AI消息管理.csv');
});
},
resetQuery() {

View File

@@ -147,7 +147,7 @@ export default {
},
exportCsv() {
game_commentsServer.exportCsv(this.gridOption.param).then(res => {
window.framework.funTool.downloadFile(res, '球局评论.csv');
window.framework.tools.downloadFile(res, '球局评论.csv');
});
}
},

View File

@@ -164,7 +164,7 @@ export default {
},
exportCsv() {
msg_notificationsServer.exportCsv(this.gridOption.param).then(res => {
window.framework.funTool.downloadFile(res, '消息通知.csv');
window.framework.tools.downloadFile(res, '消息通知.csv');
});
},
resetQuery() {

View File

@@ -229,7 +229,7 @@ export default {
},
exportCsv() {
ntr_questionsServer.exportCsv(this.gridOption.param).then(res => {
window.framework.funTool.downloadFile(res, '题库管理.csv');
window.framework.tools.downloadFile(res, '题库管理.csv');
});
}
},

View File

@@ -247,7 +247,7 @@ export default {
},
exportCsv() {
ntr_recordsServer.exportCsv(this.gridOption.param).then(res => {
window.framework.funTool.downloadFile(res, '测试记录.csv');
window.framework.tools.downloadFile(res, '测试记录.csv');
});
}
},

View File

@@ -3,12 +3,7 @@ import ParentView from './parent-view'
// 导入页面组件
import pages from '../views/index'
const {
LoginPage,
Page401,
Page404,
Page500
} = pages
const {LoginPage,Page401,Page404,Page500} = pages
import Tables from './tables'
import UploadSingle from './upload/Single.vue'
@@ -26,8 +21,10 @@ import fieldItem from './tables/fieldItem.vue'
import FieldRenderer from './tables/fieldRenderer.vue'
// 注册全局组件的方法
export function registerGlobalComponents(Vue) {
const registerGlobalComponents = (Vue) => {
Vue.component('Main', Main)
Vue.component('ParentView', ParentView)
@@ -54,7 +51,7 @@ export function registerGlobalComponents(Vue) {
}
// 注册自定义组件的方法
export function registerComponents(Vue, components = {}) {
const registerComponents = (Vue, components = {}) => {
Object.keys(components).forEach(name => {
Vue.component(name, components[name])
})
@@ -65,6 +62,7 @@ export {
registerComponents
}
export default {
Main,
ParentView,
@@ -83,7 +81,6 @@ export default {
fieldItem,
FieldRenderer,
}

View File

@@ -25,8 +25,8 @@ import storeModules, { createStore } from './store'
import { createBaseRoutes, setupRouterGuards, createRouter, getRoutes } from './router'
import components from './components/index'
import { registerGlobalComponents } from './components/index'
import components ,{ registerGlobalComponents} from './components/index'
import pages from './views/index'
const { LoginPage, Page401, Page404, Page500, setupComponentMap } = pages

View File

@@ -5,8 +5,8 @@ import appModule from './app'
export function createStore(Vuex, customModules = {}, createPersistedState) {
const store = new Vuex.Store({
modules: {
user: appModule,
app: userModule,
user: userModule,
app: appModule,
...customModules
},
plugins: createPersistedState ? [