From e039ae8c627cfc4cc54f797e2c86518f857b9ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Tue, 28 Oct 2025 11:24:11 +0800 Subject: [PATCH] 1 --- README.md | 2 +- _doc/完整使用文档.md | 18 +- demo/src/api/system/shpProfitServer.js | 15 - demo/src/views/ball/game_participants.vue | 2 +- demo/src/views/ball/games.vue | 2 +- demo/src/views/ball/venues.vue | 2 +- demo/src/views/ball/wch_users.vue | 2 +- demo/src/views/order/wallet_transactions.vue | 2 +- demo/src/views/users/wch_professions.vue | 2 +- .../formFieldServer.js | 0 src/api/{system_high => system}/formServer.js | 0 src/api/system/index.js | 12 +- src/api/{system_high => system}/menuServer.js | 0 .../modelFieldServer.js | 0 .../{system_high => system}/modelServer.js | 0 .../paramSetupServer.js | 0 src/api/system/shpProfitServer.js | 15 - .../sysControlTypeServer.js | 0 src/api/system_high/index.js | 10 - src/components/date-picker/index.vue | 21 ++ src/components/index.js | 84 +++++ src/components/switch/index.vue | 20 ++ src/components/tables/editModal.vue | 70 ++-- src/components/tables/fieldRenderer.vue | 196 +++++++++++ src/config/menuConfig.js | 14 +- src/index.js | 326 ++++-------------- src/router/index.js | 43 ++- src/store/app.js | 2 +- src/store/index.js | 21 +- src/views/index.js | 61 ++++ .../{system_high => system}/sys_control.vue | 4 +- .../{system_high => system}/sys_menu.vue | 2 +- src/views/system/sys_param_setup.vue | 2 +- src/views/system/sys_role.vue | 2 +- .../{system_high => system}/sys_title.vue | 2 +- src/views/system_high/com/databaseType.vue | 33 -- .../system_high/com/frontEndControlType.vue | 251 -------------- 使用说明.md | 68 +++- 快速开始.md | 6 +- 39 files changed, 636 insertions(+), 676 deletions(-) delete mode 100644 demo/src/api/system/shpProfitServer.js rename src/api/{system_high => system}/formFieldServer.js (100%) rename src/api/{system_high => system}/formServer.js (100%) rename src/api/{system_high => system}/menuServer.js (100%) rename src/api/{system_high => system}/modelFieldServer.js (100%) rename src/api/{system_high => system}/modelServer.js (100%) rename src/api/{system_high => system}/paramSetupServer.js (100%) delete mode 100644 src/api/system/shpProfitServer.js rename src/api/{system_high => system}/sysControlTypeServer.js (100%) delete mode 100644 src/api/system_high/index.js create mode 100644 src/components/date-picker/index.vue create mode 100644 src/components/index.js create mode 100644 src/components/switch/index.vue create mode 100644 src/components/tables/fieldRenderer.vue create mode 100644 src/views/index.js rename src/views/{system_high => system}/sys_control.vue (97%) rename src/views/{system_high => system}/sys_menu.vue (99%) rename src/views/{system_high => system}/sys_title.vue (95%) delete mode 100644 src/views/system_high/com/databaseType.vue delete mode 100644 src/views/system_high/com/frontEndControlType.vue diff --git a/README.md b/README.md index 87533c4..421455f 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ admin-framework/ │ │ ├── home/ # 主页 │ │ ├── login/ # 登录页 │ │ ├── system/ # 系统管理页面 -│ │ └── system_high/ # 高级系统页面 +│ │ └── system/ # 高级系统页面 │ └── index.js # 框架入口 ├── dist/ # 打包产物 │ └── admin-framework.js # 框架打包文件(3.6 MB,内置所有依赖) diff --git a/_doc/完整使用文档.md b/_doc/完整使用文档.md index 461a6e9..a0318d6 100644 --- a/_doc/完整使用文档.md +++ b/_doc/完整使用文档.md @@ -43,7 +43,7 @@ npm run dev ✅ **主页组件**(欢迎页面,自动显示系统标题) ✅ **系统管理页面**(sys 开头的所有页面和功能) -✅ **系统 API**(system 和 system_high 所有 API) +✅ **系统 API**(system 和 system 所有 API) ✅ **全局组件**(Tables、Editor、Upload 等) ✅ **布局组件**(Main、ParentView) ✅ **登录和错误页面**(Login、401、404、500) @@ -139,8 +139,8 @@ import AdminFramework from 'admin-framework' ✅ **已包含**: - **主页组件**(HomePage - 欢迎页面,显示系统标题) -- 所有系统页面(system、system_high) -- 所有系统 API(system、system_high) +- 所有系统页面(system、system) +- 所有系统 API(system、system) - 所有全局组件(Tables、Editor、Upload 等) - 布局组件(Main、ParentView) - 登录和错误页面 @@ -605,7 +605,7 @@ import { } from 'admin-framework' ``` -#### system_high 目录页面 +#### system 目录页面 ```javascript import { SysControl, // 控制器管理 @@ -635,7 +635,7 @@ const routes = [ component: SysRole }, { - path: '/system_high/menu', + path: '/system/menu', name: 'sys_menu', component: SysMenu } @@ -662,7 +662,7 @@ const users = await userServer.getList({ page: 1 }) const roles = await roleServer.getList() ``` -#### system_high API +#### system API ```javascript import { systemHighApi } from 'admin-framework' @@ -1229,9 +1229,9 @@ AdminFramework.addComponentMap({ - ✅ `system/sys_role.vue` - 角色管理 - ✅ `system/sys_log.vue` - 日志管理 - ✅ `system/sys_param_setup.vue` - 参数设置 -- ✅ `system_high/sys_menu.vue` - 菜单管理 -- ✅ `system_high/sys_control.vue` - 控制器管理 -- ✅ `system_high/sys_title.vue` - 系统标题设置 +- ✅ `system/sys_menu.vue` - 菜单管理 +- ✅ `system/sys_control.vue` - 控制器管理 +- ✅ `system/sys_title.vue` - 系统标题设置 #### 配置技巧 diff --git a/demo/src/api/system/shpProfitServer.js b/demo/src/api/system/shpProfitServer.js deleted file mode 100644 index 8ac9da0..0000000 --- a/demo/src/api/system/shpProfitServer.js +++ /dev/null @@ -1,15 +0,0 @@ - -class ShpProfitServer { - async report(param) { - let res = await window.framework.http.post('/shpProfit/report', param) - return res - } - - async list(param) { - let res = await window.framework.http.post('/shpProfit/list', param) - return res - } -} - -const shpProfitServer = new ShpProfitServer() -export default shpProfitServer diff --git a/demo/src/views/ball/game_participants.vue b/demo/src/views/ball/game_participants.vue index ff97d06..41dd8d2 100644 --- a/demo/src/views/ball/game_participants.vue +++ b/demo/src/views/ball/game_participants.vue @@ -41,7 +41,7 @@ diff --git a/src/components/index.js b/src/components/index.js new file mode 100644 index 0000000..742caf1 --- /dev/null +++ b/src/components/index.js @@ -0,0 +1,84 @@ +import Main from './main' +import ParentView from './parent-view' + +// 导入页面组件 +import pages from '../views/index' +const { + LoginPage, + Page401, + Page404, + Page500 +} = pages + +import Tables from './tables' +import UploadSingle from './upload/Single.vue' +import UploadMultiple from './upload/Multiple.vue' +import TreeGrid from './treeGrid' +import AsyncModal from './asyncModal' +import InfoCard from './info-card' +import LoadFlower from './load-flower' +import SplitPane from './split-pane' +import TextArea from './text-area' +import CommonIcon from './common-icon' +import Editor from './editor/index.vue' +import editModal from './tables/editModal.vue' +import fieldItem from './tables/fieldItem.vue' +import FieldRenderer from './tables/fieldRenderer.vue' + + +// 注册全局组件的方法 +export function registerGlobalComponents(Vue) { + Vue.component('Main', Main) + Vue.component('ParentView', ParentView) + + Vue.component('Page401', Page401) + Vue.component('Page404', Page404) + Vue.component('Page500', Page500) + + Vue.component('LoginPage', LoginPage) + + Vue.component('Tables', Tables) + Vue.component('UploadSingle', UploadSingle) + Vue.component('UploadMultiple', UploadMultiple) + Vue.component('TreeGrid', TreeGrid) + Vue.component('AsyncModal', AsyncModal) + Vue.component('InfoCard', InfoCard) + Vue.component('LoadFlower', LoadFlower) + Vue.component('SplitPane', SplitPane) + Vue.component('TextArea', TextArea) + Vue.component('CommonIcon', CommonIcon) + Vue.component('Editor', Editor) + Vue.component('editModal', editModal) + Vue.component('fieldItem', fieldItem) + Vue.component('FieldRenderer', FieldRenderer) +} + +// 注册自定义组件的方法 +export function registerComponents(Vue, components = {}) { + Object.keys(components).forEach(name => { + Vue.component(name, components[name]) + }) +} + +export default { + Main, + ParentView, + Tables, + UploadSingle, + UploadMultiple, + TreeGrid, + AsyncModal, + InfoCard, + LoadFlower, + SplitPane, + TextArea, + CommonIcon, + Editor, + editModal, + fieldItem, + FieldRenderer, + registerGlobalComponents, + registerComponents +} + + diff --git a/src/components/switch/index.vue b/src/components/switch/index.vue new file mode 100644 index 0000000..3e2662a --- /dev/null +++ b/src/components/switch/index.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/components/tables/editModal.vue b/src/components/tables/editModal.vue index db65a93..a53e1cf 100644 --- a/src/components/tables/editModal.vue +++ b/src/components/tables/editModal.vue @@ -13,38 +13,14 @@
- - - - - - {{item.value}} - - - - - - - - - - - - - - - - - - - + +
@@ -64,21 +40,12 @@ diff --git a/src/config/menuConfig.js b/src/config/menuConfig.js index a1b5053..9af152c 100644 --- a/src/config/menuConfig.js +++ b/src/config/menuConfig.js @@ -75,7 +75,7 @@ export const defaultMenus = [ { id: 120, name: '高级管理', - path: '/system_high', + path: '/system', component: '', parent_id: 0, type: '菜单', @@ -86,8 +86,8 @@ export const defaultMenus = [ { id: 122, name: '菜单管理', - path: '/system_high/menu', - component: 'system_high/sys_menu', + path: '/system/menu', + component: 'system/sys_menu', parent_id: 120, type: '页面', is_show_menu: 1, @@ -97,8 +97,8 @@ export const defaultMenus = [ { id: 123, name: '控制管理', - path: '/system_high/control', - component: 'system_high/sys_control', + path: '/system/control', + component: 'system/sys_control', parent_id: 120, type: '页面', is_show_menu: 1, @@ -108,8 +108,8 @@ export const defaultMenus = [ { id: 124, name: '系统标题', - path: '/system_high/title', - component: 'system_high/sys_title', + path: '/system/title', + component: 'system/sys_title', parent_id: 120, type: '页面', is_show_menu: 1, diff --git a/src/index.js b/src/index.js index c27e15a..c22adc7 100644 --- a/src/index.js +++ b/src/index.js @@ -20,197 +20,64 @@ import uiTool from './utils/uiTool' import http from './utils/http' import * as tools from './utils/tools' -import storeModules, { userModule, appModule } from './store' +import storeModules, { createStore } from './store' -import { createBaseRoutes, setupRouterGuards } from './router' +import { createBaseRoutes, setupRouterGuards, createRouter, getRoutes } from './router' -import HomePage from './views/home/index.vue' -import SysLog from './views/system/sys_log.vue' -import SysParamSetup from './views/system/sys_param_setup.vue' -import SysRole from './views/system/sys_role.vue' -import SysUser from './views/system/sys_user.vue' -import SysControl from './views/system_high/sys_control.vue' -import SysMenu from './views/system_high/sys_menu.vue' -import SysTitle from './views/system_high/sys_title.vue' - -import LoginPage from './views/login/login.vue' - -import Page401 from './views/error-page/401.vue' -import Page404 from './views/error-page/404.vue' -import Page500 from './views/error-page/500.vue' +import components from './components/index' +import pages from './views/index' +// 导入页面组件 import Main from './components/main' import ParentView from './components/parent-view' -import Tables from './components/tables' -import UploadSingle from './components/upload/Single.vue' -import UploadMultiple from './components/upload/Multiple.vue' -import TreeGrid from './components/treeGrid' -import AsyncModal from './components/asyncModal' -import InfoCard from './components/info-card' -import LoadFlower from './components/load-flower' -import SplitPane from './components/split-pane' -import TextArea from './components/text-area' -import CommonIcon from './components/common-icon' -import Editor from './components/editor/index.vue' -import editModal from './components/tables/editModal.vue' -import fieldItem from './components/tables/fieldItem.vue' +// 通过模块化方式导入页面组件 +const { + HomePage, + LoginPage, + Page401, + Page404, + Page500, + SysLog, + SysParamSetup, + SysRole, + SysUser, + SysControl, + SysMenu, + SysTitle, + setupComponentMap +} = pages + +// 导入组件相关功能 +import components, { registerGlobalComponents, registerComponents } from './components/index' import * as systemApi from './api/system' -import * as systemHighApi from './api/system_high' class AdminFramework { constructor() { this.version = '1.0.0' - this.installed = false this.config = {} this.store = null this.router = null - this.ViewUI = null this.tools = tools this.uiTool = uiTool this.http = http this.storeModules = storeModules - this.userModule = userModule - this.appModule = appModule this.createBaseRoutes = createBaseRoutes this.setupRouterGuards = setupRouterGuards - this.Main = Main - this.ParentView = ParentView - this.LoginPage = LoginPage - this.Page401 = Page401 - this.Page404 = Page404 - this.Page500 = Page500 - - this.HomePage = HomePage - this.SysLog = SysLog - this.SysParamSetup = SysParamSetup - this.SysRole = SysRole - this.SysUser = SysUser - this.SysControl = SysControl - this.SysMenu = SysMenu - this.SysTitle = SysTitle - + this.pages = pages + this.components = components this.systemApi = systemApi - this.systemHighApi = systemHighApi } - /** - * Vue plugin install method - * @param {Object} Vue - Vue instance - * @param {Object} options - config options - */ - install(Vue, options = {}) { - if (this.installed) return - this.installed = true - - const { config = {}, ViewUI, VueRouter, Vuex, createPersistedState, componentMap } = options - this.config = config - this.ViewUI = ViewUI - - if (ViewUI) { - Vue.use(ViewUI) - } - - if (VueRouter) { - Vue.use(VueRouter) - } - - if (Vuex) { - Vue.use(Vuex) - } - - Vue.prototype.$config = config - Vue.prototype.$http = http - Vue.prototype.$tools = tools - Vue.prototype.$uiTool = uiTool - Vue.prototype.$framework = this - - this.registerGlobalComponents(Vue) - - this.setupComponentMap(componentMap) - - if (Vuex && !this.store) { - this.store = this.createStore(Vuex, {}, createPersistedState) - http.init(config, this.store) - } - - if (VueRouter && !this.router) { - const mainRoute = this.getRoutes({ Main, ParentView, Page404, HomePage: this.HomePage }) - - this.router = this.createRouter(VueRouter, { - Main, - ParentView, - LoginPage, - Page401, - Page404, - Page500 - }, mainRoute ? [mainRoute] : [], ViewUI) - } - } - - /** - * Register global components - */ - registerGlobalComponents(Vue) { - Vue.component('Main', Main) - Vue.component('ParentView', ParentView) - - Vue.component('Page401', Page401) - Vue.component('Page404', Page404) - Vue.component('Page500', Page500) - - Vue.component('LoginPage', LoginPage) - - Vue.component('Tables', Tables) - Vue.component('UploadSingle', UploadSingle) - Vue.component('UploadMultiple', UploadMultiple) - Vue.component('TreeGrid', TreeGrid) - Vue.component('AsyncModal', AsyncModal) - Vue.component('InfoCard', InfoCard) - Vue.component('LoadFlower', LoadFlower) - Vue.component('SplitPane', SplitPane) - Vue.component('TextArea', TextArea) - Vue.component('CommonIcon', CommonIcon) - Vue.component('Editor', Editor) - Vue.component('editModal', editModal) - Vue.component('fieldItem', fieldItem) - } - - /** - * Setup component map - * @param {Object} customMap - custom component map - */ - setupComponentMap(customMap = {}) { - const components = { - 'home/index': HomePage, - 'system/sys_log': SysLog, - 'system/sys_param_setup': SysParamSetup, - 'system/sys_role': SysRole, - 'system/sys_user': SysUser, - 'system_high/sys_control': SysControl, - 'system_high/sys_menu': SysMenu, - 'system_high/sys_title': SysTitle, - ...customMap - } - - const map = {} - Object.keys(components).forEach(path => { - const cleanPath = path.replace(/\.vue$/, '') - map[cleanPath] = components[path] - map[cleanPath + '.vue'] = components[path] - }) - - uiTool.setComponentMap(map) - } /** * Add custom component map @@ -222,7 +89,7 @@ class AdminFramework { * }) */ addComponentMap(customMap) { - uiTool.setComponentMap(customMap) + setupComponentMap(customMap, uiTool) } /** @@ -235,88 +102,9 @@ class AdminFramework { this.store = store } - /** - * Create router instance - * @param {Object} Router - VueRouter class - * @param {Object} components - component object - * @param {Array} customRoutes - custom routes - * @param {Object} ViewUI - ViewUI instance - * @param {String} homeName - home page name - * @returns {Object} router instance - */ - createRouter(Router, components = {}, customRoutes = [], ViewUI, homeName = 'home') { - const { LoginPage, Page401, Page404, Page500 } = components - if (!LoginPage || !Page401 || !Page404 || !Page500) { - console.error('Missing required page components') - return null - } - const baseRoutes = createBaseRoutes(LoginPage, Page401, Page404, Page500) - const router = new Router({ - routes: [...baseRoutes, ...customRoutes], - mode: 'hash' - }) - - if (ViewUI) { - setupRouterGuards(router, ViewUI, homeName) - } - - return router - } - - /** - * Create Store instance - * @param {Object} Vuex - Vuex class - * @param {Object} customModules - custom modules - * @param {Object} createPersistedState - vuex-persistedstate plugin - * @returns {Object} store instance - */ - createStore(Vuex, customModules = {}, createPersistedState) { - const store = new Vuex.Store({ - modules: { - user: userModule, - app: appModule, - ...customModules - }, - plugins: createPersistedState ? [ - createPersistedState({ - storage: window.localStorage - }) - ] : [] - }) - - this.store = store - return store - } - - /** - * Get dynamic routes - * @param {Object} components - component object - * @returns {Object} main route config - */ - getRoutes(components = {}) { - const { Main, ParentView, Page404, HomePage } = components - - if (!Main || !ParentView || !Page404) { - console.error('Missing required layout components') - return null - } - - return uiTool.getRoutes(Main, ParentView, Page404, HomePage || this.HomePage) - } - - /** - * Register global components - * @param {Object} Vue - Vue instance - * @param {Object} components - component object - */ - registerComponents(Vue, components = {}) { - Object.keys(components).forEach(name => { - Vue.component(name, components[name]) - }) - } /** * Create app with simplified API (推荐使用) @@ -329,23 +117,50 @@ class AdminFramework { * @returns {Object} Vue instance */ createApp(config = {}) { - // Auto install framework using internal dependencies - if (!this.installed) { - const { componentMap, ...appConfig } = config + // 如果没有提供 uploadUrl,自动从 apiUrl 推导 + if (!config.uploadUrl && config.apiUrl) { + config.uploadUrl = config.apiUrl + (config.apiUrl.endsWith('/') ? 'upload' : '/upload') + } - // 如果没有提供 uploadUrl,自动从 apiUrl 推导 - if (!appConfig.uploadUrl && appConfig.apiUrl) { - appConfig.uploadUrl = appConfig.apiUrl + (appConfig.apiUrl.endsWith('/') ? 'upload' : '/upload') - } + // 设置配置 + this.config = config - this.install(Vue, { - config: appConfig, - ViewUI, - VueRouter, - Vuex, - createPersistedState: null, - componentMap: componentMap || {} - }) + // 初始化 Vue 插件 + Vue.use(ViewUI) + Vue.use(VueRouter) + Vue.use(Vuex) + + // 设置全局属性 + Vue.prototype.$config = config + Vue.prototype.$http = http + Vue.prototype.$tools = tools + Vue.prototype.$uiTool = uiTool + Vue.prototype.$framework = this + + // 注册全局组件 + registerGlobalComponents(Vue) + + // 设置组件映射 + setupComponentMap(config.componentMap || {}, uiTool) + + // 创建 Store + if (!this.store) { + this.store = createStore(Vuex, {}, null) + http.init(config, this.store) + } + + // 创建 Router + if (!this.router) { + const mainRoute = getRoutes({ Main, ParentView, Page404, HomePage: this.HomePage }, uiTool) + + this.router = createRouter(VueRouter, { + Main, + ParentView, + LoginPage, + Page401, + Page404, + Page500 + }, mainRoute ? [mainRoute] : [], ViewUI) } // Create Vue instance with auto menu/title restoration @@ -421,9 +236,6 @@ export { http, storeModules, - userModule, - appModule, - createBaseRoutes, setupRouterGuards, diff --git a/src/router/index.js b/src/router/index.js index e694132..b2b33d0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -89,8 +89,45 @@ export const setupRouterGuards = (router, ViewUI, homeName = 'home') => { return router } -export default { - createBaseRoutes, - setupRouterGuards +// 获取动态路由的方法 +export function getRoutes(components = {}, uiTool) { + const { Main, ParentView, Page404, HomePage } = components + + if (!Main || !ParentView || !Page404) { + console.error('Missing required layout components') + return null + } + + return uiTool.getRoutes(Main, ParentView, Page404, HomePage) +} + +// 创建路由实例的方法 +export function createRouter(Router, components = {}, customRoutes = [], ViewUI) { + const { LoginPage, Page401, Page404, Page500 } = components + + if (!LoginPage || !Page401 || !Page404 || !Page500) { + console.error('Missing required page components') + return null + } + + const baseRoutes = createBaseRoutes(LoginPage, Page401, Page404, Page500) + + const router = new Router({ + routes: [...baseRoutes, ...customRoutes], + mode: 'hash' + }) + + if (ViewUI) { + setupRouterGuards(router, ViewUI, 'home') + } + + return router +} + +export default { + createBaseRoutes, + setupRouterGuards, + createRouter, + getRoutes } diff --git a/src/store/app.js b/src/store/app.js index 01524c5..4b365cc 100644 --- a/src/store/app.js +++ b/src/store/app.js @@ -1,5 +1,5 @@ import { getBreadCrumbList, getHomeRoute } from '../utils/tools' -import paramSetupServer from '../api/system_high/paramSetupServer' +import paramSetupServer from '../api/system/paramSetupServer' export default { namespaced: true, diff --git a/src/store/index.js b/src/store/index.js index e6756aa..ed1a0e1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,10 +1,27 @@ import userModule from './user' import appModule from './app' -export { userModule, appModule } +// 创建 Store 实例的方法 +export function createStore(Vuex, customModules = {}, createPersistedState) { + const store = new Vuex.Store({ + modules: { + user: appModule, + app: userModule, + ...customModules + }, + plugins: createPersistedState ? [ + createPersistedState({ + storage: window.localStorage + }) + ] : [] + }) + + return store +} export default { user: userModule, - app: appModule + app: appModule, + createStore } diff --git a/src/views/index.js b/src/views/index.js new file mode 100644 index 0000000..5ac5ac4 --- /dev/null +++ b/src/views/index.js @@ -0,0 +1,61 @@ +import HomePage from './home/index.vue' + +import SysLog from './system/sys_log.vue' +import SysParamSetup from './system/sys_param_setup.vue' +import SysRole from './system/sys_role.vue' +import SysUser from './system/sys_user.vue' + +import SysControl from './system/sys_control.vue' +import SysMenu from './system/sys_menu.vue' +import SysTitle from './system/sys_title.vue' + +import LoginPage from './login/login.vue' + +import Page401 from './error-page/401.vue' +import Page404 from './error-page/404.vue' +import Page500 from './error-page/500.vue' + + + + + + +// 设置组件映射的方法 +export function setupComponentMap(customMap = {}, uiTool) { + const componentMap = { + 'home/index': HomePage, + 'system/sys_log': SysLog, + 'system/sys_param_setup': SysParamSetup, + 'system/sys_role': SysRole, + 'system/sys_user': SysUser, + 'system/sys_control': SysControl, + 'system/sys_menu': SysMenu, + 'system/sys_title': SysTitle, + ...customMap + } + + const map = {} + Object.keys(componentMap).forEach(path => { + const cleanPath = path.replace(/\.vue$/, '') + map[cleanPath] = componentMap[path] + map[cleanPath + '.vue'] = componentMap[path] + }) + + uiTool.setComponentMap(map) +} + +export default { + HomePage, + SysLog, + SysParamSetup, + SysRole, + SysUser, + SysControl, + SysMenu, + SysTitle, + LoginPage, + Page401, + Page404, + Page500, + setupComponentMap +} \ No newline at end of file diff --git a/src/views/system_high/sys_control.vue b/src/views/system/sys_control.vue similarity index 97% rename from src/views/system_high/sys_control.vue rename to src/views/system/sys_control.vue index c0edf77..d44059f 100644 --- a/src/views/system_high/sys_control.vue +++ b/src/views/system/sys_control.vue @@ -21,8 +21,8 @@ - - \ No newline at end of file diff --git a/src/views/system_high/com/frontEndControlType.vue b/src/views/system_high/com/frontEndControlType.vue deleted file mode 100644 index ea953e2..0000000 --- a/src/views/system_high/com/frontEndControlType.vue +++ /dev/null @@ -1,251 +0,0 @@ - - - - - \ No newline at end of file diff --git a/使用说明.md b/使用说明.md index 3811659..090ea16 100644 --- a/使用说明.md +++ b/使用说明.md @@ -5,11 +5,13 @@ ## 📦 框架特性 ### ✨ 核心功能 +- ✅ **简化的 API** - 只需调用 `createApp()` 即可完成所有初始化 +- ✅ **模块化设计** - 组件、路由、状态管理等功能按模块组织 - ✅ **完整的系统管理页面** - 用户、角色、菜单、日志等管理 - ✅ **登录和权限管理** - 完整的登录流程和权限控制 - ✅ **动态路由管理** - 基于权限菜单的动态路由生成 - ✅ **Vuex 状态管理** - 用户、应用状态管理 -- ✅ **全局组件库** - Tables、Editor、Upload、TreeGrid 等 +- ✅ **全局组件库** - Tables、Editor、Upload、TreeGrid、FieldRenderer 等 - ✅ **工具库** - HTTP、日期、Token、Cookie 等工具 - ✅ **内置样式** - base.less、animate.css、iconfont 等 - ✅ **响应式布局** - 支持移动端适配 @@ -62,6 +64,34 @@ npm run build # 3. 产物在 dist/admin-framework.js ``` +## 🎯 极简使用方式 + +### 只需 3 步即可完成集成! + +#### 1. 引入框架 +```javascript +import AdminFramework from './admin-framework.js' +``` + +#### 2. 创建应用 +```javascript +const app = AdminFramework.createApp({ + title: '我的管理系统', + apiUrl: 'http://localhost:9098/admin_api/', + componentMap: { + 'business/product': ProductComponent, + 'business/order': OrderComponent + } +}) +``` + +#### 3. 挂载应用 +```javascript +app.$mount('#app') +``` + +**就这么简单!** 框架会自动完成所有初始化工作。 + ## 📖 完整使用指南 ### 1. 项目结构准备 @@ -112,7 +142,35 @@ module.exports = { } ``` -### 4. 创建 main.js +### 4. 创建 main.js(新版本 - 推荐) + +```javascript +import AdminFramework from './libs/admin-framework.js' + +// 导入业务组件(根据权限菜单接口的 component 字段) +import GamesComponent from './views/ball/games.vue' +import PayOrdersComponent from './views/order/pay_orders.vue' + +// 🎉 只需一行代码!框架自动完成所有初始化 +const app = AdminFramework.createApp({ + title: '我的管理系统', + apiUrl: 'http://localhost:9098/admin_api/', + componentMap: { + 'ball/games': GamesComponent, + 'order/pay_orders': PayOrdersComponent + // 添加更多业务组件... + }, + onReady() { + console.log('应用已启动!') + // 应用启动完成后的回调 + } +}) + +// 挂载应用 +app.$mount('#app') +``` + +### 4.1 传统方式(兼容旧版本) ```javascript import Vue from 'vue' @@ -381,9 +439,9 @@ Vue.use(AdminFramework, { - ✅ `system/sys_role` - 角色管理 - ✅ `system/sys_log` - 日志管理 - ✅ `system/sys_param_setup` - 参数设置 -- ✅ `system_high/sys_menu` - 菜单管理 -- ✅ `system_high/sys_control` - 控制器管理 -- ✅ `system_high/sys_title` - 系统标题设置 +- ✅ `system/sys_menu` - 菜单管理 +- ✅ `system/sys_control` - 控制器管理 +- ✅ `system/sys_title` - 系统标题设置 ## 🌐 全局访问 diff --git a/快速开始.md b/快速开始.md index f9b4a5a..54575c3 100644 --- a/快速开始.md +++ b/快速开始.md @@ -128,9 +128,9 @@ app.$mount('#app') - ✅ 角色管理 (`/system/role`) - ✅ 日志管理 (`/system/log`) - ✅ 参数设置 (`/system/param`) -- ✅ 菜单管理 (`/system_high/menu`) -- ✅ 权限控制 (`/system_high/control`) -- ✅ 标题设置 (`/system_high/title`) +- ✅ 菜单管理 (`/system/menu`) +- ✅ 权限控制 (`/system/control`) +- ✅ 标题设置 (`/system/title`) ### 3. 全局组件 - ✅ `` - 增强型表格