@netang/quasar 0.0.52 → 0.0.54

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 (109) hide show
  1. package/_docs/docs/.vuepress/config.js +40 -0
  2. package/_docs/docs/.vuepress/configs/index.js +2 -0
  3. package/_docs/docs/.vuepress/configs/navbar/index.js +1 -0
  4. package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -0
  5. package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -0
  6. package/_docs/docs/.vuepress/configs/sidebar/zh.js +20 -0
  7. package/_docs/docs/.vuepress/public/css/index.css +3 -0
  8. package/_docs/docs/.vuepress/styles/index.scss +3 -0
  9. package/_docs/docs/components/field-table.md +55 -0
  10. package/_docs/docs/components/field-tree.md +1 -0
  11. package/_docs/docs/index.md +1 -0
  12. package/_docs/docs/utils/alert.md +1 -0
  13. package/_docs/docs/utils/confirm.md +1 -0
  14. package/_docs/package.json +11 -0
  15. package/components/column-title/index.vue +2 -2
  16. package/components/data/index.vue +20 -23
  17. package/components/dialog/index.vue +26 -12
  18. package/components/dialog-table/index.vue +4 -2
  19. package/components/dragger/index.vue +3 -2
  20. package/components/drawer/index.vue +16 -9
  21. package/components/editor-code/index.vue +12 -5
  22. package/components/empty/index.vue +16 -1
  23. package/components/field-date/index.vue +48 -36
  24. package/components/field-table/index.vue +69 -43
  25. package/components/field-text/index.vue +6 -2
  26. package/components/field-tree/index.vue +40 -22
  27. package/components/input-number/index.vue +5 -4
  28. package/components/list-menu/index.vue +14 -2
  29. package/components/power-page/index.vue +10 -0
  30. package/components/private/components/index.js +7 -2
  31. package/components/private/components/move-to-tree/index.vue +7 -3
  32. package/components/private/edit-power-data/index.vue +92 -52
  33. package/components/private/table-visible-columns-button/index.vue +6 -2
  34. package/components/render/index.vue +21 -7
  35. package/components/search/index.vue +30 -2
  36. package/components/search-item/index.vue +24 -8
  37. package/components/select/index.vue +5 -2
  38. package/components/splitter/index.vue +13 -9
  39. package/components/table/index.vue +32 -5
  40. package/components/table-pagination/index.vue +0 -1
  41. package/components/table-splitter/index.vue +22 -3
  42. package/components/table-summary/index.vue +10 -3
  43. package/components/thumbnail/index.vue +16 -6
  44. package/components/toolbar/index.vue +0 -2
  45. package/components/uploader/index.vue +5 -2
  46. package/components/uploader-query/index.vue +48 -27
  47. package/components/value-format/index.vue +19 -12
  48. package/configs/area3.js +1 -0
  49. package/docs/404.html +33 -0
  50. package/docs/assets/404.html-60b35caa.js +1 -0
  51. package/docs/assets/404.html-d1e63d77.js +1 -0
  52. package/docs/assets/alert.html-568d4e94.js +1 -0
  53. package/docs/assets/alert.html-f5dbc3e9.js +1 -0
  54. package/docs/assets/app-8c3ae4de.js +6 -0
  55. package/docs/assets/back-to-top-8efcbe56.svg +1 -0
  56. package/docs/assets/confirm.html-7a1566f6.js +1 -0
  57. package/docs/assets/confirm.html-96f1b004.js +1 -0
  58. package/docs/assets/field-table.html-68d610b0.js +1 -0
  59. package/docs/assets/field-table.html-86cc3511.js +1 -0
  60. package/docs/assets/field-tree.html-45410c3c.js +1 -0
  61. package/docs/assets/field-tree.html-c98ac993.js +1 -0
  62. package/docs/assets/framework-204010b2.js +5 -0
  63. package/docs/assets/index.html-1695dd7c.js +1 -0
  64. package/docs/assets/index.html-65a4aa67.js +1 -0
  65. package/docs/assets/style-ac5a9aa6.css +1 -0
  66. package/docs/components/field-table.html +33 -0
  67. package/docs/components/field-tree.html +33 -0
  68. package/docs/index.html +33 -0
  69. package/docs/utils/alert.html +33 -0
  70. package/docs/utils/confirm.html +33 -0
  71. package/package.json +11 -2
  72. package/store/index.js +3 -20
  73. package/utils/alert.js +3 -1
  74. package/utils/{$area.js → area.js} +27 -14
  75. package/utils/arr.js +6 -2
  76. package/utils/auth.js +140 -0
  77. package/utils/bus.js +1 -1
  78. package/utils/config.js +42 -15
  79. package/utils/{confrim.js → confirm.js} +1 -1
  80. package/utils/copy.js +18 -0
  81. package/utils/{$dialog.js → dialog.js} +7 -3
  82. package/utils/dict.js +5 -28
  83. package/utils/dictOptions.js +24 -0
  84. package/utils/{$form.js → form.js} +6 -2
  85. package/utils/getData.js +21 -9
  86. package/utils/getFile.js +11 -5
  87. package/utils/getImage.js +23 -12
  88. package/utils/getTime.js +9 -4
  89. package/utils/index.js +61 -0
  90. package/utils/loading.js +3 -1
  91. package/utils/notify.js +1 -1
  92. package/utils/{$power.js → power.js} +164 -118
  93. package/utils/previewImage.js +4 -2
  94. package/utils/price.js +12 -3
  95. package/utils/rule.js +13 -0
  96. package/utils/ruleValid.js +10 -0
  97. package/utils/{$search.js → search.js} +82 -51
  98. package/utils/{$table.js → table.js} +119 -87
  99. package/utils/timestamp.js +2 -2
  100. package/utils/toast.js +1 -1
  101. package/utils/{$tree.js → tree.js} +69 -46
  102. package/utils/uploader/qiniu.js +31 -15
  103. package/utils/{$uploader.js → uploader.js} +87 -56
  104. package/utils/useAuth.js +12 -5
  105. package/utils/useRouter.js +4 -4
  106. package/utils/useUploader.js +0 -5
  107. package/utils/$auth.js +0 -135
  108. package/utils/$rule.js +0 -17
  109. package/utils/http.js +0 -251
