mooho-base-admin-plus 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/.env +5 -0
  2. package/.env.development +0 -0
  3. package/.env.production +0 -0
  4. package/.eslintignore +11 -0
  5. package/.eslintrc.js +47 -0
  6. package/.prettierrc +15 -0
  7. package/README.md +18 -0
  8. package/dist/favicon.ico +0 -0
  9. package/dist/mooho-base-admin-plus.min.esm.js +131746 -0
  10. package/dist/mooho-base-admin-plus.min.js +279 -0
  11. package/dist/setting.js +31 -0
  12. package/dist/static/images/app-barcode.png +0 -0
  13. package/dist/static/images/login/bg.png +0 -0
  14. package/dist/static/images/login/logo.png +0 -0
  15. package/dist/static/images/login/password-active.png +0 -0
  16. package/dist/static/images/login/password-default.png +0 -0
  17. package/dist/static/images/login/signIn-img.png +0 -0
  18. package/dist/static/images/login/user-active.png +0 -0
  19. package/dist/static/images/login/user-default.png +0 -0
  20. package/dist/static/images/logo-dark.png +0 -0
  21. package/dist/static/images/logo-small.png +0 -0
  22. package/dist/static/images/logo.png +0 -0
  23. package/dist/static/images/logo.svg +510 -0
  24. package/dist/static/images/no-image.png +0 -0
  25. package/dist/style.css +4 -0
  26. package/index.html +18 -0
  27. package/other/pda.vue +28 -0
  28. package/package.json +59 -0
  29. package/public/favicon.ico +0 -0
  30. package/public/setting.js +31 -0
  31. package/public/static/images/app-barcode.png +0 -0
  32. package/public/static/images/login/bg.png +0 -0
  33. package/public/static/images/login/logo.png +0 -0
  34. package/public/static/images/login/password-active.png +0 -0
  35. package/public/static/images/login/password-default.png +0 -0
  36. package/public/static/images/login/signIn-img.png +0 -0
  37. package/public/static/images/login/user-active.png +0 -0
  38. package/public/static/images/login/user-default.png +0 -0
  39. package/public/static/images/logo-dark.png +0 -0
  40. package/public/static/images/logo-small.png +0 -0
  41. package/public/static/images/logo.png +0 -0
  42. package/public/static/images/logo.svg +510 -0
  43. package/public/static/images/no-image.png +0 -0
  44. package/src/App.vue +60 -0
  45. package/src/api/application.js +35 -0
  46. package/src/api/customModel.js +187 -0
  47. package/src/api/customPage.js +15 -0
  48. package/src/api/customTable.js +24 -0
  49. package/src/api/dataSource.js +93 -0
  50. package/src/api/dataView.js +199 -0
  51. package/src/api/dictType.js +23 -0
  52. package/src/api/entityView.js +13 -0
  53. package/src/api/enum.js +15 -0
  54. package/src/api/filterColumn.js +16 -0
  55. package/src/api/model.js +244 -0
  56. package/src/api/movePlan.js +29 -0
  57. package/src/api/notification.js +28 -0
  58. package/src/api/openApiPermission.js +25 -0
  59. package/src/api/permission.js +51 -0
  60. package/src/api/planJob.js +15 -0
  61. package/src/api/process.js +23 -0
  62. package/src/api/processDef.js +36 -0
  63. package/src/api/processInst.js +16 -0
  64. package/src/api/rolePermission.js +17 -0
  65. package/src/api/roleProperty.js +36 -0
  66. package/src/api/shortcut.js +20 -0
  67. package/src/api/system.js +23 -0
  68. package/src/api/task.js +56 -0
  69. package/src/api/taskQueue.js +24 -0
  70. package/src/api/user.js +45 -0
  71. package/src/api/viewColumn.js +16 -0
  72. package/src/assets/svg/body.svg +17 -0
  73. package/src/assets/svg/header-theme-dark.svg +40 -0
  74. package/src/assets/svg/header-theme-primary.svg +40 -0
  75. package/src/assets/svg/header-top.svg +40 -0
  76. package/src/assets/svg/icon-happy.svg +1 -0
  77. package/src/assets/svg/icon-sad.svg +1 -0
  78. package/src/assets/svg/icon-social-bilibili.svg +1 -0
  79. package/src/assets/svg/icon-social-dingding.svg +1 -0
  80. package/src/assets/svg/icon-social-facebook.svg +1 -0
  81. package/src/assets/svg/icon-social-juejin.svg +1 -0
  82. package/src/assets/svg/icon-social-qq.svg +1 -0
  83. package/src/assets/svg/icon-social-twitter.svg +1 -0
  84. package/src/assets/svg/icon-social-wechat.svg +1 -0
  85. package/src/assets/svg/icon-social-weibo.svg +1 -0
  86. package/src/assets/svg/icon-social-zhihu.svg +1 -0
  87. package/src/assets/svg/nav-theme-dark.svg +40 -0
  88. package/src/assets/svg/nav-theme-light.svg +40 -0
  89. package/src/components/copyright/index.vue +28 -0
  90. package/src/components/home/notice-list.vue +62 -0
  91. package/src/components/home/shortcut.vue +125 -0
  92. package/src/components/input/dialog-select.vue +301 -0
  93. package/src/components/input/item-select.vue +195 -0
  94. package/src/components/link/index.vue +54 -0
  95. package/src/components/richEditor/index.vue +86 -0
  96. package/src/components/upload/file-upload.vue +84 -0
  97. package/src/components/upload/upload-attachment.vue +119 -0
  98. package/src/components/upload/upload-image.vue +212 -0
  99. package/src/components/view/column-check.vue +223 -0
  100. package/src/components/view/column-edit.vue +850 -0
  101. package/src/components/view/column-select.vue +206 -0
  102. package/src/components/view/condition-edit.vue +164 -0
  103. package/src/components/view/filter-edit.vue +633 -0
  104. package/src/components/view/filter-setting.vue +126 -0
  105. package/src/components/view/form-setting-layout.vue +375 -0
  106. package/src/components/view/form-setting.vue +247 -0
  107. package/src/components/view/group-column.vue +104 -0
  108. package/src/components/view/group-method.vue +104 -0
  109. package/src/components/view/mixin.js +72 -0
  110. package/src/components/view/modal-form-filter.vue +319 -0
  111. package/src/components/view/modal-form-sort.vue +248 -0
  112. package/src/components/view/modal-form.vue +453 -0
  113. package/src/components/view/modal-table.vue +471 -0
  114. package/src/components/view/table-filter.vue +702 -0
  115. package/src/components/view/table-setting.vue +533 -0
  116. package/src/components/view/view-chart.vue +423 -0
  117. package/src/components/view/view-form-draggable.vue +837 -0
  118. package/src/components/view/view-form.vue +1444 -0
  119. package/src/components/view/view-table.vue +2261 -0
  120. package/src/components/workflow/flow-chart.vue +846 -0
  121. package/src/directive/focus.js +10 -0
  122. package/src/directive/tabHide.js +9 -0
  123. package/src/i18n/index.js +15 -0
  124. package/src/i18n/locale/en-US.js +1 -0
  125. package/src/i18n/locale/lang.js +1 -0
  126. package/src/i18n/locale/zh-CN.js +1 -0
  127. package/src/i18n/locale.js +102 -0
  128. package/src/index.js +222 -0
  129. package/src/layouts/basic-layout/header-breadcrumb/index.vue +122 -0
  130. package/src/layouts/basic-layout/header-collapse/index.vue +44 -0
  131. package/src/layouts/basic-layout/header-fullscreen/index.vue +19 -0
  132. package/src/layouts/basic-layout/header-i18n/index.vue +45 -0
  133. package/src/layouts/basic-layout/header-log/index.vue +41 -0
  134. package/src/layouts/basic-layout/header-logo/index.vue +23 -0
  135. package/src/layouts/basic-layout/header-notice/index.vue +218 -0
  136. package/src/layouts/basic-layout/header-reload/index.vue +21 -0
  137. package/src/layouts/basic-layout/header-search/index.vue +37 -0
  138. package/src/layouts/basic-layout/header-setting/index.vue +219 -0
  139. package/src/layouts/basic-layout/header-user/index.vue +175 -0
  140. package/src/layouts/basic-layout/i18n.js +50 -0
  141. package/src/layouts/basic-layout/index.vue +280 -0
  142. package/src/layouts/basic-layout/menu-head/index.vue +120 -0
  143. package/src/layouts/basic-layout/menu-head/title.vue +48 -0
  144. package/src/layouts/basic-layout/menu-side/index.vue +113 -0
  145. package/src/layouts/basic-layout/menu-side/menu-collapse.vue +76 -0
  146. package/src/layouts/basic-layout/menu-side/menu-item.vue +31 -0
  147. package/src/layouts/basic-layout/menu-side/menu-title.vue +56 -0
  148. package/src/layouts/basic-layout/menu-side/submenu.vue +31 -0
  149. package/src/layouts/basic-layout/mixins/click-item.js +21 -0
  150. package/src/layouts/basic-layout/mixins/sider-menu-badge.js +13 -0
  151. package/src/layouts/basic-layout/mixins/translate-title.js +11 -0
  152. package/src/layouts/basic-layout/tabs/index.vue +192 -0
  153. package/src/layouts/basic-layout/water-mark/index.vue +29 -0
  154. package/src/libs/lodop/index.js +145 -0
  155. package/src/libs/random_str.js +10 -0
  156. package/src/libs/request/index.js +158 -0
  157. package/src/libs/system/index.js +234 -0
  158. package/src/libs/util.cookies.js +44 -0
  159. package/src/libs/util.db.js +13 -0
  160. package/src/libs/util.js +55 -0
  161. package/src/libs/util.log.js +88 -0
  162. package/src/libs/water-mark.js +44 -0
  163. package/src/menu/header.js +20 -0
  164. package/src/menu/modules/dashboard.js +23 -0
  165. package/src/menu/sider.js +12 -0
  166. package/src/mixins/app.js +9 -0
  167. package/src/mixins/page.js +643 -0
  168. package/src/pages/account/login.vue +101 -0
  169. package/src/pages/common/home.vue +169 -0
  170. package/src/pages/common/task-form.vue +350 -0
  171. package/src/pages/common/todo.vue +31 -0
  172. package/src/pages/system/apiLog.vue +79 -0
  173. package/src/pages/system/applicationType.vue +182 -0
  174. package/src/pages/system/customPage.vue +62 -0
  175. package/src/pages/system/customTable.vue +98 -0
  176. package/src/pages/system/dict.vue +36 -0
  177. package/src/pages/system/dictType.vue +58 -0
  178. package/src/pages/system/entityView.vue +38 -0
  179. package/src/pages/system/error/404.vue +6 -0
  180. package/src/pages/system/extendColumn.vue +99 -0
  181. package/src/pages/system/formView.vue +136 -0
  182. package/src/pages/system/log.vue +55 -0
  183. package/src/pages/system/notice.vue +26 -0
  184. package/src/pages/system/openApi.vue +26 -0
  185. package/src/pages/system/openUser.vue +66 -0
  186. package/src/pages/system/organization.vue +98 -0
  187. package/src/pages/system/organizationType.vue +26 -0
  188. package/src/pages/system/permission.vue +175 -0
  189. package/src/pages/system/planJob.vue +40 -0
  190. package/src/pages/system/printTemplate.vue +48 -0
  191. package/src/pages/system/process.vue +79 -0
  192. package/src/pages/system/processType.vue +26 -0
  193. package/src/pages/system/role.vue +395 -0
  194. package/src/pages/system/rolePropertyEdit.vue +480 -0
  195. package/src/pages/system/sequenceSetting.vue +26 -0
  196. package/src/pages/system/systemData.vue +52 -0
  197. package/src/pages/system/tableView.vue +386 -0
  198. package/src/pages/system/taskQueue.vue +48 -0
  199. package/src/pages/system/user.vue +250 -0
  200. package/src/pages/template/processPage.vue +243 -0
  201. package/src/pages/template/reportPage.vue +66 -0
  202. package/src/pages/template/viewPage.vue +139 -0
  203. package/src/plugins/auth/index.js +21 -0
  204. package/src/plugins/error/index.js +31 -0
  205. package/src/plugins/index.js +24 -0
  206. package/src/plugins/sweetalert2/index.js +20 -0
  207. package/src/router/dynamic.js +183 -0
  208. package/src/router/index.js +84 -0
  209. package/src/setting.js +202 -0
  210. package/src/store/index.js +9 -0
  211. package/src/store/modules/admin/index.js +16 -0
  212. package/src/store/modules/admin/modules/account.js +103 -0
  213. package/src/store/modules/admin/modules/cache.js +119 -0
  214. package/src/store/modules/admin/modules/dataView.js +112 -0
  215. package/src/store/modules/admin/modules/db.js +231 -0
  216. package/src/store/modules/admin/modules/i18n.js +87 -0
  217. package/src/store/modules/admin/modules/layout.js +115 -0
  218. package/src/store/modules/admin/modules/loader.js +44 -0
  219. package/src/store/modules/admin/modules/log.js +77 -0
  220. package/src/store/modules/admin/modules/menu.js +338 -0
  221. package/src/store/modules/admin/modules/page.js +466 -0
  222. package/src/store/modules/admin/modules/user.js +96 -0
  223. package/src/store/modules/admin/modules/viewPage.js +34 -0
  224. package/src/styles/common.less +47 -0
  225. package/src/styles/css/default.css +510 -0
  226. package/src/styles/css/login.css +1217 -0
  227. package/src/styles/default/index.less +6 -0
  228. package/src/styles/font/demo.css +539 -0
  229. package/src/styles/font/demo_index.html +372 -0
  230. package/src/styles/font/icon-demo/demo.css +539 -0
  231. package/src/styles/font/icon-demo/demo_index.html +423 -0
  232. package/src/styles/font/icon-demo/iconfont.css +61 -0
  233. package/src/styles/font/icon-demo/iconfont.eot +0 -0
  234. package/src/styles/font/icon-demo/iconfont.js +1 -0
  235. package/src/styles/font/icon-demo/iconfont.svg +59 -0
  236. package/src/styles/font/icon-demo/iconfont.ttf +0 -0
  237. package/src/styles/font/icon-demo/iconfont.woff +0 -0
  238. package/src/styles/font/icon-demo/iconfont.woff2 +0 -0
  239. package/src/styles/font/iconfont.css +47 -0
  240. package/src/styles/font/iconfont.js +1 -0
  241. package/src/styles/font/iconfont.json +65 -0
  242. package/src/styles/font/iconfont.ttf +0 -0
  243. package/src/styles/font/iconfont.woff +0 -0
  244. package/src/styles/font/iconfont.woff2 +0 -0
  245. package/src/styles/font/ionicons.svg +870 -0
  246. package/src/styles/font/ionicons.ttf +0 -0
  247. package/src/styles/font/ionicons.woff +0 -0
  248. package/src/styles/font/ionicons.woff2 +0 -0
  249. package/src/styles/index.less +7 -0
  250. package/src/styles/layout/basic-layout/layout.less +527 -0
  251. package/src/styles/layout/basic-layout/menu.less +274 -0
  252. package/src/styles/layout/index.less +2 -0
  253. package/src/styles/setting.less +6 -0
  254. package/styleguide.config.js +22 -0
  255. package/test/api/barcode.js +50 -0
  256. package/test/api/inbound.js +47 -0
  257. package/test/api/interfaceLog.js +15 -0
  258. package/test/api/interfaceQueue.js +15 -0
  259. package/test/api/interfaceServer.js +29 -0
  260. package/test/api/movePlan.js +50 -0
  261. package/test/api/movePlanItem.js +13 -0
  262. package/test/api/moveType.js +22 -0
  263. package/test/api/openApiPermission.js +25 -0
  264. package/test/api/outbound.js +40 -0
  265. package/test/api/permission.js +34 -0
  266. package/test/api/rolePermission.js +17 -0
  267. package/test/api/user.js +40 -0
  268. package/test/api/viewColumn.js +16 -0
  269. package/test/api/warehouse.js +13 -0
  270. package/test/api/warehouseMoveType.js +18 -0
  271. package/test/main.js +55 -0
  272. package/test/package.js +33 -0
  273. package/test/pages/home/index.vue +22 -0
  274. package/test/pages/task/test.vue +28 -0
  275. package/test/pages/test/dataViewTest.vue +28 -0
  276. package/test/pages/test/logReport.vue +25 -0
  277. package/test/pages/test/testPage.vue +38 -0
  278. package/test/router/routes.js +88 -0
  279. package/test/setting.env.js +22 -0
  280. package/test/styles/css/custom.css +0 -0
  281. package/test/styles/css/login.css +1217 -0
  282. package/vite.config.js +72 -0
  283. package/vue.config.js +20 -0
