commit b6b426097bfdee4e1bcf8d01bb7ff8e7b34170f4 Author: 李龙龙 Date: Fri Jun 14 14:57:55 2024 +0800 初始化magic-boot项目 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..79f01ad --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..1ef366d --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,19 @@ + + + + + mysql.8 + true + true + $PROJECT_DIR$/magic-boot/src/main/resources/application.yml + com.mysql.cj.jdbc.Driver + jdbc:mysql://manage.zh-cc.top:14725/magic-boot?useSSL=false&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF8&autoReconnect=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..02c504c --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/magic.iml b/.idea/magic.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/magic.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9a143d3 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..43d2491 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..56782ca --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/magic-boot-naive/.env.development b/magic-boot-naive/.env.development new file mode 100644 index 0000000..72c53de --- /dev/null +++ b/magic-boot-naive/.env.development @@ -0,0 +1 @@ +VITE_APP_BASE_API = 'http://127.0.0.1:8089/' diff --git a/magic-boot-naive/.env.production b/magic-boot-naive/.env.production new file mode 100644 index 0000000..5b02fd6 --- /dev/null +++ b/magic-boot-naive/.env.production @@ -0,0 +1,2 @@ +#VITE_APP_BASE_API = 'http://localhost:8089/' +VITE_APP_BASE_API = 'http://192.168.1.9:8089/' diff --git a/magic-boot-naive/.gitignore b/magic-boot-naive/.gitignore new file mode 100644 index 0000000..9abdef9 --- /dev/null +++ b/magic-boot-naive/.gitignore @@ -0,0 +1,53 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +.DS_Store +node_modules/ +dist/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +package-lock.json +tests/**/coverage/ + +# Editor directories and files +*.suo +*.ntvs* +*.njsproj +*.sln + + +*.log + +logs/ \ No newline at end of file diff --git a/magic-boot-naive/LICENSE b/magic-boot-naive/LICENSE new file mode 100644 index 0000000..317769b --- /dev/null +++ b/magic-boot-naive/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 吕金泽 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/magic-boot-naive/README.md b/magic-boot-naive/README.md new file mode 100644 index 0000000..4a0f2f1 --- /dev/null +++ b/magic-boot-naive/README.md @@ -0,0 +1,52 @@ +## + +后端: + + + + +前端: + + + + + +## 简介 + +基于[ **magic-api** ](https://gitee.com/ssssssss-team/magic-api)搭建的快速开发平台,前端采用Vue3 + naive-ui最新版本搭建,依赖较少,运行速度快。对常用组件进行封装。利用Vue3的`@vue/compiler-sfc`单文件编译,动态编译组件,可以实现在浏览器编写Vue代码,既改即生效快速开发。 +QQ群([ **576433387** ](https://jq.qq.com/?_wv=1027&k=KD6DPvB0)) + + +| 代码 | 效果 | +|----|----| +| ![](https://magicboot.oss-cn-beijing.aliyuncs.com/code.png) | ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/1.png) | + + +## 功能 +- 菜单管理:树结构,配置菜单、权限按钮、选择关联组件等,支持全局模糊搜索 +- 组织机构:树结构,配置组织机构,类型:部门、公司(选择项存在数据字典),支持全局模糊搜索 +- 角色管理:角色菜单权限分配、设置数据范围等。 +- 用户管理:用户添加、导入用户(支持导入前预览数据)、登录状态更改等 +- 数据字典:分为`系统类`和`业务类`两类数据维护 +- 动态组件:在线编写Vue3业务页面代码,保存编译生效 +- 操作日志:接口调用操作日志查询 +- 登录日志:系统登录日志查询,包含登录失败日志 +- 数据库监控:Druid Monitor SQL监控、数据源信息查看等 +- 在线用户:当前活跃在系统内的用户,可以选择踢人下线 + +## 在线体验 +- 演示地址: +前台:[ **https://preview.magicboot.net/** ](https://preview.magicboot.net/) +后台:[ **https://api.magicboot.net:8443/magic/web/index.html** ](https://api.magicboot.net:8443/magic/web/index.html) +- 文档地址:[ **https://magicboot.net/** ](https://magicboot.net/) +- 账号:system/123456 + +## 系统截图 +| ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/1.png) | ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/2.png) | +|---|---| +| ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/3.png) | ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/4.png) | +| ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/5.png) | ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/6.png) | +| ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/7.png) | ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/8.png) | +| ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/9.png) | ![](https://magicboot.oss-cn-beijing.aliyuncs.com/system/10.png) | + + diff --git a/magic-boot-naive/del_node_modules.cmd b/magic-boot-naive/del_node_modules.cmd new file mode 100644 index 0000000..c007e6d --- /dev/null +++ b/magic-boot-naive/del_node_modules.cmd @@ -0,0 +1,2 @@ +del /f/s/q node_modules > nul; +rmdir /s/q node_modules; \ No newline at end of file diff --git a/magic-boot-naive/index.html b/magic-boot-naive/index.html new file mode 100644 index 0000000..0862f18 --- /dev/null +++ b/magic-boot-naive/index.html @@ -0,0 +1,21 @@ + + + + + + + + + + +
+ + + diff --git a/magic-boot-naive/package.json b/magic-boot-naive/package.json new file mode 100644 index 0000000..c17e94f --- /dev/null +++ b/magic-boot-naive/package.json @@ -0,0 +1,47 @@ +{ + "name": "magic-boot-vite", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "demo": "vite build --mode demo" + }, + "dependencies": { + "@layui/layer-vue": "^2.3.2", + "@volar/monaco": "1.7.9", + "@vueuse/core": "^10.1.0", + "ali-oss": "^6.17.1", + "axios": "^0.24.0", + "js-sha256": "^0.9.0", + "less": "^4.1.3", + "lodash": "^4.17.21", + "lodash-es": "^4.17.21", + "monaco-editor-core": "^0.46.0", + "monaco-editor-textmate": "^4.0.0", + "monaco-textmate": "^3.0.1", + "monaco-volar": "^0.4.0", + "onigasm": "^2.2.5", + "path-browserify": "^1.0.1", + "pinia": "^2.0.33", + "vue": "^3.3.11", + "vue-cropper": "^1.0.2", + "vue-router": "^4.1.6", + "vuedraggable": "^4.1.0", + "xlsx": "^0.18.3" + }, + "devDependencies": { + "@vicons/antd": "^0.12.0", + "@vicons/fluent": "^0.12.0", + "@vicons/ionicons5": "^0.12.0", + "@vitejs/plugin-vue": "^4.0.0", + "autoprefixer": "^10.4.13", + "naive-ui": "^2.38.1", + "postcss": "^8.4.21", + "sortablejs": "^1.15.0", + "tailwindcss": "^3.2.7", + "vite": "^4.1.0", + "vite-plugin-svg-icons": "^1.1.0" + } +} diff --git a/magic-boot-naive/postcss.config.js b/magic-boot-naive/postcss.config.js new file mode 100644 index 0000000..fef1b22 --- /dev/null +++ b/magic-boot-naive/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/magic-boot-naive/public/favicon.ico b/magic-boot-naive/public/favicon.ico new file mode 100644 index 0000000..57167be Binary files /dev/null and b/magic-boot-naive/public/favicon.ico differ diff --git a/magic-boot-naive/src/App.vue b/magic-boot-naive/src/App.vue new file mode 100644 index 0000000..f972f00 --- /dev/null +++ b/magic-boot-naive/src/App.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/magic-boot-naive/src/api/components/mb-checkbox.js b/magic-boot-naive/src/api/components/mb-checkbox.js new file mode 100644 index 0000000..d9c1ae0 --- /dev/null +++ b/magic-boot-naive/src/api/components/mb-checkbox.js @@ -0,0 +1,23 @@ +import {useDictStore} from "@/store/modules/dictStore"; +const dictStore = useDictStore() +export function getCheckboxData(props){ + let handlerData = (dictData) => { + if(props.optionsFilter){ + dictData = dictData.filter(props.optionsFilter) + } + return dictData + } + return new Promise((resolve, reject) => { + if (props.type) { + resolve(handlerData(dictStore.getDictType(props.type))) + } else if (props.url) { + $common.get(props.url, props.params).then(res => { + resolve(handlerData($common.mapLabelValue((res.data.list || res.data), props.labelField, props.valueField))) + }) + } else if (props.options && props.options.length > 0) { + resolve(handlerData($common.mapLabelValue(props.options, props.labelField, props.valueField))) + } else{ + reject() + } + }) +} diff --git a/magic-boot-naive/src/api/components/mb-select.js b/magic-boot-naive/src/api/components/mb-select.js new file mode 100644 index 0000000..e0820ec --- /dev/null +++ b/magic-boot-naive/src/api/components/mb-select.js @@ -0,0 +1,43 @@ +import {useDictStore} from "@/store/modules/dictStore"; +const dictStore = useDictStore() +export function getSelectData(props){ + let listConcat = (dictData) => { + let selectList = [] + if(props.optionsFilter){ + dictData = dictData.filter(props.optionsFilter) + } + if (props.allOption) { + selectList = [{ + value: '', + label: '全部' + }] + selectList = selectList.concat(dictData) + } else { + selectList = dictData + } + return selectList + } + let handlerData = (data) => { + let newData = [] + data.forEach(it => { + newData.push({ + label: it[props.labelField || 'label'], + value: it[props.valueField || 'value'].toString() + }) + }) + return newData + } + return new Promise((resolve, reject) => { + if (props.type) { + resolve(listConcat(dictStore.getDictType(props.type))) + } else if (props.url) { + $common.get(props.url, props.params).then(res => { + resolve(listConcat(handlerData(res.data.list || res.data))) + }) + } else if (props.options && props.options.length > 0) { + resolve(listConcat(handlerData(props.options))) + } else{ + reject() + } + }) +} diff --git a/magic-boot-naive/src/api/components/mb-tree-select.js b/magic-boot-naive/src/api/components/mb-tree-select.js new file mode 100644 index 0000000..a99ffe8 --- /dev/null +++ b/magic-boot-naive/src/api/components/mb-tree-select.js @@ -0,0 +1,11 @@ +import treeTable from "@/scripts/treeTable"; + +export function getTreeSelectData(props){ + return new Promise(resolve => { + $common.get(props.url).then(res => { + let options = res.data.list + treeTable.deleteEmptyChildren(options) + resolve(options) + }) + }) +} diff --git a/magic-boot-naive/src/assets/css/common.css b/magic-boot-naive/src/assets/css/common.css new file mode 100644 index 0000000..71700e4 --- /dev/null +++ b/magic-boot-naive/src/assets/css/common.css @@ -0,0 +1,27 @@ +::-webkit-scrollbar { + width: 6px; + height: 6px; + overflow: auto +} + +::-webkit-scrollbar-thumb { + background-color: #e6e6e6; + min-height: 25px; + min-width: 25px; + border: 1px solid #e0e0e0; + border-radius: 99px +} + +::-webkit-scrollbar-track { + background-color: #f7f7f7; + border: 1px solid #efefef +} +body{ + --mb-main-icon-color: #909399; +} +.clear{ + clear: both; +} +a{ + text-decoration: none; +} diff --git a/magic-boot-naive/src/components/index.js b/magic-boot-naive/src/components/index.js new file mode 100644 index 0000000..33340e6 --- /dev/null +++ b/magic-boot-naive/src/components/index.js @@ -0,0 +1,10 @@ +import {defineAsyncComponent} from 'vue' + +const components = import.meta.glob('./**/*.vue') + +export function setupComponents(app) { + for (const [key, value] of Object.entries(components)) { + const name = key.substring(key.lastIndexOf('/') + 1, key.lastIndexOf('.')) + app.component(name, defineAsyncComponent(value)) + } +} diff --git a/magic-boot-naive/src/components/magic-component-properties.js b/magic-boot-naive/src/components/magic-component-properties.js new file mode 100644 index 0000000..27799b3 --- /dev/null +++ b/magic-boot-naive/src/components/magic-component-properties.js @@ -0,0 +1,39 @@ + +export default { + table: { + // 选中行颜色 + selectedRowColor: '#D9DDE2', + // 单元格内容不换行显示 + nowrap: true, + // todo 拖拽列之后回调此方法,用保存列 + // saveCols(tableId, columns) { + // + // }, + // todo 远程加载列 + // remoteLoadColumn() { + // + // }, + // todo 保存页码数 + // savePage(pageSize,tableId){ + // + // }, + // todo 获取远程页码数 + // async getPage(tableId, callback){ + // + // }, + // 下拉表格选项 + dropMenus: [], + // 表头提示 + titleTooltip:{ + iconProps: { + icon: 'QuestionCircleFilled', + color: '#4b6fa7' + } + }, + // 单元格显示的图片 + image:{ + width: 30, + height: 30 + } + } +} diff --git a/magic-boot-naive/src/components/magic/basic/mb-icon.vue b/magic-boot-naive/src/components/magic/basic/mb-icon.vue new file mode 100644 index 0000000..1fbd652 --- /dev/null +++ b/magic-boot-naive/src/components/magic/basic/mb-icon.vue @@ -0,0 +1,56 @@ + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-editor-table.vue b/magic-boot-naive/src/components/magic/data/mb-editor-table.vue new file mode 100644 index 0000000..5a1b69d --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-editor-table.vue @@ -0,0 +1,640 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-pagination.vue b/magic-boot-naive/src/components/magic/data/mb-pagination.vue new file mode 100644 index 0000000..ddb5614 --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-pagination.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-radio-dict.vue b/magic-boot-naive/src/components/magic/data/mb-radio-dict.vue new file mode 100644 index 0000000..b682bb1 --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-radio-dict.vue @@ -0,0 +1,69 @@ + + + + + + \ No newline at end of file diff --git a/magic-boot-naive/src/components/magic/data/mb-search.vue b/magic-boot-naive/src/components/magic/data/mb-search.vue new file mode 100644 index 0000000..ba47f69 --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-search.vue @@ -0,0 +1,136 @@ + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-table-column.vue b/magic-boot-naive/src/components/magic/data/mb-table-column.vue new file mode 100644 index 0000000..c2b9304 --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-table-column.vue @@ -0,0 +1,112 @@ + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-table.vue b/magic-boot-naive/src/components/magic/data/mb-table.vue new file mode 100644 index 0000000..0df1a56 --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-table.vue @@ -0,0 +1,1178 @@ + + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-tree-select.vue b/magic-boot-naive/src/components/magic/data/mb-tree-select.vue new file mode 100644 index 0000000..efd4ada --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-tree-select.vue @@ -0,0 +1,68 @@ + + + diff --git a/magic-boot-naive/src/components/magic/data/mb-tree.vue b/magic-boot-naive/src/components/magic/data/mb-tree.vue new file mode 100644 index 0000000..26f5a18 --- /dev/null +++ b/magic-boot-naive/src/components/magic/data/mb-tree.vue @@ -0,0 +1,399 @@ + + + + diff --git a/magic-boot-naive/src/components/magic/feedback/mb-modal.vue b/magic-boot-naive/src/components/magic/feedback/mb-modal.vue new file mode 100644 index 0000000..dbae772 --- /dev/null +++ b/magic-boot-naive/src/components/magic/feedback/mb-modal.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/feedback/mb-table-tooltip.vue b/magic-boot-naive/src/components/magic/feedback/mb-table-tooltip.vue new file mode 100644 index 0000000..b74ae81 --- /dev/null +++ b/magic-boot-naive/src/components/magic/feedback/mb-table-tooltip.vue @@ -0,0 +1,41 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-checkbox.vue b/magic-boot-naive/src/components/magic/form/mb-checkbox.vue new file mode 100644 index 0000000..25b4928 --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-checkbox.vue @@ -0,0 +1,112 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-date.vue b/magic-boot-naive/src/components/magic/form/mb-date.vue new file mode 100644 index 0000000..44b4dfd --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-date.vue @@ -0,0 +1,73 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-input.vue b/magic-boot-naive/src/components/magic/form/mb-input.vue new file mode 100644 index 0000000..1753c37 --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-input.vue @@ -0,0 +1,23 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-select-table.vue b/magic-boot-naive/src/components/magic/form/mb-select-table.vue new file mode 100644 index 0000000..76366a1 --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-select-table.vue @@ -0,0 +1,206 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-select.vue b/magic-boot-naive/src/components/magic/form/mb-select.vue new file mode 100644 index 0000000..30eaad5 --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-select.vue @@ -0,0 +1,143 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-switch.vue b/magic-boot-naive/src/components/magic/form/mb-switch.vue new file mode 100644 index 0000000..baca1b2 --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-switch.vue @@ -0,0 +1,81 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-textarea.vue b/magic-boot-naive/src/components/magic/form/mb-textarea.vue new file mode 100644 index 0000000..188b0ba --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-textarea.vue @@ -0,0 +1,24 @@ + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-upload-file.vue b/magic-boot-naive/src/components/magic/form/mb-upload-file.vue new file mode 100644 index 0000000..cfc868b --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-upload-file.vue @@ -0,0 +1,372 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-upload-image.vue b/magic-boot-naive/src/components/magic/form/mb-upload-image.vue new file mode 100644 index 0000000..e990384 --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-upload-image.vue @@ -0,0 +1,423 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-upload-oss-file.vue b/magic-boot-naive/src/components/magic/form/mb-upload-oss-file.vue new file mode 100644 index 0000000..d3a834a --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-upload-oss-file.vue @@ -0,0 +1,303 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/form/mb-video.vue b/magic-boot-naive/src/components/magic/form/mb-video.vue new file mode 100644 index 0000000..114e41d --- /dev/null +++ b/magic-boot-naive/src/components/magic/form/mb-video.vue @@ -0,0 +1,18 @@ + + + + + diff --git a/magic-boot-naive/src/components/magic/scripts/watch-join-update.js b/magic-boot-naive/src/components/magic/scripts/watch-join-update.js new file mode 100644 index 0000000..d6ff15f --- /dev/null +++ b/magic-boot-naive/src/components/magic/scripts/watch-join-update.js @@ -0,0 +1,53 @@ +import {computed, watch} from 'vue' +import {isArray, isNumber, isString} from "lodash-es"; + +export function watchValue(componentValue, props, emit){ + let watchList = [] + let multiple = props.multiple + let join = props.join + if(!multiple){ + join = false + } + const getComponentValue = computed(() => { + if (join) { + return componentValue.value && componentValue.value.join(',') + } else { + return componentValue.value + } + }) + let componentValueWatch = false + let setValue = (value) => { + if(isArray(value)){ + value = value.map(v => v.toString()) + componentValue.value = value + }else if(isNumber(value)){ + join = multiple + componentValue.value = props.multiple ? value.toString().split(',') : value.toString() + }else if(isString(value)){ + join = multiple + componentValue.value = props.multiple ? value.split(',') : value + }else{ + componentValue.value = value + } + if (!componentValueWatch) { + watchList.push(watch(componentValue, (value) => { + if (join) { + emit('update:modelValue', value && value.join(',')) + emit('change', value && value.join(',')) + } else { + emit('update:modelValue', value) + emit('change', value) + } + })) + } + componentValueWatch = true + } + setValue(props.modelValue) + watchList.push(watch(() => props.modelValue, (value) => { + // 如果传过来的值和选择的值不一样则更新 + if(!$common.arrayStringEq(value, getComponentValue.value)){ + setValue(value) + } + })) + return watchList +} diff --git a/magic-boot-naive/src/components/magic/sfc/mb-monaco-volar.vue b/magic-boot-naive/src/components/magic/sfc/mb-monaco-volar.vue new file mode 100644 index 0000000..b2e895a --- /dev/null +++ b/magic-boot-naive/src/components/magic/sfc/mb-monaco-volar.vue @@ -0,0 +1,149 @@ + + + diff --git a/magic-boot-naive/src/components/magic/sfc/mb-vue-init-template.vue b/magic-boot-naive/src/components/magic/sfc/mb-vue-init-template.vue new file mode 100644 index 0000000..aa559b2 --- /dev/null +++ b/magic-boot-naive/src/components/magic/sfc/mb-vue-init-template.vue @@ -0,0 +1,9 @@ + + + diff --git a/magic-boot-naive/src/components/magic/template/mb-form.vue b/magic-boot-naive/src/components/magic/template/mb-form.vue new file mode 100644 index 0000000..0f46b11 --- /dev/null +++ b/magic-boot-naive/src/components/magic/template/mb-form.vue @@ -0,0 +1,145 @@ + + + diff --git a/magic-boot-naive/src/components/magic/template/mb-list.vue b/magic-boot-naive/src/components/magic/template/mb-list.vue new file mode 100644 index 0000000..6a96b1f --- /dev/null +++ b/magic-boot-naive/src/components/magic/template/mb-list.vue @@ -0,0 +1,63 @@ + + + diff --git a/magic-boot-naive/src/icons/component.svg b/magic-boot-naive/src/icons/component.svg new file mode 100644 index 0000000..1302679 --- /dev/null +++ b/magic-boot-naive/src/icons/component.svg @@ -0,0 +1 @@ + diff --git a/magic-boot-naive/src/icons/configure.svg b/magic-boot-naive/src/icons/configure.svg new file mode 100644 index 0000000..b9b66a6 --- /dev/null +++ b/magic-boot-naive/src/icons/configure.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/database.svg b/magic-boot-naive/src/icons/database.svg new file mode 100644 index 0000000..a8b8942 --- /dev/null +++ b/magic-boot-naive/src/icons/database.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/dict.svg b/magic-boot-naive/src/icons/dict.svg new file mode 100644 index 0000000..a5bd659 --- /dev/null +++ b/magic-boot-naive/src/icons/dict.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/error.svg b/magic-boot-naive/src/icons/error.svg new file mode 100644 index 0000000..e509005 --- /dev/null +++ b/magic-boot-naive/src/icons/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/examples.svg b/magic-boot-naive/src/icons/examples.svg new file mode 100644 index 0000000..c30cc01 --- /dev/null +++ b/magic-boot-naive/src/icons/examples.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/eye-open.svg b/magic-boot-naive/src/icons/eye-open.svg new file mode 100644 index 0000000..88dcc98 --- /dev/null +++ b/magic-boot-naive/src/icons/eye-open.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/eye.svg b/magic-boot-naive/src/icons/eye.svg new file mode 100644 index 0000000..16ed2d8 --- /dev/null +++ b/magic-boot-naive/src/icons/eye.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/fullscreen.svg b/magic-boot-naive/src/icons/fullscreen.svg new file mode 100644 index 0000000..0e86b6f --- /dev/null +++ b/magic-boot-naive/src/icons/fullscreen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/home.svg b/magic-boot-naive/src/icons/home.svg new file mode 100644 index 0000000..57cbfc4 --- /dev/null +++ b/magic-boot-naive/src/icons/home.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/interface.svg b/magic-boot-naive/src/icons/interface.svg new file mode 100644 index 0000000..39fc373 --- /dev/null +++ b/magic-boot-naive/src/icons/interface.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/log.svg b/magic-boot-naive/src/icons/log.svg new file mode 100644 index 0000000..dc6af71 --- /dev/null +++ b/magic-boot-naive/src/icons/log.svg @@ -0,0 +1 @@ + diff --git a/magic-boot-naive/src/icons/login-log.svg b/magic-boot-naive/src/icons/login-log.svg new file mode 100644 index 0000000..ec896a9 --- /dev/null +++ b/magic-boot-naive/src/icons/login-log.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/menu.svg b/magic-boot-naive/src/icons/menu.svg new file mode 100644 index 0000000..b687061 --- /dev/null +++ b/magic-boot-naive/src/icons/menu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/monitor.svg b/magic-boot-naive/src/icons/monitor.svg new file mode 100644 index 0000000..b3cce39 --- /dev/null +++ b/magic-boot-naive/src/icons/monitor.svg @@ -0,0 +1 @@ + diff --git a/magic-boot-naive/src/icons/office.svg b/magic-boot-naive/src/icons/office.svg new file mode 100644 index 0000000..21b749f --- /dev/null +++ b/magic-boot-naive/src/icons/office.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/oper-log.svg b/magic-boot-naive/src/icons/oper-log.svg new file mode 100644 index 0000000..5a2db7c --- /dev/null +++ b/magic-boot-naive/src/icons/oper-log.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/password.svg b/magic-boot-naive/src/icons/password.svg new file mode 100644 index 0000000..e291d85 --- /dev/null +++ b/magic-boot-naive/src/icons/password.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/role.svg b/magic-boot-naive/src/icons/role.svg new file mode 100644 index 0000000..34cffeb --- /dev/null +++ b/magic-boot-naive/src/icons/role.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/same-level.svg b/magic-boot-naive/src/icons/same-level.svg new file mode 100644 index 0000000..4f99c60 --- /dev/null +++ b/magic-boot-naive/src/icons/same-level.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/search.svg b/magic-boot-naive/src/icons/search.svg new file mode 100644 index 0000000..84233dd --- /dev/null +++ b/magic-boot-naive/src/icons/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/settings.svg b/magic-boot-naive/src/icons/settings.svg new file mode 100644 index 0000000..a8d3657 --- /dev/null +++ b/magic-boot-naive/src/icons/settings.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/sub-level.svg b/magic-boot-naive/src/icons/sub-level.svg new file mode 100644 index 0000000..91a86db --- /dev/null +++ b/magic-boot-naive/src/icons/sub-level.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/icons/user.svg b/magic-boot-naive/src/icons/user.svg new file mode 100644 index 0000000..198f9c8 --- /dev/null +++ b/magic-boot-naive/src/icons/user.svg @@ -0,0 +1 @@ + diff --git a/magic-boot-naive/src/icons/verification-code.svg b/magic-boot-naive/src/icons/verification-code.svg new file mode 100644 index 0000000..a105f8e --- /dev/null +++ b/magic-boot-naive/src/icons/verification-code.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/magic-boot-naive/src/layout/empty.vue b/magic-boot-naive/src/layout/empty.vue new file mode 100644 index 0000000..1887aca --- /dev/null +++ b/magic-boot-naive/src/layout/empty.vue @@ -0,0 +1,3 @@ + diff --git a/magic-boot-naive/src/layout/index.vue b/magic-boot-naive/src/layout/index.vue new file mode 100644 index 0000000..2c0e02d --- /dev/null +++ b/magic-boot-naive/src/layout/index.vue @@ -0,0 +1,176 @@ + + + + + diff --git a/magic-boot-naive/src/layout/layout-header.vue b/magic-boot-naive/src/layout/layout-header.vue new file mode 100644 index 0000000..a981995 --- /dev/null +++ b/magic-boot-naive/src/layout/layout-header.vue @@ -0,0 +1,126 @@ + + + + + diff --git a/magic-boot-naive/src/layout/nested-router.vue b/magic-boot-naive/src/layout/nested-router.vue new file mode 100644 index 0000000..27c130c --- /dev/null +++ b/magic-boot-naive/src/layout/nested-router.vue @@ -0,0 +1,25 @@ + + + diff --git a/magic-boot-naive/src/layout/tabs.vue b/magic-boot-naive/src/layout/tabs.vue new file mode 100644 index 0000000..2a7e973 --- /dev/null +++ b/magic-boot-naive/src/layout/tabs.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/magic-boot-naive/src/main.js b/magic-boot-naive/src/main.js new file mode 100644 index 0000000..f80ffbd --- /dev/null +++ b/magic-boot-naive/src/main.js @@ -0,0 +1,37 @@ +import './styles/tailwind.css' +import '@/assets/css/common.css' +import 'vite-plugin-svg-icons/register' +import {createApp} from 'vue' +import App from './App.vue' +import { + setupNaive, + setupNaiveDiscreteApi, + setupDirectives, + setupGlobalProperties, + setupMonacoVolar, + setupTheme, + setupLayer +} from '@/scripts/plugins' +import {setupRouter} from '@/scripts/router' +import {setupStore} from '@/store' +import {setupComponents} from '@/components' +import '@/scripts/compiler/magic-import' + +const app = createApp(App) + +async function start() { + setupStore(app) + setupNaive(app) + setupNaiveDiscreteApi() + setupDirectives(app) + setupGlobalProperties(app) + await setupRouter(app) + await setupMonacoVolar() + setupComponents(app) + await setupTheme() + setupLayer(app) + app.mount('#app') +} + +void start() + diff --git a/magic-boot-naive/src/scripts/common.js b/magic-boot-naive/src/scripts/common.js new file mode 100644 index 0000000..36a1ea0 --- /dev/null +++ b/magic-boot-naive/src/scripts/common.js @@ -0,0 +1,376 @@ +import request from '@/scripts/request' +import global from '@/scripts/global' +import {utils, writeFile} from 'xlsx' +import {useUserStore} from "@/store/modules/userStore"; +import {isArray, cloneDeep} from "lodash-es"; +import {h} from 'vue' +import MbIcon from "@/components/magic/basic/mb-icon.vue"; + +const common = {} + +common.handleDelete = (options) => { + const url = options.url + const id = options.id + $dialog.warning({ + title: '提示', + content: '此操作将永久删除该数据, 是否继续?', + positiveText: '确定', + negativeText: '取消', + onPositiveClick: () => { + request({ + url: url, + method: 'delete', + params: { + id: id + } + }).then(() => { + $message.success('删除成功') + options && options.done() + }) + } + }) +} + +const formatJson = (list, filterVal) => { + return list.map(v => filterVal.map(j => { + return v[j] + })) +} + +common.request = (method) => { + return common[common.requestMethod.indexOf(method) !== -1 ? method : 'get'] +} +common.requestMethod = ['get','post','postJson','delete'] +common.get = (url, data) => request({url, params: data}) +common.delete = (url, data) => request({url, method: 'delete', params: data}) +common.post = (url, data) => request.post(url, data, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + transformRequest: [data => data && Object.keys(data).map(it => encodeURIComponent(it) + '=' + encodeURIComponent(data[it] === null || data[it] === undefined ? '' : data[it])).join('&')] +}) +common.postJson = (url, data) => request.post(url, JSON.stringify(data), { + headers: { + 'Content-Type': 'application/json' + } +}) + +common.renderWhere = (where) => { + let newWhere = {} + for (let key in where) { + if (where[key] instanceof Object) { + newWhere[key] = where[key].value + } else { + newWhere[key] = where[key] + } + } + return newWhere +} + +// common.exportExcel = (options) => { +// let where = options.where || {} +// where = common.renderWhere(where) +// where.current = 1 +// where.size = 99999999 +// const url = options.url +// const headers = options.headers +// const columns = options.columns +// request({ +// url: url, +// method: 'post', +// params: where +// }).then(res => { +// import('@/vendor/Export2Excel').then(excel => { +// const data = formatJson(res.data, columns) +// excel.export_json_to_excel({ +// header: headers, +// data, +// filename: 'table-list' +// }) +// }) +// }) +// } + +common.handlerTreeData = (data, id, pid, sort, pidVal) => { + let treeData = [] + let addChildren = (it) => { + let children = data.filter(d => d[pid] === it[id]) + if (children && children.length > 0) { + children.sort((a, b) => { + return a[sort] - b[sort] + }) + it.children = children + children.forEach(chi => { + addChildren(chi) + }) + } + } + data.sort((a, b) => { + return a[sort] - b[sort] + }) + data.filter(it => it[pid] === pidVal).forEach(it => { + addChildren(it) + treeData.push(it) + }) + return treeData +} + +common.uuid = () => { + function S4() { + return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); + } + + return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4()); +} + +common.objAssign = (obj1, obj2, exclude) => { + exclude = exclude || '' + for (let o1 in obj1) { + for (let o2 in obj2) { + if (o1 === o2) { + if (exclude.indexOf(o1) == -1) { + obj1[o1] = obj2[o2] + } + } + } + } +} + +common.copyNew = (obj) => { + return JSON.parse(JSON.stringify(obj)) +} + +common.getParam = (data) => { + let url = '' + for (let k in data) { + const value = data[k] !== undefined ? data[k] : '' + url += `&${k}=${encodeURIComponent(value)}` + } + return url ? url.substring(1) : '' +} + +common.getUrl = (url, data) => { + url += (url.indexOf('?') < 0 ? '?' : '') + common.getParam(data) + return url +} + +function getToken(){ + const userStore = useUserStore() + const token = userStore.getToken() +} + +common.downloadMore = (urls, filename) => { + let params = { + // post只需编码一次,get需要编码两次(encodeURIComponent(encodeURIComponent(urls))) + urls: encodeURIComponent(urls), + filename: filename || '', + token: getToken() + } + let form = document.createElement("form"); + form.style.display = 'none'; + form.action = global.baseApi + '/system/file/download'; + form.method = 'post'; + document.body.appendChild(form); + for(let key in params){ + let input = document.createElement("input"); + input.type = 'hidden'; + input.name = key; + input.value = params[key]; + form.appendChild(input); + } + form.submit(); + form.remove(); +} + +common.download = (urls, filename) => { + location.href = common.downloadHref(urls, filename) +} + +common.downloadHref = (urls, filename) => { + return global.baseApi + `/system/file/download?urls=${encodeURIComponent(encodeURIComponent(urls))}&filename=${filename || ''}&token=${getToken()}` +} + +common.loadConfig = async () => { + await request({ + url: '/system/config/list' + }).then(res => { + const {data} = res + global.config = data + global.filePrefix = global.config.bucketDomain ? global.config.bucketDomain : global.baseApi + }) +} + +common.setDefaultValue = (obj, attr, value) => { + obj[attr] = obj[attr] === undefined ? value : obj[attr] +} + +common.isComma = (value) => { + return value.toString().indexOf(',') !== -1 +} + +common.exportExcel = (options) => { + options.suffix = options.suffix || 'xlsx' + const workBook = utils.json_to_sheet(options.data); + const wb = utils.book_new() + utils.book_append_sheet(wb, workBook, 'sheet1'); + writeFile(wb, `${options.fileName}.${options.suffix || 'xlsx'}`); +} + +common.objectAssign = (target, source) => { + return Object.assign({}, JSON.parse(JSON.stringify(target)), JSON.parse(JSON.stringify(source))) +} + +common.getUrlType = (url) => { + if(!url){ + return -1 + } + if(url.startsWith('http')){ + return 0 + }else if(url.indexOf('.htm') != -1){ + return 1 + } + return 2 +} + +common.getLocationHref = () => { + return location.href.substring(0, location.href.indexOf('/', location.href.indexOf('/', location.href.indexOf('/') + 1) + 1)) +} + +common.handlerUrlPage = (url) => { + let urlType = common.getUrlType(url) + if(urlType == 1){ + return common.getLocationHref() + url + }else if(urlType == 2){ + return common.getLocationHref() + '/#' + url + } + return url +} + +common.filterIframeTabs = (it) => { + return it.meta.keepAlive && it.meta.path && ( + (it.meta.path.startsWith('http') && (it.meta.openMode == '0' || it.meta.openMode == '2')) + || + (it.meta.path.indexOf('.htm') != -1 && (it.meta.openMode == '0' || it.meta.openMode == '2')) + || + it.meta.openMode == '2' + ) +} + +/** + * 字符串数组和字符串(带逗号)对比 + */ +common.arrayStringEq = (v1, v2) => { + let value1 = cloneDeep(v1) + let value2 = cloneDeep(v2) + value1 = isArray(value1) ? value1.join(',') : value1 && value1.toString() + value2 = isArray(value2) ? value2.join(',') : value2 && value2.toString() + return value1 == value2 +} + +/** + * 判断数据不为null、undefined、空字符串。不包含0和1 + */ +common.notEmptyNot01 = (value) => { + if(value !== null && value !== undefined && value !== ''){ + return true + } + return false +} + +/** + * 获取有效数据 并且 可以设置默认值 + */ +common.getValidValue = (value, defaultValue) => { + if(common.notEmptyNot01(value)){ + return value + }else{ + return common.notEmptyNot01(defaultValue) ? defaultValue : '' + } +} + +common.stopWatchList = (watchList) => { + for(let watchFunction of watchList){ + watchFunction() + } +} + +common.copyText = (selection) => { + let textarea = document.createElement('textarea') + textarea.value = selection + document.body.appendChild(textarea); + textarea.select() + try { + document.execCommand("copy"); + $message.success('复制成功') + } catch (err) { + $message.error('复制失败') + } + document.body.removeChild(textarea); +} + +common.dialog = (type, options) => { + $dialog[type]({ + title: options.title || '提示', + content: options.content, + positiveText: options.positiveText || '确定', + negativeText: options.negativeText || '取消', + onPositiveClick: (e) => { + if(options.ok){ + return options.ok(e) + } + }, + onNegativeClick: (e) => { + if(options.cancel){ + return options.cancel(e) + } + }, + ...options + }) +} + +common.warning = (content, ok, options) => { + common.dialog('warning', { + content, + ok, + ...options + }) +} + +common.info = (content, ok, options) => { + common.dialog('info', { + content, + ok, + ...options + }) +} + +common.success = (content, ok, options) => { + common.dialog('success', { + content, + ok, + ...options + }) +} + +common.error = (content, ok, options) => { + common.dialog('error', { + content, + ok, + ...options + }) +} + +common.renderIcon = (icon) => { + return () => h(MbIcon, { icon }) +} + +common.mapLabelValue = (data, labelField, valueField) => { + return data.map(it => { + return { + label: it[labelField || 'label'], + value: it[valueField || 'value'].toString() + } + }) +} + +export default common diff --git a/magic-boot-naive/src/scripts/compiler/dynamicComponent.js b/magic-boot-naive/src/scripts/compiler/dynamicComponent.js new file mode 100644 index 0000000..e8c7a80 --- /dev/null +++ b/magic-boot-naive/src/scripts/compiler/dynamicComponent.js @@ -0,0 +1,18 @@ + +function appComponent(app, item){ + item.compileJs = `(function(){ + ${item.compileJs} + })()` + let componentStyle = document.createElement("style"); + componentStyle.innerHTML = item.compileCss + document.head.appendChild(componentStyle); + app.component(item.name, eval(item.compileJs)) +} + +export async function loadDynamicComponent(app) { + await $common.post('/system/component/list').then((res) => { + res.data.forEach(it => { + appComponent(app, it) + }) + }) +} diff --git a/magic-boot-naive/src/scripts/compiler/magic-import.js b/magic-boot-naive/src/scripts/compiler/magic-import.js new file mode 100644 index 0000000..a941a48 --- /dev/null +++ b/magic-boot-naive/src/scripts/compiler/magic-import.js @@ -0,0 +1,30 @@ +import * as vue from "vue"; +import * as NaiveUI from 'naive-ui'; +import * as router from '@/scripts/router' +import xicons from '@/scripts/xicons' +import svgIcons from '@/scripts/svg-icons' +import * as dictStore from "@/store/modules/dictStore"; +import * as userStore from "@/store/modules/userStore"; +import MbIcon from '@/components/magic/basic/mb-icon.vue'; +import * as lodashEs from 'lodash-es' +import * as vueRouter from 'vue-router' + +const libs = { + vue, + 'naive-ui': NaiveUI, + '@/scripts/xicons': xicons, + '@/scripts/svg-icons': svgIcons, + '@/scripts/router': router, + '@/store/modules/dictStore': dictStore, + '@/store/modules/userStore': userStore, + '@/components/magic/basic/mb-icon.vue': MbIcon, + 'lodash-es': lodashEs, + 'vue-router': vueRouter +} + +window.___magic__import__ = function(lib, name){ + if(Object.prototype.toString.call(libs[lib]) != '[object Module]' && name == '*'){ + return libs[lib] + } + return (libs[lib] || {})[name] +} diff --git a/magic-boot-naive/src/scripts/compiler/sfc-compiler.js b/magic-boot-naive/src/scripts/compiler/sfc-compiler.js new file mode 100644 index 0000000..c25e736 --- /dev/null +++ b/magic-boot-naive/src/scripts/compiler/sfc-compiler.js @@ -0,0 +1,223 @@ +import * as SFCCompiler from '@vue/compiler-sfc' +import {babelParse} from "@vue/compiler-sfc"; + +const COMP_IDENTIFIER = `__sfc__` + +export function compileCode(sourceCode){ + let compiled = {} + compileFile(sourceCode, compiled) + if(compiled.errors.length){ + throw compiled.errors[0] + }else{ + let jsCode = compiled.js + let ast = babelParse(jsCode, { + sourceType: 'module' + }) + let replaceCode = (node, subCode) => jsCode.substring(0, node.start) + subCode + jsCode.substring(node.end); + for(let i = ast.program.body.length - 1; i>=0; i--){ + let node = ast.program.body[i] + if(node.type === 'ImportDeclaration'){ + jsCode = replaceCode(node, node.specifiers.map(it => `const ${it.local?.name || it.imported?.name || '*'} = ___magic__import__('${node.source.value}', '${it.imported?.name || '*'}');`).join('\r\n')); + } else if (node.type === 'ExportDefaultDeclaration'){ + jsCode = replaceCode(node, `return ${node.declaration.name}`) + } + } + return { + compileCss: compiled.css, + compileJs: jsCode + } + } +} + +export function compileFile(code, compiled) { + + const filename = 'mb-sfc-compiler.vue' + + const id = hashId(filename) + const { errors, descriptor } = SFCCompiler.parse(code, { + filename, + sourceMap: true + }) + + if (errors.length) { + compiled.errors = errors + return + } + + if(hasVueCompositionFunctions(code) && !hasScriptSetup(code)){ + compiled.errors = [ + 'defineProps、defineExpose、defineEmits、defineSlots、defineOptions、defineModel需要在 + + diff --git a/magic-boot-naive/src/views/common/show-component.vue b/magic-boot-naive/src/views/common/show-component.vue new file mode 100644 index 0000000..0988c48 --- /dev/null +++ b/magic-boot-naive/src/views/common/show-component.vue @@ -0,0 +1,14 @@ + + + diff --git a/magic-boot-naive/src/views/examples/editor-table.vue b/magic-boot-naive/src/views/examples/editor-table.vue new file mode 100644 index 0000000..5029ca1 --- /dev/null +++ b/magic-boot-naive/src/views/examples/editor-table.vue @@ -0,0 +1,234 @@ + + + diff --git a/magic-boot-naive/src/views/examples/select-example.vue b/magic-boot-naive/src/views/examples/select-example.vue new file mode 100644 index 0000000..f2536d0 --- /dev/null +++ b/magic-boot-naive/src/views/examples/select-example.vue @@ -0,0 +1,23 @@ + + + diff --git a/magic-boot-naive/src/views/examples/select-table.vue b/magic-boot-naive/src/views/examples/select-table.vue new file mode 100644 index 0000000..b97b2ca --- /dev/null +++ b/magic-boot-naive/src/views/examples/select-table.vue @@ -0,0 +1,246 @@ + + + diff --git a/magic-boot-naive/src/views/examples/shuttle-table.vue b/magic-boot-naive/src/views/examples/shuttle-table.vue new file mode 100644 index 0000000..be35c6a --- /dev/null +++ b/magic-boot-naive/src/views/examples/shuttle-table.vue @@ -0,0 +1,152 @@ + + + diff --git a/magic-boot-naive/src/views/examples/test-mb-form.vue b/magic-boot-naive/src/views/examples/test-mb-form.vue new file mode 100644 index 0000000..cf19a19 --- /dev/null +++ b/magic-boot-naive/src/views/examples/test-mb-form.vue @@ -0,0 +1,3 @@ + diff --git a/magic-boot-naive/src/views/examples/test-mb-list.vue b/magic-boot-naive/src/views/examples/test-mb-list.vue new file mode 100644 index 0000000..cf19a19 --- /dev/null +++ b/magic-boot-naive/src/views/examples/test-mb-list.vue @@ -0,0 +1,3 @@ + diff --git a/magic-boot-naive/src/views/examples/three-linkage.vue b/magic-boot-naive/src/views/examples/three-linkage.vue new file mode 100644 index 0000000..e44d3bd --- /dev/null +++ b/magic-boot-naive/src/views/examples/three-linkage.vue @@ -0,0 +1,78 @@ + + + + diff --git a/magic-boot-naive/src/views/examples/upload-file.vue b/magic-boot-naive/src/views/examples/upload-file.vue new file mode 100644 index 0000000..2a2b2c5 --- /dev/null +++ b/magic-boot-naive/src/views/examples/upload-file.vue @@ -0,0 +1,62 @@ + + + diff --git a/magic-boot-naive/src/views/home.vue b/magic-boot-naive/src/views/home.vue new file mode 100644 index 0000000..ff2af0c --- /dev/null +++ b/magic-boot-naive/src/views/home.vue @@ -0,0 +1,5 @@ + diff --git a/magic-boot-naive/src/views/login.vue b/magic-boot-naive/src/views/login.vue new file mode 100644 index 0000000..00914e1 --- /dev/null +++ b/magic-boot-naive/src/views/login.vue @@ -0,0 +1,123 @@ + + + + + diff --git a/magic-boot-naive/src/views/lowcode/code-gen-form.vue b/magic-boot-naive/src/views/lowcode/code-gen-form.vue new file mode 100644 index 0000000..c0b35ad --- /dev/null +++ b/magic-boot-naive/src/views/lowcode/code-gen-form.vue @@ -0,0 +1,437 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/magic-boot-naive/src/views/lowcode/code-gen-list.vue b/magic-boot-naive/src/views/lowcode/code-gen-list.vue new file mode 100644 index 0000000..adeeb25 --- /dev/null +++ b/magic-boot-naive/src/views/lowcode/code-gen-list.vue @@ -0,0 +1,7 @@ + + + diff --git a/magic-boot-naive/src/views/lowcode/magic-editor.vue b/magic-boot-naive/src/views/lowcode/magic-editor.vue new file mode 100644 index 0000000..c11d58e --- /dev/null +++ b/magic-boot-naive/src/views/lowcode/magic-editor.vue @@ -0,0 +1,13 @@ + + + diff --git a/magic-boot-naive/src/views/lowcode/sfc-component.vue b/magic-boot-naive/src/views/lowcode/sfc-component.vue new file mode 100644 index 0000000..90d6fa6 --- /dev/null +++ b/magic-boot-naive/src/views/lowcode/sfc-component.vue @@ -0,0 +1,417 @@ + + +