package/store/index.js CHANGED
@@ -19,28 +19,11 @@ export const statePower = ref({
19
19
  menus: [],
20
20
  })
21
21
 
22
- // 角色数据
23
- export const stateRole = ref({
24
- // 角色权限版本
25
- v: null,
26
- // all id
27
- all: {},
28
- // 页面
29
- urls: {},
30
- // 按钮
31
- btns: {},
32
- // 菜单
33
- menus: [],
34
- })
35
-
36
22
  // 时间差
37
23
  export const stateTimeDiff = ref(0)
38
24
 
39
- // loading
40
- export const stateLoading = ref(false)
41
-
42
25
  // 网络是否在线
43
- export const stateOnLine = ref(navigator.onLine)
26
+ // export const stateOnLine = ref(navigator.onLine)
44
27
 
45
- // 管理员信息状态
46
- export const stateAdminUserInfo = ref(initAuthStore())
28
+ // 用户信息状态
29
+ export const stateUserInfo = ref(initAuthStore())
package/utils/alert.js CHANGED
@@ -3,8 +3,10 @@ import { Dialog } from 'quasar'
3
3
  /**
4
4
  * 提示框
5
5
  */
6
- $n.alert = function(params) {
6
+ function alert(params) {
7
7
  return Dialog.create(Object.assign({
8
8
  title: '提示',
9
9
  }, params))
10
10
  }
11
+
12
+ export default alert
@@ -1,3 +1,11 @@
1
+ import $n_cloneDeep from 'lodash/cloneDeep'
2
+ import $n_get from 'lodash/get'
3
+ import $n_isValidArray from '@netang/utils/isValidArray'
4
+ import $n_indexOf from '@netang/utils/indexOf'
5
+ import $n_toTree from '@netang/utils/toTree'
6
+ import $n_trimString from '@netang/utils/trimString'
7
+ import $n_replaceAll from '@netang/utils/replaceAll'
8
+
1
9
  // 地址数据缓存
2
10
  let _areaData = null
3
11
 
@@ -5,7 +13,7 @@ let _areaData = null
5
13
  * 获取数据
6
14
  */
7
15
  function getData(level = 3, params) {
8
- return _getData(() => import('@/configs/area3'), level, params)
16
+ return _getData(() => import('../configs/area3'), level, params)
9
17
  }
10
18
  function _getData(areaData, level, params) {
11
19
  return new Promise(function(resolve) {
@@ -19,14 +27,14 @@ function _getData(areaData, level, params) {
19
27
  }, params)
20
28
 
21
29
  // 克隆树数据
22
- const treeData = $n.cloneDeep(_areaData)
30
+ const treeData = $n_cloneDeep(_areaData)
23
31
  const all = {}
24
32
  const rows = []
25
33
 
26
34
  // 是否有忽略省市区 id
27
- const isIgnore = $n.isValidArray(para.ignore)
35
+ const isIgnore = $n_isValidArray(para.ignore)
28
36
  function checkIgnore(id) {
29
- return isIgnore && $n.indexOf(para.ignore, id) > -1
37
+ return isIgnore && $n_indexOf(para.ignore, id) > -1
30
38
  }
31
39
 
32
40
  // 省
@@ -45,7 +53,7 @@ function _getData(areaData, level, params) {
45
53
  }
46
54
 
47
55
  // 市
48
- if (level > 1 && $n.isValidArray(item1[2])) {
56
+ if (level > 1 && $n_isValidArray(item1[2])) {
49
57
 
50
58
  for (let index2 = 0, len2 = item1[2].length; index2 < len2; index2++) {
51
59
  const item2 = item1[2][index2]
@@ -64,7 +72,7 @@ function _getData(areaData, level, params) {
64
72
  item1[2][index2] = all[item2[1]]
65
73
 
66
74
  // 区
67
- if (level > 2 && $n.isValidArray(item2[2])) {
75
+ if (level > 2 && $n_isValidArray(item2[2])) {
68
76
  for (let index3 = 0, len3 = item2[2].length; index3 < len3; index3++) {
69
77
  const item3 = item2[2][index3]
70
78
 
@@ -90,7 +98,7 @@ function _getData(areaData, level, params) {
90
98
  rows.push(all[key])
91
99
  }
92
100
 
93
- resolve($n.toTree({
101
+ resolve($n_toTree({
94
102
  data: rows,
95
103
  }))
96
104
  }
@@ -112,7 +120,7 @@ function _getData(areaData, level, params) {
112
120
  * 替换地址
113
121
  */
114
122
  function replaceArea(val) {
115
- val = $n.trimString(val)
123
+ val = $n_trimString(val)
116
124
  return val.replace(/直辖市/g, '')
117
125
  .replace(/市/g, '')
118
126
  .replace(/区/g, '')
@@ -166,7 +174,7 @@ async function getInfo(params) {
166
174
  const { attrs, nodes, tree } = areaData
167
175
 
168
176
  // 先通过地区编码来查找
169
- let data = $n.get(nodes, code)
177
+ let data = $n_get(nodes, code)
170
178
 
171
179
  // 如果没有找到, 则通过文字来查找
172
180
  if (! data) {
@@ -184,19 +192,19 @@ async function getInfo(params) {
184
192
  children: children1,
185
193
  } = item1
186
194
 
187
- const _text1 = $n.replaceAll(text1, '省', '')
195
+ const _text1 = $n_replaceAll(text1, '省', '')
188
196
 
189
197
  if (
190
198
  isAreaText ?
191
199
  (
192
200
  provinceText === text1
193
- || $n.replaceAll(provinceText, '省', '') === _text1
201
+ || $n_replaceAll(provinceText, '省', '') === _text1
194
202
  )
195
203
  : regionText.indexOf(_text1) > -1
196
204
  ) {
197
205
 
198
206
  // 获取市 start --------------------------------------------------
199
- if ($n.isValidArray(children1)) {
207
+ if ($n_isValidArray(children1)) {
200
208
 
201
209
  for (const item2 of children1) {
202
210
 
@@ -216,7 +224,7 @@ async function getInfo(params) {
216
224
  : regionText.indexOf(_text2) > -1
217
225
  ) {
218
226
  // 获取区 start --------------------------------------------------
219
- if ($n.isValidArray(children2)) {
227
+ if ($n_isValidArray(children2)) {
220
228
 
221
229
  if (areaText || regionText) {
222
230
 
@@ -379,9 +387,14 @@ async function getInfo(params) {
379
387
  return res
380
388
  }
381
389
 
382
- $n.$area = {
390
+ /**
391
+ * 地区
392
+ */
393
+ const area = {
383
394
  // 获取数据
384
395
  getData,
385
396
  // 获取详情
386
397
  getInfo,
387
398
  }
399
+
400
+ export default area
package/utils/arr.js CHANGED
@@ -1,14 +1,16 @@
1
+ import $n_isFunction from 'lodash/isFunction'
2
+
1
3
  /*
2
4
  * 操作数组
3
5
  */
4
- $n.arr = {
6
+ const arr = {
5
7
 
6
8
  /**
7
9
  * 增加
8
10
  */
9
11
  add(children, index, newItem) {
10
12
  if (Array.isArray(children)) {
11
- children.splice(index + 1, 0, $n.isFunction(newItem) ? newItem() : newItem)
13
+ children.splice(index + 1, 0, $n_isFunction(newItem) ? newItem() : newItem)
12
14
  }
13
15
  },
14
16
 
@@ -45,3 +47,5 @@ $n.arr = {
45
47
  }
46
48
  },
47
49
  }
50
+
51
+ export default arr
package/utils/auth.js ADDED
@@ -0,0 +1,140 @@
1
+ import $n_router from '@netang/vue-utils/router'
2
+
3
+ import $n_isValidObject from '@netang/utils/isValidObject'
4
+ import $n_cookie from '@netang/utils/cookie'
5
+
6
+ import { stateUserInfo } from '../store'
7
+ import { checkUserInfo } from './useAuth'
8
+
9
+ /**
10
+ * 是否登录
11
+ */
12
+ function isLogin() {
13
+ return stateUserInfo.value.isLogin
14
+ }
15
+
16
+ /**
17
+ * 登录后更新数据
18
+ */
19
+ function updateLogin(res) {
20
+
21
+ // 获取返回结果
22
+ const {
23
+ // 管理员 id
24
+ i,
25
+ // 鉴权认证
26
+ t,
27
+ // 用户基础信息
28
+ user_info,
29
+ } = res
30
+
31
+ // 更新用户信息
32
+ return _updateUserInfo({
33
+ id: i,
34
+ token: t,
35
+ info: $n_isValidObject(user_info) ? user_info : {},
36
+ })
37
+ }
38
+
39
+ /**
40
+ * 更新用户信息
41
+ */
42
+ function updateUserInfo(res) {
43
+ return _updateUserInfo(Object.assign(
44
+ {},
45
+ stateUserInfo.value,
46
+ res,
47
+ ))
48
+ }
49
+ function _updateUserInfo(res) {
50
+
51
+ // 验证用户信息
52
+ if (! checkUserInfo(res)) {
53
+
54
+ // 【调试模式】
55
+ // --------------------------------------------------
56
+ // #ifdef IS_DEBUG
57
+ console.error('【验证错误 _updateUserInfo】', res)
58
+ // #endif
59
+ // --------------------------------------------------
60
+
61
+ return false
62
+ }
63
+
64
+ // 设置已登录
65
+ res.isLogin = true
66
+
67
+ if (! $n_isValidObject(res.info)) {
68
+ res.info = {}
69
+ }
70
+
71
+ // 保存缓存(永久缓存)
72
+ $n_cookie.set('_tk', res, 0)
73
+
74
+ // 设置用户信息状态
75
+ stateUserInfo.value = res
76
+
77
+ return true
78
+ }
79
+
80
+ /**
81
+ * 获取用户信息
82
+ */
83
+ function getUserInfo() {
84
+ return stateUserInfo.value
85
+ }
86
+
87
+ /**
88
+ * 获取用户 id
89
+ */
90
+ function getAdminUserId() {
91
+ return isLogin() ? stateUserInfo.value.id : 0
92
+ }
93
+
94
+ /**
95
+ * 跳转登录页面
96
+ */
97
+ function pushLogin(query) {
98
+ $n_router.push({
99
+ path: 'login',
100
+ query,
101
+ })
102
+ }
103
+
104
+ /**
105
+ * 退出登录
106
+ */
107
+ function logout() {
108
+
109
+ // 删除管理员信息
110
+ $n_cookie.delete('_tk')
111
+
112
+ // 清空用户信息状态
113
+ stateUserInfo.value = {
114
+ id: 0,
115
+ isLogin: false,
116
+ info: {},
117
+ }
118
+ }
119
+
120
+ /**
121
+ * 鉴权业务
122
+ */
123
+ const auth = {
124
+ // 是否登录
125
+ isLogin,
126
+ // 登录后更新数据
127
+ updateLogin,
128
+ // 更新用户信息
129
+ updateUserInfo,
130
+ // 获取用户信息
131
+ getUserInfo,
132
+ // 获取管理员 id
133
+ getAdminUserId,
134
+ // 跳转登录页面
135
+ pushLogin,
136
+ // 退出登录
137
+ logout,
138
+ }
139
+
140
+ export default auth
package/utils/bus.js CHANGED
@@ -3,4 +3,4 @@ import { EventBus } from 'quasar'
3
3
  /**
4
4
  * 事件总线
5
5
  */
6
- $n.bus = new EventBus()
6
+ export default new EventBus()
package/utils/config.js CHANGED
@@ -1,22 +1,49 @@
1
- import configData from '@/configs/production.json'
1
+ import $n_get from 'lodash/get'
2
+ import $n_merge from 'lodash/merge'
2
3
 
3
- // 【开发模式】
4
- // --------------------------------------------------
5
- // #if IS_DEBUG && IS_DEV
6
- import configDataDev from '@/configs/development.json'
7
- $n.merge(configData, configDataDev)
8
- // #endif
4
+ // 配置
5
+ export const configs = {
6
+ // api 请求公共数据地址
7
+ apiDataUrl: '',
8
+ // api 文件请求地址
9
+ apiFileUrl: '',
10
+ // 用户配置
11
+ userConfig: {},
12
+ // 用户字典
13
+ userDict: {},
14
+ // 字典变量
15
+ dicts: {},
16
+ // 自定义路由
17
+ routers: {},
18
+ // 表格配置
19
+ tablesConfig: {},
20
+ // 对话框组件
21
+ dialogComponents: {},
22
+ // 是否开启人民币分转元
23
+ priceCentToYuan: false,
24
+ // 上传器
25
+ uploader: {
26
+ upload: {},
27
+ limit: {
28
+ image: {
29
+ maxSize: 10,
30
+ exts: [ 'jpg', 'png', 'gif' ]
31
+ }
32
+ },
33
+ },
34
+ }
9
35
 
10
- // 【测试模式】
11
- // --------------------------------------------------
12
- // #if IS_DEBUG && IS_TEST
13
- import configDataTest from '@/configs/testing.json'
14
- $n.merge(configData, configDataTest)
15
- // #endif
36
+ /**
37
+ * 配置处理器
38
+ * @param options
39
+ */
40
+ export function configHandler(options) {
41
+ $n_merge(configs, options)
42
+ }
16
43
 
17
44
  /**
18
45
  * 获取配置
19
46
  */
20
- $n.config = function(key = '', defaultValue = '') {
21
- return key ? $n.get(configData, key, defaultValue) : configData
47
+ export default function config(key = '', defaultValue = '') {
48
+ return key ? $n_get(configs.userConfig, key, defaultValue) : configs.userConfig
22
49
  }
@@ -3,7 +3,7 @@ import { Dialog } from 'quasar'
3
3
  /**
4
4
  * 确认框
5
5
  */
6
- $n.confirm = function(params) {
6
+ export default function confirm(params) {
7
7
  return Dialog.create(Object.assign({
8
8
  title: '提示',
9
9
  cancel: true,
package/utils/copy.js ADDED
@@ -0,0 +1,18 @@
1
+ import $n_copy from '@netang/utils/copy'
2
+
3
+ import $n_toast from './toast'
4
+
5
+ /**
6
+ * 复制
7
+ */
8
+ export default function copy(text, message) {
9
+ if (message) {
10
+ // 轻提示
11
+ $n_toast({
12
+ type: 'positive',
13
+ message,
14
+ })
15
+ }
16
+ // 复制
17
+ $n_copy(text)
18
+ }
@@ -1,3 +1,5 @@
1
+ import $n_has from 'lodash/has'
2
+
1
3
  import { inject } from 'vue'
2
4
  import { Dialog } from 'quasar'
3
5
 
@@ -10,9 +12,9 @@ import { NDialogKey } from './symbols'
10
12
  function create(params) {
11
13
  if (
12
14
  // 如果是路由组件
13
- $n.has(params, 'route')
15
+ $n_has(params, 'route')
14
16
  // 或自定义组件
15
- || $n.has(params, 'name')
17
+ || $n_has(params, 'name')
16
18
  ) {
17
19
  return Dialog.create({
18
20
  // 组件
@@ -35,9 +37,11 @@ function onInject() {
35
37
  /**
36
38
  * 对话框业务
37
39
  */
38
- $n.$dialog = {
40
+ const dialog = {
39
41
  // 创建对话框
40
42
  create,
41
43
  // 获取对话框注入数据
42
44
  inject: onInject,
43
45
  }
46
+
47
+ export default dialog
package/utils/dict.js CHANGED
@@ -1,21 +1,16 @@
1
- import dictData from '@/configs/dict.json'
1
+ import $n_has from 'lodash/has'
2
2
 
3
- /**
4
- * 数据字典
5
- */
6
-
7
- // 设置字典数据
8
- $n.dictData = dictData
3
+ import { configs } from './config'
9
4
 
10
5
  /**
11
6
  * 获取字典值对应的文字
12
7
  */
13
- $n.dict = function(key, value, defaultValue = '') {
8
+ export default function dict(key, value, defaultValue = '') {
14
9
  if (
15
10
  key
16
- && $n.has(dictData, key)
11
+ && $n_has(configs.userDict, key)
17
12
  ) {
18
- for (const item of dictData[key]) {
13
+ for (const item of configs.userDict[key]) {
19
14
  if (item[1] === value) {
20
15
  return item[0]
21
16
  }
@@ -24,21 +19,3 @@ $n.dict = function(key, value, defaultValue = '') {
24
19
 
25
20
  return defaultValue
26
21
  }
27
-
28
- $n.dictOptions = function(key, textKey = 'label', valueKey = 'value') {
29
-
30
- const lists = []
31
-
32
- const dictItem = $n.get(dictData, key, [])
33
-
34
- for (const item of dictItem) {
35
-
36
- const val = {}
37
- val[textKey] = item[0]
38
- val[valueKey] = item[1]
39
-
40
- lists.push(val)
41
- }
42
-
43
- return lists
44
- }
@@ -0,0 +1,24 @@
1
+ import $n_get from 'lodash/get'
2
+
3
+ import { configs } from './config'
4
+
5
+ /**
6
+ * 数据字典选项
7
+ */
8
+ export default function dictOptions(key, textKey = 'label', valueKey = 'value') {
9
+
10
+ const lists = []
11
+
12
+ const dictItem = $n_get(configs.userDict, key, [])
13
+
14
+ for (const item of dictItem) {
15
+
16
+ const val = {}
17
+ val[textKey] = item[0]
18
+ val[valueKey] = item[1]
19
+
20
+ lists.push(val)
21
+ }
22
+
23
+ return lists
24
+ }
@@ -1,5 +1,7 @@
1
1
  import { ref, provide, inject } from 'vue'
2
2
 
3
+ import $n_has from 'lodash/has'
4
+
3
5
  import { NPowerKey, NFormKey } from './symbols'
4
6
 
5
7
  /**
@@ -18,7 +20,7 @@ function create(params) {
18
20
  }, params)
19
21
 
20
22
  // 获取权限注入
21
- const $power = $n.has(params, '$power') ? params.$power : inject(NPowerKey)
23
+ const $power = $n_has(params, '$power') ? params.$power : inject(NPowerKey)
22
24
 
23
25
  // ==========【返回】=================================================================================================
24
26
 
@@ -46,7 +48,9 @@ function create(params) {
46
48
  /**
47
49
  * 业务表单
48
50
  */
49
- $n.$form = {
51
+ const form = {
50
52
  // 创建表单
51
53
  create,
52
54
  }
55
+
56
+ export default form
package/utils/getData.js CHANGED
@@ -1,19 +1,31 @@
1
1
  import { isRef } from 'vue'
2
2
 
3
+ import $n_isNil from 'lodash/isNil'
4
+ import $n_map from 'lodash/map'
5
+
6
+ import $n_http from '@netang/utils/http'
7
+
8
+ import { configs } from './config'
9
+
10
+ const {
11
+ // 请求公共数据地址
12
+ apiDataUrl,
13
+ } = configs
14
+
3
15
  /**
4
16
  * 获取公共数据
5
17
  */
6
- $n.getData = async function(url, pageStatus, emptyDescription, refValue) {
18
+ export default async function getData(url, pageStatus, emptyDescription, refValue) {
7
19
 
8
- const warn = $n.isNil(pageStatus) || ! isRef(pageStatus)
20
+ const warn = $n_isNil(pageStatus) || ! isRef(pageStatus)
9
21
 
10
22
  // 如果是数组, 说明需要同时请求多个地址
11
23
  // --------------------------------------------------
12
24
  if (Array.isArray(url)) {
13
25
 
14
- const result = await $n.http($n.map(url, function (item) {
26
+ const result = await $n_http($n_map(url, function (item) {
15
27
  return {
16
- url: $n.config('commonDataUrl') + item,
28
+ url: apiDataUrl + item,
17
29
  warn,
18
30
  }
19
31
  }))
@@ -25,7 +37,7 @@ $n.getData = async function(url, pageStatus, emptyDescription, refValue) {
25
37
  if (! warn) {
26
38
  pageStatus.value = false
27
39
  }
28
- if (! $n.isNil(emptyDescription) && isRef(emptyDescription)) {
40
+ if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
29
41
  emptyDescription.value = data.msg
30
42
  }
31
43
  return false
@@ -38,22 +50,22 @@ $n.getData = async function(url, pageStatus, emptyDescription, refValue) {
38
50
 
39
51
  // 单个请求
40
52
  // --------------------------------------------------
41
- const { status, data } = await $n.http({
42
- url: $n.config('commonDataUrl') + url,
53
+ const { status, data } = await $n_http({
54
+ url: apiDataUrl + url,
43
55
  warn,
44
56
  })
45
57
  if (! status) {
46
58
  if (! warn) {
47
59
  pageStatus.value = false
48
60
  }
49
- if (! $n.isNil(emptyDescription) && isRef(emptyDescription)) {
61
+ if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
50
62
  emptyDescription.value = data.msg
51
63
  }
52
64
  return false
53
65
  }
54
66
 
55
67
  // 直接设置 value
56
- if (! $n.isNil(refValue) && isRef(refValue)) {
68
+ if (! $n_isNil(refValue) && isRef(refValue)) {
57
69
  refValue.value = data
58
70
  }
59
71
 
package/utils/getFile.js CHANGED
@@ -1,27 +1,33 @@
1
+ import $n_isValidArray from '@netang/utils/isValidArray'
2
+ import $n_isValidString from '@netang/utils/isValidString'
3
+ import $n_slash from '@netang/utils/slash'
4
+
5
+ import { configs } from './config'
6
+
1
7
  /**
2
8
  * 获取文件
3
9
  */
4
- $n.getFile = function(src) {
10
+ export default function getFile(src) {
5
11
 
6
12
  if (src) {
7
13
 
8
14
  // 如果为数组, 则获取第一个
9
- if ($n.isValidArray(src)) {
15
+ if ($n_isValidArray(src)) {
10
16
  src = src[0]
11
17
  }
12
18
 
13
- if ($n.isValidString(src)) {
19
+ if ($n_isValidString(src)) {
14
20
 
15
21
  // http(s):// 或 data: 或 blob: 开头的地址
16
22
  if (/^(http(s)?:\/\/|data:|blob:)/i.test(src)) {
17
23
  return src
18
24
  }
19
25
 
20
- const uploaderConfig = $n.config('uploader.upload')
26
+ const uploaderConfig = configs.uploader.upload
21
27
  switch (uploaderConfig.type) {
22
28
  // 七牛云
23
29
  case 'qiniu':
24
- return $n.slash(uploaderConfig.domain, 'end', true) + src
30
+ return $n_slash(uploaderConfig.domain, 'end', true) + src
25
31
  }
26
32
  }
27
33
  }