From 7670b07db67cce2cc4d5a7e74aeb8c702e9671d8 Mon Sep 17 00:00:00 2001 From: icssoa <2570063477@qq.com> Date: Tue, 9 Mar 2021 18:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=BB=93=E6=9E=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 11 + .eslintignore | 2 - cool/index.js | 43 --- cool/modules/base/components/menu/file.vue | 145 ---------- cool/modules/base/package.json | 12 - cool/modules/base/static/css/theme.scss | 126 --------- cool/modules/base/store/module.js | 33 --- cool/modules/base/utils/index.js | 31 -- cool/modules/base/views/index.js | 56 ---- cool/modules/chat/components/index.js | 4 - cool/modules/chat/package.json | 10 - cool/modules/copy/package.json | 9 - cool/modules/demo/index.js | 5 - cool/modules/demo/package.json | 9 - cool/modules/demo/utils/service.js | 106 ------- cool/modules/demo/views/index.js | 26 -- cool/modules/task/index.js | 4 - cool/modules/task/package.json | 9 - cool/modules/task/service/index.js | 7 - cool/modules/task/views/index.js | 9 - package.json | 38 +-- src/assets/css/common.scss | 10 +- src/config/env.js | 31 +- src/cool/index.js | 41 +++ .../cool}/modules/base/common/index.js | 6 +- .../modules/base/components/avatar/index.vue | 0 .../base/components/codemirror/index.vue | 2 +- .../modules/base/components/dept/check.vue | 4 +- .../modules/base/components/dept/move.vue | 4 +- .../modules/base/components/dept/tree.vue | 14 +- .../base/components/editor-quill/index.vue | 0 .../base/components/icon-svg/index.vue | 0 .../cool}/modules/base/components/index.js | 0 .../modules/base/components/menu/file.vue | 77 +++++ .../modules/base/components/menu/icons.vue | 2 +- .../modules/base/components/menu/perms.vue | 14 +- .../base/components/menu/slider/index.js | 26 +- .../base/components/menu/slider/index.scss | 24 +- .../modules/base/components/menu/topbar.vue | 2 +- .../modules/base/components/menu/tree.vue | 6 +- .../modules/base/components/perf/common.js | 0 .../cool}/modules/base/components/perf/ct.vue | 6 +- .../modules/base/components/perf/mysql.vue | 4 +- .../modules/base/components/perf/network.vue | 10 +- .../modules/base/components/perf/redis.vue | 4 +- .../modules/base/components/process/index.vue | 12 +- .../modules/base/components/role/perms.vue | 10 +- .../modules/base/components/role/select.vue | 0 .../base/components/route-nav/index.vue | 8 +- .../base/components/scrollbar/index.vue | 0 .../cool}/modules/base/directives/index.js | 0 .../modules/base/directives/permission.js | 6 +- .../cool}/modules/base/filters/index.js | 0 {cool => src/cool}/modules/base/index.js | 0 .../modules/base/pages/error-page/403.vue | 0 .../modules/base/pages/error-page/404.vue | 0 .../modules/base/pages/error-page/500.vue | 0 .../modules/base/pages/error-page/502.vue | 0 .../error-page/components/error-page.vue | 0 .../cool}/modules/base/pages/iframe/index.vue | 0 .../cool}/modules/base/pages/index.js | 12 +- .../base/pages/login/components/captcha.vue | 2 +- .../cool}/modules/base/pages/login/index.vue | 0 .../cool}/modules/base/service/common.js | 0 .../cool}/modules/base/service/index.js | 0 .../cool}/modules/base/service/open.js | 0 .../cool}/modules/base/service/plugin/info.js | 0 .../cool}/modules/base/service/system/dept.js | 0 .../cool}/modules/base/service/system/info.js | 0 .../cool}/modules/base/service/system/log.js | 0 .../cool}/modules/base/service/system/menu.js | 0 .../modules/base/service/system/param.js | 0 .../cool}/modules/base/service/system/role.js | 0 .../cool}/modules/base/service/system/user.js | 0 .../cool}/modules/base/static/css/index.scss | 0 src/cool/modules/base/static/css/theme.scss | 50 ++++ .../base/static/images/default-avatar.png | Bin .../cool}/modules/base/static/images/logo.png | Bin {cool => src/cool}/modules/base/store/app.js | 17 +- .../cool}/modules/base/store/index.js | 0 {cool => src/cool}/modules/base/store/menu.js | 38 ++- src/cool/modules/base/store/module.js | 26 ++ .../cool}/modules/base/store/process.js | 6 +- {cool => src/cool}/modules/base/store/user.js | 14 +- src/cool/modules/base/utils/index.js | 31 ++ src/cool/modules/base/views/index.js | 10 + .../cool}/modules/base/views/info.vue | 2 +- {cool => src/cool}/modules/base/views/log.vue | 6 +- .../cool}/modules/base/views/menu.vue | 131 +++++---- .../cool}/modules/base/views/param.vue | 0 .../cool}/modules/base/views/perf.vue | 2 +- .../cool}/modules/base/views/plugin.vue | 30 +- .../cool}/modules/base/views/role.vue | 0 .../cool}/modules/base/views/user.vue | 4 +- .../cool}/modules/chat/components/box.vue | 32 ++- .../cool}/modules/chat/components/emoji.vue | 2 +- .../modules/chat/components/icon-voice.vue | 0 src/cool/modules/chat/components/index.js | 3 + .../cool}/modules/chat/components/message.vue | 6 +- .../cool}/modules/chat/components/notice.vue | 8 +- {cool => src/cool}/modules/chat/index.js | 0 .../cool}/modules/chat/service/index.js | 0 .../cool}/modules/chat/service/message.js | 0 .../cool}/modules/chat/service/session.js | 0 .../chat/static/images/custom-avatar.png | Bin .../modules/chat/static/images/emoji.png | Bin .../modules/chat/static/images/image.png | Bin .../modules/chat/static/images/video.png | Bin .../cool}/modules/chat/static/notify.mp3 | Bin .../cool}/modules/chat/utils/index.js | 0 .../cool}/modules/copy/directives/index.js | 4 +- {cool => src/cool}/modules/copy/index.js | 0 src/cool/modules/demo/index.js | 1 + src/cool/modules/demo/utils/service.js | 106 +++++++ .../views/components/b-cl-context-menu.vue | 0 .../demo/views/components/b-cl-crud.vue | 0 .../views/components/b-cl-editor-quill.vue | 0 .../demo/views/components/b-cl-form.vue | 2 +- .../demo/views/components/b-cl-upload.vue | 0 .../demo/views/components/b-error-page.vue | 0 .../demo/views/components/b-icon-svg.vue | 0 .../demo/views/components/b-v-copy.vue | 0 .../cool}/modules/demo/views/crud.vue | 4 +- .../cool}/modules/demo/views/demo.vue | 0 .../cool}/modules/demo/views/editor-quill.vue | 0 .../cool}/modules/demo/views/upload.vue | 0 .../modules/distpicker/components/data.json | 0 .../modules/distpicker/components/index.vue | 0 .../cool}/modules/distpicker/index.js | 0 src/cool/modules/task/index.js | 3 + src/cool/modules/task/service/index.js | 7 + .../cool}/modules/task/service/info.js | 0 .../cool}/modules/task/views/task.vue | 20 +- src/cool/modules/theme/components/index.js | 5 + src/cool/modules/theme/components/theme.vue | 158 +++++++++++ src/cool/modules/theme/index.js | 3 + .../cool}/modules/upload/components/index.js | 0 .../cool}/modules/upload/components/index.vue | 34 +-- .../cool}/modules/upload/components/space.vue | 28 +- {cool => src/cool}/modules/upload/index.js | 0 .../cool}/modules/upload/package.json | 0 .../cool}/modules/upload/service/index.js | 0 .../cool}/modules/upload/service/info.js | 2 +- .../cool}/modules/upload/service/type.js | 2 +- src/core/common/index.js | 11 + src/core/index.js | 12 + src/core/service/base.js | 118 ++++++++ src/core/service/desorator.js | 38 +++ src/core/service/index.js | 4 + src/core/set/index.js | 5 + src/core/set/module.js | 157 +++++++++++ src/core/set/router.js | 113 ++++++++ src/core/set/service.js | 53 ++++ src/core/utils/index.js | 266 ++++++++++++++++++ src/core/utils/storage.js | 81 ++++++ src/icons/svg/icon-theme.svg | 12 + src/main.js | 4 +- src/pages/layout/topbar.vue | 25 +- src/router/index.js | 2 +- src/service/request.js | 20 +- .../home/components/category-ratio.vue | 0 .../home/components/count-effect.vue | 0 .../home/components/count-paid.vue | 0 .../home/components/count-sales.vue | 0 .../home/components/count-views.vue | 0 .../home/components/hot-search.vue | 0 .../home/components/sales-rank.vue | 6 +- .../home/components/tab-chart.vue | 0 src/{pages => views}/home/index.vue | 0 vue.config.js | 86 +++--- 170 files changed, 1816 insertions(+), 1026 deletions(-) create mode 100644 .editorconfig delete mode 100644 cool/index.js delete mode 100644 cool/modules/base/components/menu/file.vue delete mode 100644 cool/modules/base/package.json delete mode 100644 cool/modules/base/static/css/theme.scss delete mode 100644 cool/modules/base/store/module.js delete mode 100644 cool/modules/base/utils/index.js delete mode 100644 cool/modules/base/views/index.js delete mode 100644 cool/modules/chat/components/index.js delete mode 100644 cool/modules/chat/package.json delete mode 100644 cool/modules/copy/package.json delete mode 100644 cool/modules/demo/index.js delete mode 100644 cool/modules/demo/package.json delete mode 100644 cool/modules/demo/utils/service.js delete mode 100644 cool/modules/demo/views/index.js delete mode 100644 cool/modules/task/index.js delete mode 100644 cool/modules/task/package.json delete mode 100644 cool/modules/task/service/index.js delete mode 100644 cool/modules/task/views/index.js create mode 100644 src/cool/index.js rename {cool => src/cool}/modules/base/common/index.js (73%) rename {cool => src/cool}/modules/base/components/avatar/index.vue (100%) rename {cool => src/cool}/modules/base/components/codemirror/index.vue (99%) rename {cool => src/cool}/modules/base/components/dept/check.vue (98%) rename {cool => src/cool}/modules/base/components/dept/move.vue (97%) rename {cool => src/cool}/modules/base/components/dept/tree.vue (97%) rename {cool => src/cool}/modules/base/components/editor-quill/index.vue (100%) rename {cool => src/cool}/modules/base/components/icon-svg/index.vue (100%) rename {cool => src/cool}/modules/base/components/index.js (100%) create mode 100644 src/cool/modules/base/components/menu/file.vue rename {cool => src/cool}/modules/base/components/menu/icons.vue (96%) rename {cool => src/cool}/modules/base/components/menu/perms.vue (78%) rename {cool => src/cool}/modules/base/components/menu/slider/index.js (82%) rename {cool => src/cool}/modules/base/components/menu/slider/index.scss (77%) rename {cool => src/cool}/modules/base/components/menu/topbar.vue (96%) rename {cool => src/cool}/modules/base/components/menu/tree.vue (91%) rename {cool => src/cool}/modules/base/components/perf/common.js (100%) rename {cool => src/cool}/modules/base/components/perf/ct.vue (97%) rename {cool => src/cool}/modules/base/components/perf/mysql.vue (98%) rename {cool => src/cool}/modules/base/components/perf/network.vue (96%) rename {cool => src/cool}/modules/base/components/perf/redis.vue (98%) rename {cool => src/cool}/modules/base/components/process/index.vue (92%) rename {cool => src/cool}/modules/base/components/role/perms.vue (92%) rename {cool => src/cool}/modules/base/components/role/select.vue (100%) rename {cool => src/cool}/modules/base/components/route-nav/index.vue (92%) rename {cool => src/cool}/modules/base/components/scrollbar/index.vue (100%) rename {cool => src/cool}/modules/base/directives/index.js (100%) rename {cool => src/cool}/modules/base/directives/permission.js (77%) rename {cool => src/cool}/modules/base/filters/index.js (100%) rename {cool => src/cool}/modules/base/index.js (100%) rename {cool => src/cool}/modules/base/pages/error-page/403.vue (100%) rename {cool => src/cool}/modules/base/pages/error-page/404.vue (100%) rename {cool => src/cool}/modules/base/pages/error-page/500.vue (100%) rename {cool => src/cool}/modules/base/pages/error-page/502.vue (100%) rename {cool => src/cool}/modules/base/pages/error-page/components/error-page.vue (100%) rename {cool => src/cool}/modules/base/pages/iframe/index.vue (100%) rename {cool => src/cool}/modules/base/pages/index.js (76%) rename {cool => src/cool}/modules/base/pages/login/components/captcha.vue (97%) rename {cool => src/cool}/modules/base/pages/login/index.vue (100%) rename {cool => src/cool}/modules/base/service/common.js (100%) rename {cool => src/cool}/modules/base/service/index.js (100%) rename {cool => src/cool}/modules/base/service/open.js (100%) rename {cool => src/cool}/modules/base/service/plugin/info.js (100%) rename {cool => src/cool}/modules/base/service/system/dept.js (100%) rename {cool => src/cool}/modules/base/service/system/info.js (100%) rename {cool => src/cool}/modules/base/service/system/log.js (100%) rename {cool => src/cool}/modules/base/service/system/menu.js (100%) rename {cool => src/cool}/modules/base/service/system/param.js (100%) rename {cool => src/cool}/modules/base/service/system/role.js (100%) rename {cool => src/cool}/modules/base/service/system/user.js (100%) rename {cool => src/cool}/modules/base/static/css/index.scss (100%) create mode 100644 src/cool/modules/base/static/css/theme.scss rename {cool => src/cool}/modules/base/static/images/default-avatar.png (100%) rename {cool => src/cool}/modules/base/static/images/logo.png (100%) rename {cool => src/cool}/modules/base/store/app.js (69%) rename {cool => src/cool}/modules/base/store/index.js (100%) rename {cool => src/cool}/modules/base/store/menu.js (82%) create mode 100644 src/cool/modules/base/store/module.js rename {cool => src/cool}/modules/base/store/process.js (86%) rename {cool => src/cool}/modules/base/store/user.js (87%) create mode 100644 src/cool/modules/base/utils/index.js create mode 100644 src/cool/modules/base/views/index.js rename {cool => src/cool}/modules/base/views/info.vue (98%) rename {cool => src/cool}/modules/base/views/log.vue (96%) rename {cool => src/cool}/modules/base/views/menu.vue (76%) rename {cool => src/cool}/modules/base/views/param.vue (100%) rename {cool => src/cool}/modules/base/views/perf.vue (95%) rename {cool => src/cool}/modules/base/views/plugin.vue (90%) rename {cool => src/cool}/modules/base/views/role.vue (100%) rename {cool => src/cool}/modules/base/views/user.vue (99%) rename {cool => src/cool}/modules/chat/components/box.vue (95%) rename {cool => src/cool}/modules/chat/components/emoji.vue (98%) rename {cool => src/cool}/modules/chat/components/icon-voice.vue (100%) create mode 100644 src/cool/modules/chat/components/index.js rename {cool => src/cool}/modules/chat/components/message.vue (98%) rename {cool => src/cool}/modules/chat/components/notice.vue (84%) rename {cool => src/cool}/modules/chat/index.js (100%) rename {cool => src/cool}/modules/chat/service/index.js (100%) rename {cool => src/cool}/modules/chat/service/message.js (100%) rename {cool => src/cool}/modules/chat/service/session.js (100%) rename {cool => src/cool}/modules/chat/static/images/custom-avatar.png (100%) rename {cool => src/cool}/modules/chat/static/images/emoji.png (100%) rename {cool => src/cool}/modules/chat/static/images/image.png (100%) rename {cool => src/cool}/modules/chat/static/images/video.png (100%) rename {cool => src/cool}/modules/chat/static/notify.mp3 (100%) rename {cool => src/cool}/modules/chat/utils/index.js (100%) rename {cool => src/cool}/modules/copy/directives/index.js (88%) rename {cool => src/cool}/modules/copy/index.js (100%) create mode 100644 src/cool/modules/demo/index.js create mode 100644 src/cool/modules/demo/utils/service.js rename {cool => src/cool}/modules/demo/views/components/b-cl-context-menu.vue (100%) rename {cool => src/cool}/modules/demo/views/components/b-cl-crud.vue (100%) rename {cool => src/cool}/modules/demo/views/components/b-cl-editor-quill.vue (100%) rename {cool => src/cool}/modules/demo/views/components/b-cl-form.vue (98%) rename {cool => src/cool}/modules/demo/views/components/b-cl-upload.vue (100%) rename {cool => src/cool}/modules/demo/views/components/b-error-page.vue (100%) rename {cool => src/cool}/modules/demo/views/components/b-icon-svg.vue (100%) rename {cool => src/cool}/modules/demo/views/components/b-v-copy.vue (100%) rename {cool => src/cool}/modules/demo/views/crud.vue (99%) rename {cool => src/cool}/modules/demo/views/demo.vue (100%) rename {cool => src/cool}/modules/demo/views/editor-quill.vue (100%) rename {cool => src/cool}/modules/demo/views/upload.vue (100%) rename {cool => src/cool}/modules/distpicker/components/data.json (100%) rename {cool => src/cool}/modules/distpicker/components/index.vue (100%) rename {cool => src/cool}/modules/distpicker/index.js (100%) create mode 100644 src/cool/modules/task/index.js create mode 100644 src/cool/modules/task/service/index.js rename {cool => src/cool}/modules/task/service/info.js (100%) rename {cool => src/cool}/modules/task/views/task.vue (98%) create mode 100644 src/cool/modules/theme/components/index.js create mode 100644 src/cool/modules/theme/components/theme.vue create mode 100644 src/cool/modules/theme/index.js rename {cool => src/cool}/modules/upload/components/index.js (100%) rename {cool => src/cool}/modules/upload/components/index.vue (94%) rename {cool => src/cool}/modules/upload/components/space.vue (95%) rename {cool => src/cool}/modules/upload/index.js (100%) rename {cool => src/cool}/modules/upload/package.json (100%) rename {cool => src/cool}/modules/upload/service/index.js (100%) rename {cool => src/cool}/modules/upload/service/info.js (71%) rename {cool => src/cool}/modules/upload/service/type.js (71%) create mode 100644 src/core/common/index.js create mode 100644 src/core/index.js create mode 100644 src/core/service/base.js create mode 100644 src/core/service/desorator.js create mode 100644 src/core/service/index.js create mode 100644 src/core/set/index.js create mode 100644 src/core/set/module.js create mode 100644 src/core/set/router.js create mode 100644 src/core/set/service.js create mode 100644 src/core/utils/index.js create mode 100644 src/core/utils/storage.js create mode 100644 src/icons/svg/icon-theme.svg rename src/{pages => views}/home/components/category-ratio.vue (100%) rename src/{pages => views}/home/components/count-effect.vue (100%) rename src/{pages => views}/home/components/count-paid.vue (100%) rename src/{pages => views}/home/components/count-sales.vue (100%) rename src/{pages => views}/home/components/count-views.vue (100%) rename src/{pages => views}/home/components/hot-search.vue (100%) rename src/{pages => views}/home/components/sales-rank.vue (95%) rename src/{pages => views}/home/components/tab-chart.vue (100%) rename src/{pages => views}/home/index.vue (100%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..db1d3f8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# 🎨 editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore index 0d0f62a..3300625 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,6 +3,4 @@ /node_modules/ /src/icons/svg/ /mock/ -/cool/ -/src/cool/ vue.config.js \ No newline at end of file diff --git a/cool/index.js b/cool/index.js deleted file mode 100644 index 793cbff..0000000 --- a/cool/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import Base from "./modules/base"; -import Task from "./modules/task"; -import Upload from "./modules/upload"; -import Copy from "./modules/copy"; -import Demo from "./modules/demo"; -import Distpicker from "./modules/distpicker"; -import Crud from "cl-admin-crud"; -import Export from "cl-admin-export"; - -export default { - modules: [ - ["base", Base], - ["task", Task], - [ - "upload", - Upload, - { - icon: "el-icon-picture", - text: "选择图片", - limitSize: 1, - rename: true - } - ], - [ - "crud", - Crud, - { - crud: { - dict: { - sort: { - prop: "order", - order: "sort" - } - } - } - } - ], - ["export", Export], - ["copy", Copy], - ["distpicker", Distpicker], - ["demo", Demo] - ] -}; diff --git a/cool/modules/base/components/menu/file.vue b/cool/modules/base/components/menu/file.vue deleted file mode 100644 index d55c0e5..0000000 --- a/cool/modules/base/components/menu/file.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - - - diff --git a/cool/modules/base/package.json b/cool/modules/base/package.json deleted file mode 100644 index d02ff9a..0000000 --- a/cool/modules/base/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "base", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "quill": "^1.3.7", - "codemirror": "^5.59.2", - "js-beautify": "^1.13.5", - "vue-codemirror": "^4.0.6" - } -} diff --git a/cool/modules/base/static/css/theme.scss b/cool/modules/base/static/css/theme.scss deleted file mode 100644 index 4ab24dc..0000000 --- a/cool/modules/base/static/css/theme.scss +++ /dev/null @@ -1,126 +0,0 @@ -// customize style -.scroller1 { - overflow: hidden auto; - position: relative; - z-index: 9; - - &::-webkit-scrollbar-track { - background: transparent; - } - - &::-webkit-scrollbar-thumb { - background-color: rgba(144, 147, 153, 0.3); - border-radius: 6px; - } - - &::-webkit-scrollbar { - height: 6px; - width: 6px; - } -} - -// Element-ui theme -.el-input-number { - .el-input-number__decrease, - .el-input-number__increase { - border: 0 !important; - background-color: transparent; - } -} - -.el-dialog { - .el-dialog__header { - padding: 10px; - text-align: center; - border-bottom: 1px solid #f7f7f7; - - .el-dialog__title { - font-size: 15px; - letter-spacing: 0.5px; - } - - .el-dialog__headerbtn { - top: 13px; - - .el-dialog__close { - font-size: 18px; - } - } - } - - .el-dialog__body { - padding: 20px; - } - - .el-dialog__footer { - padding-bottom: 15px; - } -} - -.el-message { - &.el-message--success, - &.el-message--error, - &.el-message--info, - &.el-message--warning { - min-width: auto; - background-color: #fff; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); - border: 0; - padding: 12px 20px 12px 15px; - - .el-message__icon { - font-size: 16px; - } - - .el-message__content { - color: #999; - } - } -} - -.el-table { - &__header { - th { - padding: 0 !important; - background-color: #ebeef5 !important; - height: 36px; - line-height: 36px; - } - - .cell { - color: $color-main; - font-weight: normal; - } - } - - &__body { - &-wrapper { - @media only screen and (max-width: 768px) { - &::-webkit-scrollbar { - height: 6px; - width: 6px; - } - } - } - } - - &__column { - &-filter-trigger { - margin-left: 5px; - } - } - - &-column--selection { - .cell { - padding: 0 14px !important; - } - } -} - -.el-table-filter { - margin-top: 5px !important; - - .el-checkbox__label { - font-size: 12px; - } -} diff --git a/cool/modules/base/store/module.js b/cool/modules/base/store/module.js deleted file mode 100644 index 5b7702e..0000000 --- a/cool/modules/base/store/module.js +++ /dev/null @@ -1,33 +0,0 @@ -export default { - state: { - info: {}, - list: [], - views: [] - }, - - getters: { - // 模块信息 - modules: (state) => state.info, - // 模块列表 - moduleList: (state) => state.list, - // 模块视图 - moduleViews: (state) => state.views - }, - - mutations: { - SET_MODULE(state, list) { - let d = {}; - - list.forEach((e) => { - d[e.name] = e; - }); - - state.list = list; - state.info = d; - }, - - SET_MODULE_VIEWS(state, list) { - state.views = list; - } - } -}; diff --git a/cool/modules/base/utils/index.js b/cool/modules/base/utils/index.js deleted file mode 100644 index 2f50527..0000000 --- a/cool/modules/base/utils/index.js +++ /dev/null @@ -1,31 +0,0 @@ -export const revisePath = (path) => { - if (!path) { - return ""; - } - - if (path[0] == "/") { - return path; - } else { - return `/${path}`; - } -}; - -export function firstMenu(list) { - let path = ""; - - const fn = (arr) => { - arr.forEach((e) => { - if (e.type == 1) { - if (!path) { - path = e.path; - } - } else { - fn(e.children); - } - }); - }; - - fn(list); - - return path || "/404"; -} diff --git a/cool/modules/base/views/index.js b/cool/modules/base/views/index.js deleted file mode 100644 index fc42c00..0000000 --- a/cool/modules/base/views/index.js +++ /dev/null @@ -1,56 +0,0 @@ -export default [ - { - label: "个人中心", - path: "/my/info", - component: () => import("./info") - }, - { - moduleName: "sys-user", - label: "用户列表", - path: "/sys/user", - icon: "icon-user", - component: () => import("./user") - }, - { - moduleName: "sys-menu", - label: "菜单列表", - path: "/sys/menu", - icon: "icon-menu", - component: () => import("./menu") - }, - { - moduleName: "sys-role", - label: "角色列表", - path: "/sys/role", - icon: "icon-common", - component: () => import("./role") - }, - { - moduleName: "sys.perf", - label: "状态监控", - path: "/sys/perf", - icon: "icon-warn", - component: () => import("./perf") - }, - { - moduleName: "sys.param", - label: "参数列表", - path: "/sys/param", - icon: "icon-menu", - component: () => import("./param") - }, - { - moduleName: "sys.log", - label: "请求日志", - path: "/sys/log", - icon: "icon-log", - component: () => import("./log") - }, - { - moduleName: "plugin", - label: "插件列表", - path: "/plugin", - icon: "icon-menu", - component: () => import("./plugin") - } -]; diff --git a/cool/modules/chat/components/index.js b/cool/modules/chat/components/index.js deleted file mode 100644 index 1fb09af..0000000 --- a/cool/modules/chat/components/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import ChatBox from "./box"; -import Notice from "./notice"; - -export default { ChatBox, Notice }; diff --git a/cool/modules/chat/package.json b/cool/modules/chat/package.json deleted file mode 100644 index 3b674eb..0000000 --- a/cool/modules/chat/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "chat", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "dayjs": "^1.10.4", - "socket.io-client": "^3.1.1" - } -} diff --git a/cool/modules/copy/package.json b/cool/modules/copy/package.json deleted file mode 100644 index d75ac1a..0000000 --- a/cool/modules/copy/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "copy", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "clipboard": "^2.0.6" - } -} diff --git a/cool/modules/demo/index.js b/cool/modules/demo/index.js deleted file mode 100644 index 3c5dcb8..0000000 --- a/cool/modules/demo/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import views from './views' - -export default { - views -}; diff --git a/cool/modules/demo/package.json b/cool/modules/demo/package.json deleted file mode 100644 index 7859683..0000000 --- a/cool/modules/demo/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "demo", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "dayjs": "^1.10.4" - } -} diff --git a/cool/modules/demo/utils/service.js b/cool/modules/demo/utils/service.js deleted file mode 100644 index b851040..0000000 --- a/cool/modules/demo/utils/service.js +++ /dev/null @@ -1,106 +0,0 @@ -import dayjs from 'dayjs' - -let id = 10 - -export const UserList = [ - { - id: 1, - name: "刘一", - createTime: "2019年09月02日", - price: 75.99, - status: 1 - }, - { - id: 2, - name: "陈二", - createTime: "2019年09月05日", - price: 242.1, - status: 1 - }, - { - id: 3, - name: "张三", - createTime: "2019年09月12日", - price: 74.11, - status: 0 - }, - { - id: 4, - name: "李四", - createTime: "2019年09月13日", - price: 276.64, - status: 0 - }, - { - id: 5, - name: "王五", - createTime: "2019年09月18日", - price: 160.23, - status: 1 - } -]; - -export const TestService = { - page: (p) => { - console.log("GET[page]", p); - - let total = 0 - - let list = UserList.filter((e, i) => { - if (p.name) { - return e.name.includes(p.name) - } - - if (![undefined, null, ''].includes(p.status)) { - return e.status === p.status - } - - total++ - - if (i >= (p.page - 1) * p.size && i < p.page * p.size) { - return true - } else { - return false - } - }) - - return Promise.resolve({ - list, - pagination: { - page: p.page, - size: p.size, - total - } - }); - }, - info: (d) => { - console.log("GET[info]", d); - return new Promise((resolve) => { - resolve(UserList.find(e.id == d.id)); - }); - }, - add: (d) => { - console.log("POST[add]", d); - UserList.push({ - ...d, - id: id++, - createTime: dayjs().format('YYYY年MM月DD日') - }) - return Promise.resolve(); - }, - delete: (d) => { - console.log("POST[delete]", d); - let ids = d.ids.split(',') - ids.forEach(id => { - const index = UserList.findIndex(e => e.id == id) - UserList.splice(index, 1) - }) - return Promise.resolve(); - }, - update: (d) => { - console.log("POST[update]", d); - let item = UserList.find(e => e.id == d.id) - Object.assign(item, d) - return Promise.resolve(); - } -}; diff --git a/cool/modules/demo/views/index.js b/cool/modules/demo/views/index.js deleted file mode 100644 index 97e2dbf..0000000 --- a/cool/modules/demo/views/index.js +++ /dev/null @@ -1,26 +0,0 @@ -export default [ - { - moduleName: "crud", - label: "crud 示例", - path: "/crud", - component: () => import("./crud") - }, - { - moduleName: "editor-quill", - label: "quill 富文本编辑器", - path: "/editor-quill", - component: () => import("./editor-quill") - }, - { - moduleName: "upload", - label: "文件上传", - path: "/upload", - component: () => import("./upload") - }, - { - moduleName: "demo", - label: "组件预览", - path: "/demo", - component: () => import("./demo") - } -]; diff --git a/cool/modules/task/index.js b/cool/modules/task/index.js deleted file mode 100644 index b70c3ca..0000000 --- a/cool/modules/task/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import views from './views' -import service from './service' - -export default { views, service } \ No newline at end of file diff --git a/cool/modules/task/package.json b/cool/modules/task/package.json deleted file mode 100644 index 50af67e..0000000 --- a/cool/modules/task/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "task", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "vuedraggable": "^2.24.3" - } -} diff --git a/cool/modules/task/service/index.js b/cool/modules/task/service/index.js deleted file mode 100644 index b1e0687..0000000 --- a/cool/modules/task/service/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import Info from './info' - -export default { - task: { - info: new Info() - } -} \ No newline at end of file diff --git a/cool/modules/task/views/index.js b/cool/modules/task/views/index.js deleted file mode 100644 index 0cf9e35..0000000 --- a/cool/modules/task/views/index.js +++ /dev/null @@ -1,9 +0,0 @@ -export default [ - { - moduleName: "task", - label: "任务列表", - path: "/task", - icon: "icon-menu", - component: () => import("./task") - }, -] \ No newline at end of file diff --git a/package.json b/package.json index e5a9e00..b850749 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "cool-admin-vue", "version": "3.0.0", - "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", @@ -10,12 +9,12 @@ }, "dependencies": { "axios": "^0.21.1", - "cl-admin": "^1.2.0", - "cl-admin-crud": "^1.3.4", + "cl-admin": "^1.3.0", + "cl-admin-crud": "^1.4.0", "cl-admin-export": "^1.0.5", "clipboard": "^2.0.7", "codemirror": "^5.59.4", - "core-js": "^3.9.0", + "core-js": "^3.6.5", "dayjs": "^1.10.4", "echarts": "^4.5.0", "element-ui": "^2.15.1", @@ -26,36 +25,37 @@ "socket.io-client": "^3.1.2", "store": "^2.0.12", "uuid": "^8.3.2", - "vue": "^2.6.10", + "vue": "^2.6.11", "vue-codemirror": "^4.0.6", "vue-echarts": "^5.0.0-beta.0", - "vue-router": "^3.5.1", + "vue-router": "^3.2.0", "vuedraggable": "^2.24.3", - "vuex": "^3.6.2" + "vuex": "^3.4.0" }, "devDependencies": { "@typescript-eslint/parser": "^3.0.0", "@vue/babel-helper-vue-jsx-merge-props": "^1.0.0", "@vue/babel-preset-jsx": "^1.1.2", - "@vue/cli-plugin-babel": "^4.1.0", - "@vue/cli-plugin-eslint": "^4.1.0", - "@vue/cli-plugin-router": "^4.1.0", - "@vue/cli-plugin-vuex": "^4.1.0", - "@vue/cli-service": "^4.1.0", + "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-plugin-eslint": "~4.5.0", + "@vue/cli-plugin-router": "~4.5.0", + "@vue/cli-plugin-vuex": "~4.5.0", + "@vue/cli-service": "~4.5.0", "@vue/eslint-config-prettier": "^6.0.0", - "babel-eslint": "^10.0.3", + "babel-eslint": "^10.1.0", "babel-plugin-component": "^1.1.1", "babel-plugin-jsx-v-model": "^2.0.3", "clean-webpack-plugin": "^3.0.0", - "eslint": "^7.0.0", - "eslint-plugin-prettier": "^3.1.1", + "eslint": "^6.7.2", + "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-vue": "^6.2.2", - "node-sass": "^4.13.0", - "prettier": "^2.0.5", - "sass-loader": "^8.0.0", + "hard-source-webpack-plugin": "^0.13.1", + "node-sass": "^4.12.0", + "prettier": "^1.19.1", + "sass-loader": "^8.0.2", "svg-sprite-loader": "^5.0.0", "typescript": "^3.9.3", - "vue-template-compiler": "^2.6.10", + "vue-template-compiler": "^2.6.11", "webpack-cli": "^3.3.12" } } diff --git a/src/assets/css/common.scss b/src/assets/css/common.scss index b82fc7b..88abb56 100644 --- a/src/assets/css/common.scss +++ b/src/assets/css/common.scss @@ -1,14 +1,6 @@ -$color-main: #2f3447; +$color-main: var(--color-main, #2f3447); $color-danger: #f56c6c; $color-primary: #4165d7; $color-success: #67c23a; $color-info: #909399; $color-warning: #e6a23c; - -@mixin text_ellipsis($line: 1) { - overflow: hidden; - text-overflow: ellipsis; - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: $line; -} diff --git a/src/config/env.js b/src/config/env.js index 4f30a2a..3267d8d 100644 --- a/src/config/env.js +++ b/src/config/env.js @@ -2,16 +2,19 @@ import store from "store"; import { getUrlParam } from "cl-admin/utils"; // 路由模式 -const routerMode = "history"; +export const routerMode = "history"; // 开发模式 -const isDev = process.env.NODE_ENV == "development"; +export const isDev = process.env.NODE_ENV == "development"; // Host -const host = "https://show.cool-admin.com"; +export const host = "https://show.cool-admin.com"; + +// Socket +export const socketUrl = (isDev ? `${host}` : "") + "/socket"; // 请求地址 -const baseUrl = (function () { +export const baseUrl = (function() { let proxy = getUrlParam("proxy"); if (proxy) { @@ -20,24 +23,14 @@ const baseUrl = (function () { proxy = store.get("proxy") || "dev"; } - switch (process.env.NODE_ENV) { - case "development": - return `/${proxy}/admin`; - case "production": - return `/api/admin`; - default: - return ""; - } + return isDev ? `/${proxy}/admin` : `/api/admin`; })(); -// Socket -const socketUrl = (isDev ? `${host}` : "") + "/socket"; - // 阿里字体图标库 https://at.alicdn.com/t/**.css -const iconfontUrl = ``; +export const iconfontUrl = ``; // 程序配置参数 -const app = { +export const app = { name: "cool-admin", conf: { @@ -53,6 +46,4 @@ const app = { }; // 自定义菜单列表 -const menuList = []; - -export { routerMode, baseUrl, socketUrl, iconfontUrl, app, isDev, menuList }; +export const menuList = []; diff --git a/src/cool/index.js b/src/cool/index.js new file mode 100644 index 0000000..671ffe0 --- /dev/null +++ b/src/cool/index.js @@ -0,0 +1,41 @@ +import Crud from "cl-admin-crud"; +import Export from "cl-admin-export"; + +export default { + modules: [ + "base", + "task", + { + name: "upload", + options: { + icon: "el-icon-picture", + text: "选择图片", + limitSize: 1, + rename: true + } + }, + + { + name: "crud", + value: Crud, + options: { + crud: { + dict: { + sort: { + prop: "order", + order: "sort" + } + } + } + } + }, + { + name: "export", + value: Export + }, + "copy", + "distpicker", + "demo", + "theme" + ] +}; diff --git a/cool/modules/base/common/index.js b/src/cool/modules/base/common/index.js similarity index 73% rename from cool/modules/base/common/index.js rename to src/cool/modules/base/common/index.js index cfee74b..e74a94f 100644 --- a/cool/modules/base/common/index.js +++ b/src/cool/modules/base/common/index.js @@ -8,7 +8,7 @@ if (iconfontUrl) { document.getElementsByTagName("head")[0].appendChild(link); } -const requireAll = (requireContext) => requireContext.keys().map(requireContext); +const requireAll = requireContext => requireContext.keys().map(requireContext); const req = require.context("@/icons/svg/", false, /\.svg$/); requireAll(req); @@ -16,7 +16,7 @@ export function iconList() { return req .keys() .map(req) - .map((e) => e.default.id) - .filter((e) => e.includes("icon")) + .map(e => e.default.id) + .filter(e => e.includes("icon")) .sort(); } diff --git a/cool/modules/base/components/avatar/index.vue b/src/cool/modules/base/components/avatar/index.vue similarity index 100% rename from cool/modules/base/components/avatar/index.vue rename to src/cool/modules/base/components/avatar/index.vue diff --git a/cool/modules/base/components/codemirror/index.vue b/src/cool/modules/base/components/codemirror/index.vue similarity index 99% rename from cool/modules/base/components/codemirror/index.vue rename to src/cool/modules/base/components/codemirror/index.vue index 6e97848..8733faf 100644 --- a/cool/modules/base/components/codemirror/index.vue +++ b/src/cool/modules/base/components/codemirror/index.vue @@ -69,7 +69,7 @@ export default { }, mounted() { - this.$el.onkeydown = (e) => { + this.$el.onkeydown = e => { let keyCode = e.keyCode || e.which || e.charCode; let altKey = e.altKey || e.metaKey; let shiftKey = e.shiftKey || e.metaKey; diff --git a/cool/modules/base/components/dept/check.vue b/src/cool/modules/base/components/dept/check.vue similarity index 98% rename from cool/modules/base/components/dept/check.vue rename to src/cool/modules/base/components/dept/check.vue index 5c67d97..c745e2d 100644 --- a/cool/modules/base/components/dept/check.vue +++ b/src/cool/modules/base/components/dept/check.vue @@ -80,11 +80,11 @@ export default { refresh() { this.$service.system.dept .list() - .then((res) => { + .then(res => { this.list = deepTree(res); this.refreshTree(this.value); }) - .catch((err) => { + .catch(err => { this.$message.error(err); }); }, diff --git a/cool/modules/base/components/dept/move.vue b/src/cool/modules/base/components/dept/move.vue similarity index 97% rename from cool/modules/base/components/dept/move.vue rename to src/cool/modules/base/components/dept/move.vue index 8b5f72c..be87cb4 100644 --- a/cool/modules/base/components/dept/move.vue +++ b/src/cool/modules/base/components/dept/move.vue @@ -79,12 +79,12 @@ export default { departmentId: id, userIds: ids }) - .then((res) => { + .then(res => { this.$message.success("转移成功"); this.$emit("success", res); close(); }) - .catch((err) => { + .catch(err => { this.$message.error(err); this.$emit("error", err); done(); diff --git a/cool/modules/base/components/dept/tree.vue b/src/cool/modules/base/components/dept/tree.vue similarity index 97% rename from cool/modules/base/components/dept/tree.vue rename to src/cool/modules/base/components/dept/tree.vue index f39acda..f72c99d 100644 --- a/cool/modules/base/components/dept/tree.vue +++ b/src/cool/modules/base/components/dept/tree.vue @@ -158,7 +158,7 @@ export default { this.$service.system.dept .list() - .then((res) => { + .then(res => { this.list = deepTree(res); this.$emit("list-change", this.list); }) @@ -169,7 +169,7 @@ export default { rowClick(e) { ContextMenu.close(); - let ids = e.children ? revDeepTree(e.children).map((e) => e.id) : []; + let ids = e.children ? revDeepTree(e.children).map(e => e.id) : []; ids.unshift(e.id); this.$emit("row-click", { item: e, ids }); }, @@ -237,7 +237,7 @@ export default { close(); this.refresh(); }) - .catch((err) => { + .catch(err => { this.$message.error(err); done(); }); @@ -247,7 +247,7 @@ export default { }, rowDel(e) { - const del = (f) => { + const del = f => { this.$service.system.dept .delete({ ids: e.id, @@ -274,7 +274,7 @@ export default { .then(() => { del(true); }) - .catch((action) => { + .catch(action => { if (action == "cancel") { del(false); } @@ -288,7 +288,7 @@ export default { }) .then(() => { const deep = (list, pid) => { - list.forEach((e) => { + list.forEach(e => { e.parentId = pid; ids.push(e); @@ -315,7 +315,7 @@ export default { .then(() => { this.$message.success("更新排序成功"); }) - .catch((err) => { + .catch(err => { this.$message.error(err); }) .done(() => { diff --git a/cool/modules/base/components/editor-quill/index.vue b/src/cool/modules/base/components/editor-quill/index.vue similarity index 100% rename from cool/modules/base/components/editor-quill/index.vue rename to src/cool/modules/base/components/editor-quill/index.vue diff --git a/cool/modules/base/components/icon-svg/index.vue b/src/cool/modules/base/components/icon-svg/index.vue similarity index 100% rename from cool/modules/base/components/icon-svg/index.vue rename to src/cool/modules/base/components/icon-svg/index.vue diff --git a/cool/modules/base/components/index.js b/src/cool/modules/base/components/index.js similarity index 100% rename from cool/modules/base/components/index.js rename to src/cool/modules/base/components/index.js diff --git a/src/cool/modules/base/components/menu/file.vue b/src/cool/modules/base/components/menu/file.vue new file mode 100644 index 0000000..23acac4 --- /dev/null +++ b/src/cool/modules/base/components/menu/file.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/cool/modules/base/components/menu/icons.vue b/src/cool/modules/base/components/menu/icons.vue similarity index 96% rename from cool/modules/base/components/menu/icons.vue rename to src/cool/modules/base/components/menu/icons.vue index 377437e..1d23ccb 100644 --- a/cool/modules/base/components/menu/icons.vue +++ b/src/cool/modules/base/components/menu/icons.vue @@ -29,7 +29,7 @@ diff --git a/src/cool/modules/theme/index.js b/src/cool/modules/theme/index.js new file mode 100644 index 0000000..277a61b --- /dev/null +++ b/src/cool/modules/theme/index.js @@ -0,0 +1,3 @@ +import components from "./components"; + +export default { components }; diff --git a/cool/modules/upload/components/index.js b/src/cool/modules/upload/components/index.js similarity index 100% rename from cool/modules/upload/components/index.js rename to src/cool/modules/upload/components/index.js diff --git a/cool/modules/upload/components/index.vue b/src/cool/modules/upload/components/index.vue similarity index 94% rename from cool/modules/upload/components/index.vue rename to src/cool/modules/upload/components/index.vue index 9fa2479..3487365 100644 --- a/cool/modules/upload/components/index.vue +++ b/src/cool/modules/upload/components/index.vue @@ -251,8 +251,8 @@ export default { }; return this.urls - .filter((e) => Boolean(e.url)) - .map((e) => { + .filter(e => Boolean(e.url)) + .map(e => { let arr = e.url.split("."); let suf = last(arr); e.type = format.image.includes(suf) ? "image" : null; @@ -269,7 +269,7 @@ export default { arr = [this._size, this._size]; } - const [height, width] = arr.map((e) => (isNumber(e) ? `${e}px` : e)); + const [height, width] = arr.map(e => (isNumber(e) ? `${e}px` : e)); if (this.listType == "default" && !this.drag) { return { @@ -308,11 +308,11 @@ export default { // 比较数据,避免重复动画 if ( - !this.urls.some((e) => { + !this.urls.some(e => { return list.includes(e.url); }) ) { - this.fileList = list.filter(Boolean).map((url) => { + this.fileList = list.filter(Boolean).map(url => { return { url, name: path.basename(url), @@ -328,8 +328,8 @@ export default { // 更新值 update() { const urls = this.urls - .filter((e) => Boolean(e.url)) - .map((e) => e.url) + .filter(e => Boolean(e.url)) + .map(e => e.url) .join(","); this.$emit("input", urls); @@ -355,7 +355,7 @@ export default { // 删除文件 _onRemove(file) { this.urls.splice( - this.urls.findIndex((e) => e.uid === file.uid), + this.urls.findIndex(e => e.uid === file.uid), 1 ); this.update(); @@ -372,7 +372,7 @@ export default { this.preview.url = file.url; if (!file.url) { - let item = this.urls.find((e) => e.uid == file.uid); + let item = this.urls.find(e => e.uid == file.uid); if (item) { this.preview.url = item.url; @@ -423,9 +423,9 @@ export default { const { mode } = this.upload; // 多种上传请求 - const upload = (file) => { + const upload = file => { return new Promise((resolve, reject) => { - const next = (res) => { + const next = res => { let data = new FormData(); for (let i in res) { @@ -453,21 +453,21 @@ export default { "Content-Type": "multipart/form-data" }, data, - onUploadProgress: (e) => { + onUploadProgress: e => { if (this.onProgress) { e.percent = parseInt((e.loaded / e.total) * 100); this.onProgress(e, req.file); } } }) - .then((res) => { + .then(res => { if (mode === "local") { resolve(res); } else { resolve(`${res.host}/app/${fileName}`); } }) - .catch((err) => { + .catch(err => { reject(err); }); }; @@ -479,7 +479,7 @@ export default { } else { this.$service.common .upload() - .then((res) => { + .then(res => { if (isDev) { res.host = "@/oss-upload"; } @@ -494,10 +494,10 @@ export default { this.loading = true; upload(req.file) - .then((url) => { + .then(url => { this._onSuccess({ data: url }, { raw: req.file }); }) - .catch((err) => { + .catch(err => { console.error("upload error", err); this.$message.error(err); diff --git a/cool/modules/upload/components/space.vue b/src/cool/modules/upload/components/space.vue similarity index 95% rename from cool/modules/upload/components/space.vue rename to src/cool/modules/upload/components/space.vue index b56e954..a1b57ee 100644 --- a/cool/modules/upload/components/space.vue +++ b/src/cool/modules/upload/components/space.vue @@ -286,11 +286,11 @@ export default { ...mapGetters(["token"]), categoryList() { - return this.category.list.filter((e) => e.name.includes(this.category.keyword)); + return this.category.list.filter(e => e.name.includes(this.category.keyword)); }, selection() { - return this.file.list.filter((e) => e.selected); + return this.file.list.filter(e => e.selected); } }, @@ -316,7 +316,7 @@ export default { this.visible = false; this.$nextTick(() => { - this.file.list.map((e) => { + this.file.list.map(e => { this.$set(e, "selected", false); }); }); @@ -324,7 +324,7 @@ export default { // 上传成功 onSuccess(res, file) { - let item = this.file.list.find((e) => file.uid == e.uid); + let item = this.file.list.find(e => file.uid == e.uid); if (item) { item.url = res.data; @@ -335,11 +335,11 @@ export default { type: item.type, classifyId: item.classifyId }) - .then((res) => { + .then(res => { item.loading = false; item.id = res.id; }) - .catch((err) => { + .catch(err => { this.$message.error(err); }); } @@ -377,7 +377,7 @@ export default { classifyId: this.category.current.id, type: this.accept }) - .then((res) => { + .then(res => { this.file.pagination = res.pagination; this.file.list = res.list; }) @@ -388,7 +388,7 @@ export default { // 刷新分类 refreshCategory() { - return this.$service.space.type.list().then((res) => { + return this.$service.space.type.list().then(res => { res.unshift({ name: "全部文件", id: null @@ -435,7 +435,7 @@ export default { next.then(() => { this.refreshCategory(); close(); - }).catch((err) => { + }).catch(err => { this.$message.error(err); done(); }); @@ -496,7 +496,7 @@ export default { this.refreshFile(); } }) - .catch((err) => { + .catch(err => { console.error(err); this.$message.error(err); }); @@ -535,7 +535,7 @@ export default { // 确认选中文件 confirmFile() { const selection = this.selection.filter((e, i) => i < this.limit); - const urls = selection.map((e) => e.url).join(","); + const urls = selection.map(e => e.url).join(","); this.$emit("input", urls); this.$emit("confirm", this.detailData ? selection : urls); @@ -561,14 +561,14 @@ export default { this.$message.success("删除成功"); this.file.list = this.file.list.filter( - (e) => !selection.map((e) => e.id).includes(e.id) + e => !selection.map(e => e.id).includes(e.id) ); this.$service.space.info .delete({ - ids: selection.map((e) => e.id).join(",") + ids: selection.map(e => e.id).join(",") }) - .catch((err) => { + .catch(err => { this.$message.error(err); }); }) diff --git a/cool/modules/upload/index.js b/src/cool/modules/upload/index.js similarity index 100% rename from cool/modules/upload/index.js rename to src/cool/modules/upload/index.js diff --git a/cool/modules/upload/package.json b/src/cool/modules/upload/package.json similarity index 100% rename from cool/modules/upload/package.json rename to src/cool/modules/upload/package.json diff --git a/cool/modules/upload/service/index.js b/src/cool/modules/upload/service/index.js similarity index 100% rename from cool/modules/upload/service/index.js rename to src/cool/modules/upload/service/index.js diff --git a/cool/modules/upload/service/info.js b/src/cool/modules/upload/service/info.js similarity index 71% rename from cool/modules/upload/service/info.js rename to src/cool/modules/upload/service/info.js index 22be4b6..c2a0364 100644 --- a/cool/modules/upload/service/info.js +++ b/src/cool/modules/upload/service/info.js @@ -1,6 +1,6 @@ import { BaseService, Service } from "cl-admin"; @Service("space/info") -class SpaceInfo extends BaseService { } +class SpaceInfo extends BaseService {} export default SpaceInfo; diff --git a/cool/modules/upload/service/type.js b/src/cool/modules/upload/service/type.js similarity index 71% rename from cool/modules/upload/service/type.js rename to src/cool/modules/upload/service/type.js index 081ef3b..194614f 100644 --- a/cool/modules/upload/service/type.js +++ b/src/cool/modules/upload/service/type.js @@ -1,6 +1,6 @@ import { BaseService, Service } from "cl-admin"; @Service("space/type") -class SpaceType extends BaseService { } +class SpaceType extends BaseService {} export default SpaceType; diff --git a/src/core/common/index.js b/src/core/common/index.js new file mode 100644 index 0000000..6b25db4 --- /dev/null +++ b/src/core/common/index.js @@ -0,0 +1,11 @@ +Promise.prototype.done = function(cb) { + let P = this.constructor; + + return this.then( + value => P.resolve(cb()).then(() => value), + reason => + P.resolve(cb()).then(() => { + throw reason; + }) + ); +}; diff --git a/src/core/index.js b/src/core/index.js new file mode 100644 index 0000000..46ccf3c --- /dev/null +++ b/src/core/index.js @@ -0,0 +1,12 @@ +import { BaseService, Service, Permission } from "./service"; +import { SET_SERVICE, SET_ROUTER, SET_MODULE } from "./set"; +import "./common"; + +async function bootstrap(options = {}) { + const { modules } = options; + + SET_ROUTER(); + SET_SERVICE(); + SET_MODULE({ events: modules }); +} +export { Service, Permission, BaseService, bootstrap }; diff --git a/src/core/service/base.js b/src/core/service/base.js new file mode 100644 index 0000000..cb47aeb --- /dev/null +++ b/src/core/service/base.js @@ -0,0 +1,118 @@ +import request from "@/service/request"; +import { baseUrl } from "@/config/env"; + +export default class BaseService { + constructor() { + const crud = { + page: "page", + list: "list", + info: "info", + add: "add", + delete: "delete", + update: "update" + }; + + if (!this.permission) { + this.permission = {}; + } + + for (let i in crud) { + if (this.namespace) { + this.permission[i] = this.namespace.replace(/\//g, ":") + ":" + crud[i]; + } else { + this.permission[i] = crud[i]; + } + } + } + + request(options = {}) { + if (!options.params) { + options.params = {}; + } + + let path = ""; + + if (process.env.NODE_ENV == "development") { + path = this.proxy || baseUrl; + } else { + if (this.proxy) { + path = this.url; + } else { + path = baseUrl; + } + } + + if (this.namespace) { + path += "/" + this.namespace; + } + + if (options.url.indexOf("http") !== 0) { + if (options.url[0] === "@") { + options.url = options.url.replace("@", ""); + } else { + options.url = path + options.url; + } + } + + return request(options); + } + + list(params) { + return this.request({ + url: "/list", + method: "POST", + data: { + ...params + } + }); + } + + page(params) { + return this.request({ + url: "/page", + method: "POST", + data: { + ...params + } + }); + } + + info(params) { + return this.request({ + url: "/info", + params: { + ...params + } + }); + } + + update(params) { + return this.request({ + url: "/update", + method: "POST", + data: { + ...params + } + }); + } + + delete(params) { + return this.request({ + url: "/delete", + method: "POST", + data: { + ...params + } + }); + } + + add(params) { + return this.request({ + url: "/add", + method: "POST", + data: { + ...params + } + }); + } +} diff --git a/src/core/service/desorator.js b/src/core/service/desorator.js new file mode 100644 index 0000000..a6dbed6 --- /dev/null +++ b/src/core/service/desorator.js @@ -0,0 +1,38 @@ +import { isObject } from "../utils"; + +export function Permission(value) { + return function (target, key, descriptor) { + if (!target.permission) { + target.permission = {}; + } + + setTimeout(() => { + target.permission[key] = ( + (target.namespace ? target.namespace + "/" : "") + value + ).replace(/\//g, ":"); + }, 0); + + return descriptor; + }; +} + +export function Service(value) { + return function (target) { + // 命名 + if (typeof value == "string") { + target.prototype.namespace = value; + } + + // 复杂项 + if (isObject(value)) { + let { proxy, namespace, url } = value; + + target.prototype.namespace = namespace; + + if (proxy) { + target.prototype.proxy = proxy; + target.prototype.url = url || process.env.PROXY_LIST[proxy].target; + } + } + }; +} diff --git a/src/core/service/index.js b/src/core/service/index.js new file mode 100644 index 0000000..f96b8cd --- /dev/null +++ b/src/core/service/index.js @@ -0,0 +1,4 @@ +import BaseService from "./base"; +import { Service, Permission } from "./desorator"; + +export { BaseService, Service, Permission }; diff --git a/src/core/set/index.js b/src/core/set/index.js new file mode 100644 index 0000000..0342a1a --- /dev/null +++ b/src/core/set/index.js @@ -0,0 +1,5 @@ +import SET_SERVICE from "./service"; +import SET_ROUTER from "./router"; +import SET_MODULE from "./module"; + +export { SET_SERVICE, SET_ROUTER, SET_MODULE }; diff --git a/src/core/set/module.js b/src/core/set/module.js new file mode 100644 index 0000000..c45e98b --- /dev/null +++ b/src/core/set/module.js @@ -0,0 +1,157 @@ +import Vue from "vue"; +import cool from "@/cool"; +import store from "@/store"; +import router from "@/router"; +import { deepMerge, isFunction, isObject, isString } from "../utils"; + +// 模块列表 +let modules = []; + +export default function () { + const files = require.context("@/cool/modules", true, /index.js$/); + + // 本地模块 + const local = files + .keys() + .map(e => { + let [, name, , error] = e.split("/"); + + if (!error) { + return { + name, + value: files(e).default + }; + } else { + return null; + } + }) + .filter(Boolean); + + // 安装模块 + function install(mod) { + const { store: _store, components, service, directives, filters, pages, views, name } = mod; + + try { + // 注册vuex模块 + if (_store) { + for (let i in _store) { + store.registerModule(`${name}-${i}`, _store[i]); + } + } + + // 注册组件 + if (components) { + for (let i in components) { + Vue.component(components[i].name, components[i]); + } + } + + // 注册请求服务 + if (service) { + deepMerge(store.$service, service); + } + + // 注册指令 + if (directives) { + for (let i in directives) { + Vue.directive(i, directives[i]); + } + } + + // 注册过滤器 + if (filters) { + for (let i in filters) { + Vue.filter(i, filters[i]); + } + } + + // 注册页面 + if (pages) { + pages.forEach(e => { + router.addRoute(e); + }); + } + + // 注册视图 + if (views) { + views.forEach(e => { + if (!e.meta) { + e.meta = {}; + } + + if (e.path) { + router.$plugin.addViews([e], { + ignore404: true + }); + } else { + console.error(`[${name}-views]:path in null`); + } + }); + } + } catch (e) { + console.error(`模块 ${name} 异常`, e); + } + } + + // 解析模块 + cool.modules.map(e => { + if (!e) { + return null; + } + + let mod = null; + + // Parse + if (isString(e)) { + mod = { + name: e + }; + } else if (isObject(e)) { + mod = e; + } else if (isArray(e)) { + mod = { + name: e[0], + value: e[1], + options: e[2] + }; + } else { + console.error(e, "格式错误"); + } + + // Set + if (mod.value) { + if (isFunction(mod.value.install)) { + mod.value = mod.value.install(Vue, mod.options); + } + } else { + const item = local.find(m => m.name === mod.name); + + if (item) { + mod.value = item.value; + } + } + + if (!mod.value) { + console.error(mod.name, "不是一个有效的模块"); + } + + // 是否开启 + if (mod.options && mod.options.enable === false) { + return null; + } + + if (mod) { + mod = { + name: mod.name, + options: mod.options, + ...mod.value + }; + + modules.push(mod); + install(mod); + } + }); + + // 缓存模块 + store.commit("SET_MODULE", modules); +} diff --git a/src/core/set/router.js b/src/core/set/router.js new file mode 100644 index 0000000..ab45f62 --- /dev/null +++ b/src/core/set/router.js @@ -0,0 +1,113 @@ +import VueRouter from "vue-router"; +import { Message } from "element-ui"; +import store from "@/store"; +import router, { ignore } from "@/router"; +import storage from "../utils/storage"; + +// Remove Navigating to current location (XXX) is not allowed +const routerPush = VueRouter.prototype.push; +VueRouter.prototype.push = function push(location) { + return routerPush.call(this, location).catch(error => error); +}; + +export default function () { + router.$plugin = { + addViews: (list, options) => { + if (!options) { + options = {}; + } + + // Parse route config + list.map(e => { + if (!e.component) { + let url = e.viewPath; + + if (url) { + if ( + /^(http[s]?:\/\/)([0-9a-z.]+)(:[0-9]+)?([/0-9a-z.]+)?(\?[0-9a-z&=]+)?(#[0-9-a-z]+)?/i.test( + url + ) + ) { + e.meta.iframeUrl = url; + e.component = () => + import(`@/cool/modules/base/pages/iframe/index.vue`); + } else { + e.component = () => import(`@/${url}`); + } + } else { + e.redirect = "/404"; + } + } + }); + + // Batch add route + list.forEach(e => { + router.addRoute("index", e); + }); + + // Add 404 rule + if (!options.ignore404) { + router.addRoute({ + path: "*", + redirect: "/404" + }); + } + }, + + to: url => { + if (router.path != url) { + router.push(url); + } + } + }; + + router.beforeEach((to, from, next) => { + const { token, browser } = store.getters; + + if (token) { + if (to.path.indexOf("/login") === 0) { + // 登录成功且 token 未过期,回到首页 + if (!storage.isExpired("token")) { + return next("/"); + } + } else { + // 添加路由进程 + store.commit("ADD_PROCESS", { + label: (to.meta && to.meta.label) || to.name, + value: to.fullPath + }); + } + } else { + if (!ignore.token.some(e => to.path.indexOf(e) === 0)) { + return next("/login"); + } + } + + // H5 下关闭左侧菜单 + if (browser.isMobile) { + store.commit("COLLAPSE_MENU", true); + } + + next(); + }); + + let lock = false; + + router.onError(err => { + if (!lock) { + lock = true; + + if (err.code == "MODULE_NOT_FOUND") { + console.error(err.message.replace("Cannot find module ", ""), "路由组件不存在"); + + Message.error(`路由组件路径错误`); + } else { + console.error(err); + } + + setTimeout(() => { + lock = false; + }, 0); + } + }); +} diff --git a/src/core/set/service.js b/src/core/set/service.js new file mode 100644 index 0000000..4b67eaf --- /dev/null +++ b/src/core/set/service.js @@ -0,0 +1,53 @@ +import Vue from "vue"; +import path from "path"; +import store from "@/store"; + +export default function() { + const files = require.context("@/service/", true, /\.js$/); + const ignore = ["./request.js"]; + + let modules = {}; + + files + .keys() + .filter(e => !ignore.includes(e)) + .map(e => { + if (e.includes("--ignore")) { + return false; + } + + let list = e.substr(2).split("/"); + let parents = list.slice(0, list.length - 1); + let name = path.basename(e, ".js"); + + let curr = modules; + let prev = null; + let key = null; + + parents.forEach(k => { + if (!curr[k]) { + curr[k] = {}; + } + + prev = curr; + curr = curr[k]; + key = k; + }); + + let ep = files(e); + + if (ep.default) { + let service = new ep.default(); + + if (name == "index") { + prev[key] = service; + } else { + curr[name] = service; + } + } else { + console.error(`Service must export default [${e}]`); + } + }); + + Vue.prototype.$service = store.$service = modules; +} diff --git a/src/core/utils/index.js b/src/core/utils/index.js new file mode 100644 index 0000000..1000b6e --- /dev/null +++ b/src/core/utils/index.js @@ -0,0 +1,266 @@ +import { routerMode } from "@/config/env"; +import storage from "./storage"; + +export function getUrlParam(name) { + let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); + let r = window.location.search.substr(1).match(reg); + if (r != null) return decodeURIComponent(r[2]); + return null; +} + +export function isPc() { + const userAgentInfo = navigator.userAgent; + const Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; + let flag = true; + for (let v = 0; v < Agents.length; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; +} + +export const isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); + +export function getBrowser() { + let ua = navigator.userAgent.toLowerCase(); + let btypeInfo = (ua.match(/firefox|chrome|safari|opera/g) || "other")[0]; + if ((ua.match(/msie|trident/g) || [])[0]) { + btypeInfo = "msie"; + } + let pc = ""; + let prefix = ""; + let plat = ""; + + let isTocuh = + "ontouchstart" in window || ua.indexOf("touch") !== -1 || ua.indexOf("mobile") !== -1; + if (isTocuh) { + if (ua.indexOf("ipad") !== -1) { + pc = "pad"; + } else if (ua.indexOf("mobile") !== -1) { + pc = "mobile"; + } else if (ua.indexOf("android") !== -1) { + pc = "androidPad"; + } else { + pc = "pc"; + } + } else { + pc = "pc"; + } + switch (btypeInfo) { + case "chrome": + case "safari": + case "mobile": + prefix = "webkit"; + break; + case "msie": + prefix = "ms"; + break; + case "firefox": + prefix = "Moz"; + break; + case "opera": + prefix = "O"; + break; + default: + prefix = "webkit"; + break; + } + plat = ua.indexOf("android") > 0 ? "android" : navigator.platform.toLowerCase(); + return { + version: (ua.match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], + plat: plat, + type: btypeInfo, + pc: pc, + prefix: prefix, + isMobile: pc == "pc" ? false : true + }; +} + +export function href(path, newWindow) { + let { search, origin, pathname } = window.location; + + if (pathname == path) { + return false; + } + + let url = ""; + + if (routerMode == "history") { + url = origin + path; + } else { + url = origin + search + "#" + path; + } + + if (newWindow) { + window.open(url); + } else { + window.location.href = url; + } +} + +export function orderBy(list, key) { + return list.sort((a, b) => a[key] - b[key]); +} + +export function deepTree(list) { + let newList = []; + let map = {}; + + list.forEach(e => (map[e.id] = e)); + + list.forEach(e => { + let parent = map[e.parentId]; + + if (parent) { + (parent.children || (parent.children = [])).push(e); + } else { + newList.push(e); + } + }); + + const fn = list => { + list.map(e => { + if (e.children instanceof Array) { + e.children = orderBy(e.children, "orderNum"); + + fn(e.children); + } + }); + }; + + fn(newList); + + return orderBy(newList, "orderNum"); +} + +export function revDeepTree(list = []) { + let d = []; + let id = 0; + + const deep = (list, parentId) => { + list.forEach(e => { + if (!e.id) { + e.id = id++; + } + + e.parentId = parentId; + + d.push(e); + + if (e.children && isArray(e.children)) { + deep(e.children, e.id); + } + }); + }; + + deep(list || [], null); + + return d; +} + +export function debounce(fn, delay) { + let timer = null; + + return function() { + let args = arguments; + let context = this; + + if (timer) { + clearTimeout(timer); + + timer = setTimeout(function() { + fn.apply(context, args); + }, delay); + } else { + timer = setTimeout(function() { + fn.apply(context, args); + }, delay); + } + }; +} + +export function isArray(value) { + if (typeof Array.isArray === "function") { + return Array.isArray(value); + } else { + return Object.prototype.toString.call(value) === "[object Array]"; + } +} + +export function isObject(value) { + return Object.prototype.toString.call(value) === "[object Object]"; +} + +export function isNumber(value) { + return !isNaN(Number(value)); +} + +export function isFunction(value) { + return typeof value == "function"; +} + +export function isString(value) { + return typeof value == "string"; +} + +export function isEmpty(value) { + if (isArray(value)) { + return value.length === 0; + } + + if (isObject(value)) { + return Object.keys(value).length === 0; + } + + return value === "" || value === undefined || value === null; +} + +export function last(data) { + if (isArray(data) || isString(data)) { + return data[data.length - 1]; + } +} + +export function cloneDeep(obj) { + let d = isArray(obj) ? obj : {}; + + if (isObject(obj)) { + for (let key in obj) { + if (obj.hasOwnProperty && obj.hasOwnProperty(key)) { + if (obj[key] && typeof obj[key] === "object") { + d[key] = cloneDeep(obj[key]); + } else { + d[key] = obj[key]; + } + } + } + } + + return d; +} + +export function clone(obj) { + return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj)); +} + +export function deepMerge(a, b) { + let k; + for (k in b) { + a[k] = + a[k] && a[k].toString() === "[object Object]" ? deepMerge(a[k], b[k]) : (a[k] = b[k]); + } + return a; +} + +export function contains(parent, node) { + if (document.documentElement.contains) { + return parent !== node && parent.contains(node); + } else { + while (node && (node = node.parentNode)) if (node === parent) return true; + return false; + } +} + +export { storage }; diff --git a/src/core/utils/storage.js b/src/core/utils/storage.js new file mode 100644 index 0000000..edf585c --- /dev/null +++ b/src/core/utils/storage.js @@ -0,0 +1,81 @@ +import store from "store"; + +export default { + // 后缀标识 + suffix: "_deadtime", + + /** + * 获取 + * @param {string} key 关键字 + */ + get(key) { + return store.get(key); + }, + + /** + * 获取全部 + */ + info() { + let d = {}; + + store.each(function(value, key) { + d[key] = value; + }); + + return d; + }, + + /** + * 设置 + * @param {string} key 关键字 + * @param {*} value 值 + * @param {number} expires 过期时间 + */ + set(key, value, expires) { + store.set(key, value); + + if (expires) { + store.set(`${key}${this.suffix}`, Date.parse(new Date()) + expires * 1000); + } + }, + + /** + * 是否过期 + * @param {string} key 关键字 + */ + isExpired(key) { + return (this.getExpiration(key) || 0) - Date.parse(new Date()) <= 2000; + }, + + /** + * 获取到期时间 + * @param {string} key 关键字 + */ + getExpiration(key) { + return this.get(key + this.suffix); + }, + + /** + * 移除 + * @param {string} key 关键字 + */ + remove(key) { + store.remove(key); + this.removeExpiration(key); + }, + + /** + * 移除到期时间 + * @param {string} key 关键字 + */ + removeExpiration(key) { + store.remove(key + this.suffix); + }, + + /** + * 清理 + */ + clearAll() { + store.clearAll(); + } +}; diff --git a/src/icons/svg/icon-theme.svg b/src/icons/svg/icon-theme.svg new file mode 100644 index 0000000..7833dde --- /dev/null +++ b/src/icons/svg/icon-theme.svg @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 405f08b..0c7145d 100644 --- a/src/main.js +++ b/src/main.js @@ -20,9 +20,9 @@ bootstrap() new Vue({ router, store, - render: (h) => h(App) + render: h => h(App) }).$mount("#app"); }) - .catch((err) => { + .catch(err => { console.error("COOL-ADMIN 启动失败", err); }); diff --git a/src/pages/layout/topbar.vue b/src/pages/layout/topbar.vue index 1fefcd6..920ff1b 100644 --- a/src/pages/layout/topbar.vue +++ b/src/pages/layout/topbar.vue @@ -4,21 +4,29 @@ - -
- -
-
+ +
+ +
+
@@ -99,9 +107,10 @@ export default { } &__tools { + display: flex; margin-right: 20px; - /deep/li { + li { list-style: none; height: 45px; width: 45px; @@ -111,7 +120,7 @@ export default { cursor: pointer; i { - font-size: 16px; + font-size: 18px; &:hover { opacity: 0.8; diff --git a/src/router/index.js b/src/router/index.js index ade11be..3886a84 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -19,7 +19,7 @@ const routes = [ { path: "/", name: "数据统计", - component: () => import("@/pages/home/index.vue") + component: () => import("@/views/home/index.vue") } ] } diff --git a/src/service/request.js b/src/service/request.js index d913974..de3c4ee 100644 --- a/src/service/request.js +++ b/src/service/request.js @@ -26,15 +26,15 @@ let isRefreshing = false; // Request axios.interceptors.request.use( - (config) => { + config => { const token = store.getters.token || ""; if (config.url) { - if (!ignore.token.some((e) => config.url.includes(e))) { + if (!ignore.token.some(e => config.url.includes(e))) { config.headers["Authorization"] = token; } - if (!ignore.NProgress.some((e) => config.url.includes(e))) { + if (!ignore.NProgress.some(e => config.url.includes(e))) { NProgress.start(); } } @@ -65,16 +65,16 @@ axios.interceptors.request.use( if (!isRefreshing) { isRefreshing = true; - store.dispatch("refreshToken").then((token) => { - requests.forEach((cb) => cb(token)); + store.dispatch("refreshToken").then(token => { + requests.forEach(cb => cb(token)); requests = []; isRefreshing = false; }); } - return new Promise((resolve) => { + return new Promise(resolve => { // 继续请求 - requests.push((token) => { + requests.push(token => { // 重新设置 token config.headers["Authorization"] = token; resolve(config); @@ -85,14 +85,14 @@ axios.interceptors.request.use( return config; }, - (error) => { + error => { return Promise.reject(error); } ); // Response axios.interceptors.response.use( - (res) => { + res => { NProgress.done(); const { code, data, message } = res.data; @@ -107,7 +107,7 @@ axios.interceptors.response.use( return Promise.reject(message); } }, - async (error) => { + async error => { NProgress.done(); if (error.response) { diff --git a/src/pages/home/components/category-ratio.vue b/src/views/home/components/category-ratio.vue similarity index 100% rename from src/pages/home/components/category-ratio.vue rename to src/views/home/components/category-ratio.vue diff --git a/src/pages/home/components/count-effect.vue b/src/views/home/components/count-effect.vue similarity index 100% rename from src/pages/home/components/count-effect.vue rename to src/views/home/components/count-effect.vue diff --git a/src/pages/home/components/count-paid.vue b/src/views/home/components/count-paid.vue similarity index 100% rename from src/pages/home/components/count-paid.vue rename to src/views/home/components/count-paid.vue diff --git a/src/pages/home/components/count-sales.vue b/src/views/home/components/count-sales.vue similarity index 100% rename from src/pages/home/components/count-sales.vue rename to src/views/home/components/count-sales.vue diff --git a/src/pages/home/components/count-views.vue b/src/views/home/components/count-views.vue similarity index 100% rename from src/pages/home/components/count-views.vue rename to src/views/home/components/count-views.vue diff --git a/src/pages/home/components/hot-search.vue b/src/views/home/components/hot-search.vue similarity index 100% rename from src/pages/home/components/hot-search.vue rename to src/views/home/components/hot-search.vue diff --git a/src/pages/home/components/sales-rank.vue b/src/views/home/components/sales-rank.vue similarity index 95% rename from src/pages/home/components/sales-rank.vue rename to src/views/home/components/sales-rank.vue index 11eab08..dabbc8c 100644 --- a/src/pages/home/components/sales-rank.vue +++ b/src/views/home/components/sales-rank.vue @@ -174,7 +174,11 @@ export default { margin: 0 10px; letter-spacing: 0.5px; color: #222; - @include text_ellipsis(); + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; } } diff --git a/src/pages/home/components/tab-chart.vue b/src/views/home/components/tab-chart.vue similarity index 100% rename from src/pages/home/components/tab-chart.vue rename to src/views/home/components/tab-chart.vue diff --git a/src/pages/home/index.vue b/src/views/home/index.vue similarity index 100% rename from src/pages/home/index.vue rename to src/views/home/index.vue diff --git a/vue.config.js b/vue.config.js index fe4264e..b03dd57 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,9 +1,48 @@ -const path = require("path"); +const HardSourceWebpackPlugin = require("hard-source-webpack-plugin"); const isProduction = process.env.NODE_ENV === "production"; -function resolve(dir) { - return path.join(__dirname, dir); +// 代理列表 +const PROXY_LIST = { + "/dev": { + target: "http://127.0.0.1:8001", + changeOrigin: true, + pathRewrite: { + "^/dev": "" + } + }, + + "/ap": { + target: "https://admin.cn.utools.club", + changeOrigin: true, + pathRewrite: { + "^/ap": "" + } + }, + + "/fz": { + target: "http://xfz520231.utools.club", + changeOrigin: true, + pathRewrite: { + "^/fz": "" + } + }, + + "/oss-upload": { + target: "https://cool-admin-pro.oss-cn-shanghai.aliyuncs.com", + changeOrigin: true, + pathRewrite: { + "^/oss-upload": "" + } + }, + + "/pro": { + target: "https://show.cool-admin.com", + changeOrigin: true, + pathRewrite: { + "^/pro": "/api" + } + } } module.exports = { @@ -31,34 +70,10 @@ module.exports = { errors: true }, disableHostCheck: true, - proxy: { - "/dev": { - target: "http://127.0.0.1:8001", - changeOrigin: true, - pathRewrite: { - "^/dev": "" - } - }, - - "/oss-upload": { - target: "https://cool-admin-pro.oss-cn-shanghai.aliyuncs.com", - changeOrigin: true, - pathRewrite: { - "^/oss-upload": "" - } - }, - - "/pro": { - target: "https://show.cool-admin.com", - changeOrigin: true, - pathRewrite: { - "^/pro": "/api" - } - } - } + proxy: PROXY_LIST }, - chainWebpack: (config) => { + chainWebpack: config => { // svg config.module.rule("svg").uses.clear(); @@ -78,7 +93,7 @@ module.exports = { .rule("vue") .use("vue-loader") .loader("vue-loader") - .tap((options) => { + .tap(options => { options.compilerOptions.preserveWhitespace = true; return options; }) @@ -90,8 +105,11 @@ module.exports = { // 移除 preload 插件,避免加载多余的资源 config.plugins.delete("preload-index"); - // 设置别名 - config.resolve.alias.set("cool", resolve("cool")); + // 设置环境变量 + config.plugin('define').tap(args => { + args[0]['process.env'].PROXY_LIST = JSON.stringify(PROXY_LIST) + return args + }) // 生产模式下 if (isProduction) { @@ -117,5 +135,9 @@ module.exports = { } }); } + }, + + configureWebpack: config => { + // config.plugins.push(new HardSourceWebpackPlugin()); } };