@@ -0,0 +1,119 @@
1
+ import enumApi from '../../../../api/enum';
2
+ import modelApi from '../../../../api/model';
3
+ import userApi from '../../../../api/user';
4
+
5
+ /**
6
+ * 缓存信息
7
+ * */
8
+ export default {
9
+ namespaced: true,
10
+ state: {
11
+ // 缓存
12
+ caches: {},
13
+ // 枚举字典信息
14
+ dicts: {},
15
+ // 枚举信息
16
+ enums: {},
17
+ // 用户姓名
18
+ userNames: {}
19
+ },
20
+ getters: {},
21
+ actions: {
22
+ /**
23
+ * @description 加载缓存数据
24
+ * @param {Object} state vuex state
25
+ * @param {*} type 类别
26
+ */
27
+ async loadCache({ state }, type) {
28
+ if (!(type in state.caches)) {
29
+ state.caches[type] = [];
30
+
31
+ try {
32
+ let res = await modelApi.query(type, {});
33
+
34
+ state.caches = {
35
+ ...state.caches
36
+ };
37
+
38
+ state.caches[type] = res.data;
39
+ } catch (err) {
40
+ delete state.caches[type];
41
+ throw err;
42
+ }
43
+ }
44
+ },
45
+ /**
46
+ * @description 加载枚举字典数据
47
+ * @param {Object} state vuex state
48
+ * @param {*} type 类别
49
+ */
50
+ async loadDict({ state }, type) {
51
+ if (!(type in state.dicts)) {
52
+ state.dicts[type] = {};
53
+
54
+ try {
55
+ let res = await modelApi.query('Dict', { type: type });
56
+ state.dicts = {
57
+ ...state.dicts
58
+ };
59
+
60
+ res.data.forEach(item => {
61
+ state.dicts[type][item.id] = item.displayName;
62
+ });
63
+ } catch (err) {
64
+ delete state.dicts[type];
65
+ throw err;
66
+ }
67
+ }
68
+ },
69
+ /**
70
+ * @description 加载枚举数据
71
+ * @param {Object} state vuex state
72
+ * @param {*} type 类别
73
+ */
74
+ async loadEnum({ state }, type) {
75
+ if (!(type in state.enums)) {
76
+ state.enums[type] = {};
77
+
78
+ try {
79
+ let res = await enumApi.query(type);
80
+ state.enums = {
81
+ ...state.enums
82
+ };
83
+
84
+ res.forEach(item => {
85
+ state.enums[type][item.id] = item.name;
86
+ });
87
+ } catch (err) {
88
+ delete state.enums[type];
89
+ throw err;
90
+ }
91
+ }
92
+ },
93
+ /**
94
+ * @description 加载用户姓名数据
95
+ * @param {Object} state vuex state
96
+ * @param {*} id 唯一编号
97
+ */
98
+ async loadUserName({ state }, id) {
99
+ if (id && !(id in state.userNames)) {
100
+ state.userNames[id] = {};
101
+
102
+ try {
103
+ let res = await userApi.get(id);
104
+
105
+ if (res) {
106
+ state.userNames = {
107
+ ...state.userNames
108
+ };
109
+
110
+ state.userNames[id] = res.name;
111
+ }
112
+ } catch (err) {
113
+ delete state.userNames[id];
114
+ throw err;
115
+ }
116
+ }
117
+ }
118
+ }
119
+ };
@@ -0,0 +1,112 @@
1
+ import dataViewApi from '../../../../api/dataView';
2
+
3
+ /**
4
+ * 缓存信息
5
+ * */
6
+ export default {
7
+ namespaced: true,
8
+ state: {
9
+ // 数据视图
10
+ dataViews: {},
11
+ // 数据结构
12
+ schemas: {}
13
+ },
14
+ getters: {
15
+ get: state => code => {
16
+ return state.dataViews[code];
17
+ },
18
+ getSchema: state => model => {
19
+ return state.schemas[model];
20
+ }
21
+ },
22
+ actions: {
23
+ /**
24
+ * @description 加载数据视图
25
+ * @param {Object} state vuex state
26
+ * @param {*} code 代码
27
+ */
28
+ async load({ state }, code) {
29
+ if (!(code in state.dataViews)) {
30
+ let res = await dataViewApi.getByCode(code);
31
+ state.dataViews[code] = res;
32
+
33
+ return res;
34
+ } else {
35
+ return state.dataViews[code];
36
+ }
37
+ },
38
+ /**
39
+ * @description 加载数据结构
40
+ * @param {Object} state vuex state
41
+ * @param {*} model 模型
42
+ */
43
+ async loadSchema({ state }, model) {
44
+ if (!(model in state.schemas)) {
45
+ let res = await dataViewApi.getSchemaByModel(model);
46
+ state.schemas[model] = res;
47
+
48
+ return res;
49
+ } else {
50
+ return state.schemas[model];
51
+ }
52
+ },
53
+ /**
54
+ * @description 重置数据视图
55
+ * @param {Object} state vuex state
56
+ * @param {*} code 代码
57
+ */
58
+ async reset({ state }, code) {
59
+ let res = await dataViewApi.reset(code);
60
+ state.dataViews[code] = res;
61
+
62
+ return res;
63
+ },
64
+ /**
65
+ * @description 保存数据视图
66
+ * @param {Object} state vuex state
67
+ * @param {*} code 代码
68
+ * @param {*} columns 字段
69
+ */
70
+ async save({ state }, { code, columns }) {
71
+ let res = await dataViewApi.save(code, columns);
72
+ state.dataViews[code] = res;
73
+
74
+ return res;
75
+ },
76
+ /**
77
+ * @description 保存用户数据视图
78
+ * @param {Object} state vuex state
79
+ * @param {*} code 代码
80
+ * @param {*} columns 字段
81
+ */
82
+ async saveUserView({ state }, { code, columns }) {
83
+ let res = await dataViewApi.saveUserView(code, columns);
84
+ state.dataViews[code] = res;
85
+
86
+ return res;
87
+ },
88
+ /**
89
+ * @description 保存筛选字段
90
+ * @param {Object} state vuex state
91
+ * @param {*} code 代码
92
+ * @param {*} columns 字段
93
+ */
94
+ async saveFilterColumn({ state }, { code, columns }) {
95
+ let res = await dataViewApi.saveFilterColumn(code, columns);
96
+ state.dataViews[code] = res;
97
+
98
+ return res;
99
+ },
100
+ /**
101
+ * @description 保存数据视图设置
102
+ * @param {Object} state vuex state
103
+ * @param {*} dataView 数据视图
104
+ */
105
+ async saveSetting({ state }, dataView) {
106
+ let res = await dataViewApi.saveSetting(dataView);
107
+ state.dataViews[dataView.code] = res;
108
+
109
+ return res;
110
+ }
111
+ }
112
+ };
@@ -0,0 +1,231 @@
1
+ /**
2
+ * 持久化存储
3
+ * 一般情况下,您无需修改此文件
4
+ * */
5
+ import util from '../../../../libs/util';
6
+ import router from '../../../../router';
7
+ import { cloneDeep } from 'lodash';
8
+
9
+ /**
10
+ * @description 检查路径是否存在 不存在的话初始化
11
+ * @param {Object} dbName {String} 数据库名称
12
+ * @param {Object} path {String} 路径
13
+ * @param {Object} user {Boolean} 区分用户
14
+ * @param {Object} validator {Function} 数据校验钩子 返回 true 表示验证通过
15
+ * @param {Object} defaultValue {*} 初始化默认值
16
+ * @returns {String} 可以直接使用的路径
17
+ */
18
+ function pathInit({ dbName = 'database', path = '', user = true, validator = () => true, defaultValue = '' }) {
19
+ const uuid = util.cookies.get('uuid') || 'ghost-uuid';
20
+ const currentPath = `${dbName}.${user ? `user.${uuid}` : 'public'}${path ? `.${path}` : ''}`;
21
+ const value = util.db.get(currentPath).value();
22
+
23
+ if (!(value !== undefined && validator(value))) {
24
+ util.db.set(currentPath, defaultValue).write();
25
+ }
26
+ return currentPath;
27
+ }
28
+
29
+ export { pathInit };
30
+
31
+ export default {
32
+ namespaced: true,
33
+ actions: {
34
+ /**
35
+ * @description 将数据存储到指定位置 | 路径不存在会自动初始化
36
+ * @description 效果类似于取值 dbName.path = value
37
+ * @param context context
38
+ * @param {Object} dbName {String} 数据库名称
39
+ * @param {Object} path {String} 存储路径
40
+ * @param {Object} value {*} 需要存储的值
41
+ * @param {Object} user {Boolean} 是否区分用户
42
+ */
43
+ set(context, { dbName = 'database', path = '', value = '', user = false }) {
44
+ util.db
45
+ .set(
46
+ pathInit({
47
+ dbName,
48
+ path,
49
+ user
50
+ }),
51
+ value
52
+ )
53
+ .write();
54
+ },
55
+ /**
56
+ * @description 获取数据
57
+ * @description 效果类似于取值 dbName.path || defaultValue
58
+ * @param context context
59
+ * @param {Object} dbName {String} 数据库名称
60
+ * @param {Object} path {String} 存储路径
61
+ * @param {Object} defaultValue {*} 取值失败的默认值
62
+ * @param {Object} user {Boolean} 是否区分用户
63
+ */
64
+ get(context, { dbName = 'database', path = '', defaultValue = '', user = false }) {
65
+ return new Promise(resolve => {
66
+ resolve(
67
+ cloneDeep(
68
+ util.db
69
+ .get(
70
+ pathInit({
71
+ dbName,
72
+ path,
73
+ user,
74
+ defaultValue
75
+ })
76
+ )
77
+ .value()
78
+ )
79
+ );
80
+ });
81
+ },
82
+ /**
83
+ * @description 获取存储数据库对象
84
+ * @param {Object} context context
85
+ * @param {Object} user {Boolean} 是否区分用户
86
+ */
87
+ database(context, { user = false } = {}) {
88
+ return new Promise(resolve => {
89
+ resolve(
90
+ util.db.get(
91
+ pathInit({
92
+ dbName: 'database',
93
+ path: '',
94
+ user,
95
+ defaultValue: {}
96
+ })
97
+ )
98
+ );
99
+ });
100
+ },
101
+ /**
102
+ * @description 清空存储数据库对象
103
+ * @param {Object} context context
104
+ * @param {Object} user {Boolean} 是否区分用户
105
+ */
106
+ databaseClear(context, { user = false } = {}) {
107
+ return new Promise(resolve => {
108
+ resolve(
109
+ util.db.get(
110
+ pathInit({
111
+ dbName: 'database',
112
+ path: '',
113
+ user,
114
+ validator: () => false,
115
+ defaultValue: {}
116
+ })
117
+ )
118
+ );
119
+ });
120
+ },
121
+ /**
122
+ * @description 获取存储数据库对象 [ 区分页面 ]
123
+ * @param {Object} context context
124
+ * @param {Object} basis {String} 页面区分依据 [ name | path | fullPath ]
125
+ * @param {Object} user {Boolean} 是否区分用户
126
+ */
127
+ databasePage(context, { basis = 'fullPath', user = false } = {}) {
128
+ return new Promise(resolve => {
129
+ resolve(
130
+ util.db.get(
131
+ pathInit({
132
+ dbName: 'database',
133
+ path: `$page.${router.app.$route[basis]}`,
134
+ user,
135
+ defaultValue: {}
136
+ })
137
+ )
138
+ );
139
+ });
140
+ },
141
+ /**
142
+ * @description 清空存储数据库对象 [ 区分页面 ]
143
+ * @param {Object} context context
144
+ * @param {Object} basis {String} 页面区分依据 [ name | path | fullPath ]
145
+ * @param {Object} user {Boolean} 是否区分用户
146
+ */
147
+ databasePageClear(context, { basis = 'fullPath', user = false } = {}) {
148
+ return new Promise(resolve => {
149
+ resolve(
150
+ util.db.get(
151
+ pathInit({
152
+ dbName: 'database',
153
+ path: `$page.${router.app.$route[basis]}`,
154
+ user,
155
+ validator: () => false,
156
+ defaultValue: {}
157
+ })
158
+ )
159
+ );
160
+ });
161
+ },
162
+ /**
163
+ * @description 快速将页面当前的数据 ( $data ) 持久化
164
+ * @param {Object} context context
165
+ * @param {Object} instance {Object} vue 实例
166
+ * @param {Object} basis {String} 页面区分依据 [ name | path | fullPath ]
167
+ * @param {Object} user {Boolean} 是否区分用户
168
+ */
169
+ pageSet(context, { instance, basis = 'fullPath', user = false }) {
170
+ return new Promise(resolve => {
171
+ resolve(
172
+ util.db.get(
173
+ pathInit({
174
+ dbName: 'database',
175
+ path: `$page.${router.app.$route[basis]}.$data`,
176
+ user,
177
+ validator: () => false,
178
+ defaultValue: cloneDeep(instance.$data)
179
+ })
180
+ )
181
+ );
182
+ });
183
+ },
184
+ /**
185
+ * @description 快速获取页面快速持久化的数据
186
+ * @param {Object} context context
187
+ * @param {Object} instance {Object} vue 实例
188
+ * @param {Object} basis {String} 页面区分依据 [ name | path | fullPath ]
189
+ * @param {Object} user {Boolean} 是否区分用户
190
+ */
191
+ pageGet(context, { instance, basis = 'fullPath', user = false }) {
192
+ return new Promise(resolve => {
193
+ resolve(
194
+ cloneDeep(
195
+ util.db
196
+ .get(
197
+ pathInit({
198
+ dbName: 'database',
199
+ path: `$page.${router.app.$route[basis]}.$data`,
200
+ user,
201
+ defaultValue: cloneDeep(instance.$data)
202
+ })
203
+ )
204
+ .value()
205
+ )
206
+ );
207
+ });
208
+ },
209
+ /**
210
+ * @description 清空页面快照
211
+ * @param {Object} context context
212
+ * @param {Object} basis {String} 页面区分依据 [ name | path | fullPath ]
213
+ * @param {Object} user {Boolean} 是否区分用户
214
+ */
215
+ pageClear(context, { basis = 'fullPath', user = false }) {
216
+ return new Promise(resolve => {
217
+ resolve(
218
+ util.db.get(
219
+ pathInit({
220
+ dbName: 'database',
221
+ path: `$page.${router.app.$route[basis]}.$data`,
222
+ user,
223
+ validator: () => false,
224
+ defaultValue: {}
225
+ })
226
+ )
227
+ );
228
+ });
229
+ }
230
+ }
231
+ };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * 多语言
3
+ * */
4
+ import Languages from '../../../../i18n/locale';
5
+ import Setting from '../../../../setting';
6
+ import util from '../../../../libs/util';
7
+ import { pathInit } from '../../../../store/modules/admin/modules/db';
8
+
9
+ const savedLocaleKey = 'i18n-locale';
10
+
11
+ export default {
12
+ namespaced: true,
13
+ state: {
14
+ locale: ''
15
+ },
16
+ actions: {
17
+ /**
18
+ * @description 获取当前语言
19
+ * */
20
+ getLocale({ state }) {
21
+ let locale;
22
+
23
+ const db = util.db.get(
24
+ pathInit({
25
+ dbName: 'database',
26
+ path: '',
27
+ user: true,
28
+ defaultValue: {}
29
+ })
30
+ );
31
+
32
+ const savedLocale = db.get(savedLocaleKey).value();
33
+
34
+ // 先判断本地存储是否已有语言选择
35
+ if (savedLocale) {
36
+ locale = savedLocale;
37
+ } else {
38
+ // 判断是否开启自动识别语言
39
+ if (Setting.i18n.auto) {
40
+ // 如果自动识别的语言,本地没有该语言包,则设置为默认语言
41
+ const navLang = navigator.language;
42
+ if (Languages[navLang]) {
43
+ locale = navLang;
44
+ } else {
45
+ locale = Setting.i18n.default;
46
+ }
47
+ } else {
48
+ locale = Setting.i18n.default;
49
+ }
50
+
51
+ // 将初次的语言保存在本地
52
+ db.set(savedLocaleKey, locale).write();
53
+ }
54
+ state.locale = locale;
55
+ },
56
+ /**
57
+ * @description 设置当前语言
58
+ * */
59
+ setLocale({ state }, { locale = Setting.i18n.default, vm }) {
60
+ const db = util.db.get(
61
+ pathInit({
62
+ dbName: 'database',
63
+ path: '',
64
+ user: true,
65
+ defaultValue: {}
66
+ })
67
+ );
68
+
69
+ // 将语言保存在本地
70
+ db.set(savedLocaleKey, locale).write();
71
+
72
+ // 判断是否刷新页面
73
+ if (Setting.i18n.refresh) {
74
+ location.reload();
75
+ } else {
76
+ // 设置当前语言
77
+ state.locale = locale;
78
+ // 设置 vue-i18n 的语言
79
+ vm.$i18n.locale = locale;
80
+ // 更新网页标题
81
+ util.title({
82
+ title: vm.$route.meta.title
83
+ });
84
+ }
85
+ }
86
+ }
87
+ };
@@ -0,0 +1,115 @@
1
+ /**
2
+ * 布局配置
3
+ * */
4
+ import screenfull from 'screenfull';
5
+
6
+ import Setting from '../../../../setting';
7
+
8
+ export default {
9
+ namespaced: true,
10
+ state: {
11
+ ...Setting.layout,
12
+ isMobile: false, // 是否为手机
13
+ isTablet: false, // 是否为平板
14
+ isDesktop: true, // 是否为桌面
15
+ isFullscreen: false, // 是否切换到了全屏
16
+ bodyHeight: 0,
17
+ waterMark: Setting.waterMark
18
+ },
19
+ mutations: {
20
+ /**
21
+ * @description 设置设备类型
22
+ * @param {Object} state vuex state
23
+ * @param {String} type 设备类型,可选值为 Mobile、Tablet、Desktop
24
+ */
25
+ setDevice(state, type) {
26
+ state.isMobile = false;
27
+ state.isTablet = false;
28
+ state.isDesktop = false;
29
+ state[`is${type}`] = true;
30
+ },
31
+ /**
32
+ * @description 修改 menuCollapse
33
+ * @param {Object} state vuex state
34
+ * @param {Boolean} collapse 折叠状态
35
+ * */
36
+ updateMenuCollapse(state, collapse) {
37
+ state.menuCollapse = collapse;
38
+ },
39
+ /**
40
+ * @description 设置全屏状态
41
+ * @param {Object} state vuex state
42
+ * @param {Boolean} isFullscreen vuex
43
+ * */
44
+ setFullscreen(state, isFullscreen) {
45
+ state.isFullscreen = isFullscreen;
46
+ },
47
+ /**
48
+ * @description 更改指定布局配置
49
+ * @param {Object} state vuex state
50
+ * @param {Object} key layout 名称,对应 Setting.layout
51
+ * @param {Object} value layout 值
52
+ * */
53
+ updateLayoutSetting(state, { key, value }) {
54
+ state[key] = value;
55
+ },
56
+ /**
57
+ * @description 更新页面高度
58
+ * */
59
+ setBodyHeight(state, height) {
60
+ state.bodyHeight = height;
61
+ },
62
+ /**
63
+ * @description 更新水印显示状态
64
+ * */
65
+ updateWaterMarkStatus(state, status) {
66
+ state.waterMark.show = status;
67
+ },
68
+ /**
69
+ * @description 更新水印文本
70
+ * */
71
+ updateWaterMarkText(state, text) {
72
+ state.waterMark.text = text;
73
+ },
74
+ /**
75
+ * @description 更新水印配置
76
+ * */
77
+ updateWaterMarkOptions(state, options) {
78
+ state.waterMark.options = options;
79
+ }
80
+ },
81
+ actions: {
82
+ /**
83
+ * @description 初始化监听全屏状态
84
+ */
85
+ listenFullscreen({ commit }) {
86
+ return new Promise(resolve => {
87
+ if (screenfull.enabled) {
88
+ screenfull.on('change', () => {
89
+ if (!screenfull.isFullscreen) {
90
+ commit('setFullscreen', false);
91
+ }
92
+ });
93
+ }
94
+ // end
95
+ resolve();
96
+ });
97
+ },
98
+ /**
99
+ * @description 切换全屏
100
+ */
101
+ toggleFullscreen({ commit }) {
102
+ return new Promise(resolve => {
103
+ if (screenfull.isFullscreen) {
104
+ screenfull.exit();
105
+ commit('setFullscreen', false);
106
+ } else {
107
+ screenfull.request();
108
+ commit('setFullscreen', true);
109
+ }
110
+ // end
111
+ resolve();
112
+ });
113
+ }
114
+ }
115
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 遮罩层
3
+ * */
4
+
5
+ export default {
6
+ namespaced: true,
7
+ state: {
8
+ count: 0, // 计数
9
+ enabled: true, // 启用
10
+ isLoading: false // 加载中
11
+ },
12
+ mutations: {
13
+ /**
14
+ * @description 开始加载
15
+ * @param {Object} state vuex state
16
+ */
17
+ start(state) {
18
+ state.count++;
19
+ state.isLoading = true;
20
+ },
21
+ /**
22
+ * @description 加载结束
23
+ * @param {Object} state vuex state
24
+ * */
25
+ end(state) {
26
+ state.count--;
27
+ state.isLoading = state.count > 0;
28
+ },
29
+ /**
30
+ * @description 禁用遮罩层
31
+ * @param {Object} state vuex state
32
+ * */
33
+ disable(state) {
34
+ state.enabled = false;
35
+ },
36
+ /**
37
+ * @description 启用遮罩层
38
+ * @param {Object} state vuex state
39
+ * */
40
+ enable(state) {
41
+ state.enabled = true;
42
+ }
43
+ }
44
+ };