@netang/quasar 0.0.20
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.
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/components/column-title/index.vue +32 -0
- package/components/dialog/components/index.js +6 -0
- package/components/dialog/components/move-to-tree/index.vue +150 -0
- package/components/dialog/index.vue +330 -0
- package/components/dialog-table/index.vue +92 -0
- package/components/dragger/index.vue +202 -0
- package/components/drawer/index.vue +262 -0
- package/components/field-date/index.vue +844 -0
- package/components/field-date/methods.js +100 -0
- package/components/field-table/index.vue +468 -0
- package/components/field-text/index.vue +167 -0
- package/components/field-tree/index.vue +435 -0
- package/components/input-number/index.vue +324 -0
- package/components/input-number/number.js +67 -0
- package/components/input-price-cent/index.vue +213 -0
- package/components/input-price-yuan/index.vue +179 -0
- package/components/layout/index.vue +119 -0
- package/components/list-menu/index.vue +137 -0
- package/components/list-menu-item/index.vue +79 -0
- package/components/power-data/index.vue +667 -0
- package/components/search/index.vue +176 -0
- package/components/search-item/index.vue +219 -0
- package/components/select/index.vue +71 -0
- package/components/select-filter/index.vue +75 -0
- package/components/table/index.vue +347 -0
- package/components/table-column-fixed/index.vue +68 -0
- package/components/table-pagination/index.vue +83 -0
- package/components/table-summary/index.vue +91 -0
- package/components/thumbnail/index.vue +87 -0
- package/components/toolbar/container.vue +31 -0
- package/components/toolbar/index.vue +405 -0
- package/components/uploader/index.vue +157 -0
- package/components/uploader-query/index.vue +731 -0
- package/package.json +21 -0
- package/sass/common.scss +165 -0
- package/sass/index.scss +14 -0
- package/sass/line.scss +39 -0
- package/sass/quasar/btn.scss +46 -0
- package/sass/quasar/common.scss +3 -0
- package/sass/quasar/dialog.scss +7 -0
- package/sass/quasar/drawer.scss +6 -0
- package/sass/quasar/field.scss +210 -0
- package/sass/quasar/loading.scss +6 -0
- package/sass/quasar/menu.scss +8 -0
- package/sass/quasar/table.scss +112 -0
- package/sass/quasar/toolbar.scss +22 -0
- package/store/index.js +32 -0
- package/utils/$area.js +387 -0
- package/utils/$auth.js +135 -0
- package/utils/$dialog.js +43 -0
- package/utils/$role.js +807 -0
- package/utils/$rule.js +17 -0
- package/utils/$search.js +336 -0
- package/utils/$table.js +802 -0
- package/utils/$tree.js +620 -0
- package/utils/$uploader.js +1029 -0
- package/utils/alert.js +10 -0
- package/utils/bus.js +6 -0
- package/utils/config.js +22 -0
- package/utils/confrim.js +11 -0
- package/utils/dict.js +44 -0
- package/utils/getData.js +61 -0
- package/utils/getFile.js +30 -0
- package/utils/getImage.js +136 -0
- package/utils/getTime.js +94 -0
- package/utils/http.js +251 -0
- package/utils/loading.js +13 -0
- package/utils/notify.js +13 -0
- package/utils/previewImage.js +8 -0
- package/utils/symbols.js +3 -0
- package/utils/timestamp.js +18 -0
- package/utils/toast.js +13 -0
- package/utils/uploader/aliyun.js +6 -0
- package/utils/uploader/local.js +8 -0
- package/utils/uploader/qiniu.js +311 -0
- package/utils/useAuth.js +26 -0
- package/utils/useRouter.js +36 -0
- package/utils/useUploader.js +58 -0
package/utils/symbols.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { stateTimeDiff } from '../store'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取当前时间戳
|
|
5
|
+
*/
|
|
6
|
+
utils.timestamp = function(isMicro = false) {
|
|
7
|
+
|
|
8
|
+
// 获取当前时间戳(毫秒)
|
|
9
|
+
const nowTime = new Date().getTime()
|
|
10
|
+
|
|
11
|
+
// 如果是毫秒
|
|
12
|
+
if (isMicro) {
|
|
13
|
+
return nowTime - (stateTimeDiff.value * 1000)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 否则是秒
|
|
17
|
+
return Math.floor(nowTime / 1000) - stateTimeDiff.value
|
|
18
|
+
}
|
package/utils/toast.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import {
|
|
2
|
+
// 文件请求地址
|
|
3
|
+
REQUEST_URL,
|
|
4
|
+
UPLOAD_STATUS,
|
|
5
|
+
} from '../useUploader'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 获取七牛云上传 token
|
|
9
|
+
*/
|
|
10
|
+
async function getQiniuToken(bucket = 'public') {
|
|
11
|
+
|
|
12
|
+
// 请求数据
|
|
13
|
+
const { status, data } = await utils.http({
|
|
14
|
+
url: REQUEST_URL + 'get_qiniu_token',
|
|
15
|
+
data: {
|
|
16
|
+
bucket,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// 【生产模式】
|
|
20
|
+
// --------------------------------------------------
|
|
21
|
+
// #ifdef IS_PRO
|
|
22
|
+
// 开启缓存
|
|
23
|
+
cache: 'qiniu_token_' + bucket,
|
|
24
|
+
// 缓存时间(6 小时)
|
|
25
|
+
cacheTime: 21600000,
|
|
26
|
+
// #endif
|
|
27
|
+
// --------------------------------------------------
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// 如果成功
|
|
31
|
+
if (! status) {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return data
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 七牛云上传
|
|
40
|
+
*/
|
|
41
|
+
export default async function ({ waitUploadFileLists, uploadFileLists, checkFileError, setFileSuccess, setFileFail }) {
|
|
42
|
+
|
|
43
|
+
// 获取七牛云上传 token
|
|
44
|
+
const token = await getQiniuToken()
|
|
45
|
+
if (! token) {
|
|
46
|
+
for (const fileItem of waitUploadFileLists) {
|
|
47
|
+
setFileFail(fileItem, '上传失败')
|
|
48
|
+
}
|
|
49
|
+
utils.toast({
|
|
50
|
+
message: '获取上传参数失败',
|
|
51
|
+
})
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 批量上传
|
|
56
|
+
for (const fileItem of waitUploadFileLists) {
|
|
57
|
+
// 上传单个文件
|
|
58
|
+
uploadFileItem(fileItem, token)
|
|
59
|
+
.finally()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 上传单个文件
|
|
64
|
+
*/
|
|
65
|
+
async function uploadFileItem(fileItem, token) {
|
|
66
|
+
|
|
67
|
+
// 设置文件状态
|
|
68
|
+
fileItem.status = UPLOAD_STATUS.uploading
|
|
69
|
+
|
|
70
|
+
// 请求上传文件到七牛云
|
|
71
|
+
const { status, data: resUpload } = await utils.http({
|
|
72
|
+
// 上传地址
|
|
73
|
+
url: 'https://upload.qiniup.com/',
|
|
74
|
+
// 数据
|
|
75
|
+
data: {
|
|
76
|
+
// 七牛云上传 token
|
|
77
|
+
token,
|
|
78
|
+
// 文件
|
|
79
|
+
file: fileItem.file,
|
|
80
|
+
// 自定义文件 key
|
|
81
|
+
key: fileItem.hash,
|
|
82
|
+
},
|
|
83
|
+
// 关闭错误提醒
|
|
84
|
+
warn: false,
|
|
85
|
+
// 关闭检查结果 code
|
|
86
|
+
checkCode: false,
|
|
87
|
+
// 不包含头部鉴权认证
|
|
88
|
+
token: false,
|
|
89
|
+
// 开启上传
|
|
90
|
+
upload: true,
|
|
91
|
+
// 取消请求
|
|
92
|
+
onCancel(cancel) {
|
|
93
|
+
// 设置中断上传
|
|
94
|
+
fileItem.abort = function(msg) {
|
|
95
|
+
cancel(utils.isValidString(msg) ? msg : '已取消')
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
// 监听上传进度
|
|
99
|
+
onUploadProgress(percent) {
|
|
100
|
+
// 设置上传进度
|
|
101
|
+
fileItem.progress = percent
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// 如果请求失败
|
|
106
|
+
if (! status) {
|
|
107
|
+
// 设置文件上传失败
|
|
108
|
+
setFileFail(fileItem, resUpload.msg)
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 如果检查七牛回调成功
|
|
113
|
+
const query = await checkQiniuCallback(resUpload, fileItem)
|
|
114
|
+
if (! query) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 请求 - 上传文件至 cdn
|
|
119
|
+
const { status: statusCallback, data: resCallback } = await utils.http({
|
|
120
|
+
url: REQUEST_URL + 'upload_cdn_callback',
|
|
121
|
+
data: query,
|
|
122
|
+
// 关闭错误提示
|
|
123
|
+
warn: false,
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
// 请求失败
|
|
127
|
+
if (! statusCallback) {
|
|
128
|
+
// 设置文件上传失败
|
|
129
|
+
setFileFail(fileItem, resCallback.msg || '上传失败')
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 设置文件上传成功
|
|
134
|
+
setFileSuccess(fileItem)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 检查七牛回调成功
|
|
139
|
+
*/
|
|
140
|
+
function checkQiniuCallback(res, fileItem) {
|
|
141
|
+
|
|
142
|
+
// 如果文件被删除
|
|
143
|
+
if (_.findIndex(uploadFileLists.value, { hash: fileItem.hash }) === -1) {
|
|
144
|
+
// 设置文件上传失败
|
|
145
|
+
setFileFail(fileItem, '上传失败')
|
|
146
|
+
return false
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 返回示例
|
|
150
|
+
// ------------------------------
|
|
151
|
+
// format: "null"
|
|
152
|
+
// width: null
|
|
153
|
+
// height: null
|
|
154
|
+
// key: "d038dce5892840636b2c1f6d241f33ad"
|
|
155
|
+
// hash: "lrYGlELBAgN9OgKV_i5gbHOdZMvt"
|
|
156
|
+
// orientation: null
|
|
157
|
+
// size: 6620454
|
|
158
|
+
// aduration: 57.258005
|
|
159
|
+
// vwidth: 1280
|
|
160
|
+
// vheight: 720
|
|
161
|
+
// vrotate: null
|
|
162
|
+
// vduration: 57.291992
|
|
163
|
+
|
|
164
|
+
const {
|
|
165
|
+
format,
|
|
166
|
+
width,
|
|
167
|
+
height,
|
|
168
|
+
key,
|
|
169
|
+
orientation,
|
|
170
|
+
size,
|
|
171
|
+
aduration,
|
|
172
|
+
vwidth,
|
|
173
|
+
vheight,
|
|
174
|
+
vrotate,
|
|
175
|
+
vduration,
|
|
176
|
+
} = res
|
|
177
|
+
|
|
178
|
+
const query = {
|
|
179
|
+
// 标题
|
|
180
|
+
title: fileItem.title,
|
|
181
|
+
// 类型(1:文件,2:图片,3:视频,4:音频)
|
|
182
|
+
type: 0,
|
|
183
|
+
// hash
|
|
184
|
+
hash: key,
|
|
185
|
+
// 文件大小
|
|
186
|
+
size,
|
|
187
|
+
// 后缀
|
|
188
|
+
ext: fileItem.ext,
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// json 信息
|
|
192
|
+
const json = {}
|
|
193
|
+
|
|
194
|
+
// 【1】先判断是否为视频(有时长 && 有宽 && 有高 && 时长 > 0, 则为视频)
|
|
195
|
+
if (vduration && vwidth && vheight) {
|
|
196
|
+
|
|
197
|
+
// 类型(3:视频)
|
|
198
|
+
query.type = 3
|
|
199
|
+
|
|
200
|
+
// 视频旋转角度
|
|
201
|
+
// vrotate: 无 ==> 1: 手机右横屏(宽高不变)
|
|
202
|
+
// vrotate: 90 ==> 2: 手机垂直(宽高反转)
|
|
203
|
+
// vrotate: 180 ==> 3: 手机左横屏(宽高不变)
|
|
204
|
+
// vrotate: 270 ==> 4: 手机倒过来垂直(宽高反转)
|
|
205
|
+
const rotates = {
|
|
206
|
+
90: 2,
|
|
207
|
+
180: 3,
|
|
208
|
+
270: 4,
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 设置 json 信息
|
|
212
|
+
Object.assign(json, {
|
|
213
|
+
w: vwidth,
|
|
214
|
+
h: vheight,
|
|
215
|
+
d: vduration,
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
if (_.has(rotates, vrotate)) {
|
|
219
|
+
json.o = rotates[vrotate]
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 【2】再判断是否为音频(有音频时长 && 无视频时长 && 音频时长 > 0, 则为音频)
|
|
223
|
+
} else if (aduration && ! vduration) {
|
|
224
|
+
|
|
225
|
+
// 类型(4:音频)
|
|
226
|
+
query.type = 4
|
|
227
|
+
|
|
228
|
+
// 设置 json 信息
|
|
229
|
+
json.d = aduration
|
|
230
|
+
|
|
231
|
+
// 【3】再判断是否为图片(有宽 && 有高 && 大小 < 20M, 为图片)
|
|
232
|
+
} else if (width && height) {
|
|
233
|
+
|
|
234
|
+
// 类型(2:图片)
|
|
235
|
+
query.type = 2
|
|
236
|
+
|
|
237
|
+
// 图片后缀名
|
|
238
|
+
query.ext = format === 'jpeg' ? 'jpg' : format
|
|
239
|
+
|
|
240
|
+
// 如果大小 < 20M, 则为可用图片
|
|
241
|
+
if (size < 20971520) {
|
|
242
|
+
|
|
243
|
+
// 设置 json 数据
|
|
244
|
+
json.w = width
|
|
245
|
+
json.h = height
|
|
246
|
+
|
|
247
|
+
// 图片垂直角度
|
|
248
|
+
const orientations = {
|
|
249
|
+
// 【1】相机原始位置(宽高不变)
|
|
250
|
+
// 'top-left': 1,
|
|
251
|
+
// 【2】等于 1 的垂直镜像(几乎无用)(宽高不变)
|
|
252
|
+
'top-right': 2,
|
|
253
|
+
// 【3】旋转 180度(宽高不变)
|
|
254
|
+
'bottom-right': 3,
|
|
255
|
+
// 【4】等于 3 的垂直镜像(几乎无用)(宽高不变)
|
|
256
|
+
'bottom-left': 4,
|
|
257
|
+
// 【5】等于 8 的水平镜像(几乎无用)(宽高反转)
|
|
258
|
+
'left-top': 5,
|
|
259
|
+
// 【6】旋转 90 度(宽高反转)
|
|
260
|
+
'right-top': 6,
|
|
261
|
+
// 【7】等于 8 的垂直镜像(几乎无用)(宽高反转)
|
|
262
|
+
'right-bottom': 7,
|
|
263
|
+
// 【8】旋转 270 度(宽高反转)
|
|
264
|
+
'left-bottom': 8,
|
|
265
|
+
}
|
|
266
|
+
if (orientation && _.isString(orientation)) {
|
|
267
|
+
const key = _.trim(orientation).toLowerCase()
|
|
268
|
+
if (_.has(orientations, key)) {
|
|
269
|
+
json.o = orientations[key]
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// 否则为类型为文件
|
|
274
|
+
} else {
|
|
275
|
+
// 检查文件错误
|
|
276
|
+
const errMsg = checkFileError(query)
|
|
277
|
+
if (errMsg) {
|
|
278
|
+
// 设置文件上传失败
|
|
279
|
+
setFileFail(fileItem, errMsg)
|
|
280
|
+
return false
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// 类型(1:文件)
|
|
284
|
+
query.type = 1
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// 否则为类型为文件
|
|
288
|
+
} else {
|
|
289
|
+
// 类型(1:文件)
|
|
290
|
+
query.type = 1
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 检查文件错误
|
|
294
|
+
const errMsg = checkFileError(query)
|
|
295
|
+
if (errMsg) {
|
|
296
|
+
// 设置文件上传失败
|
|
297
|
+
setFileFail(fileItem, errMsg)
|
|
298
|
+
return false
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// json 信息
|
|
302
|
+
query.json = json
|
|
303
|
+
|
|
304
|
+
// 设置文件
|
|
305
|
+
Object.assign(fileItem, query)
|
|
306
|
+
|
|
307
|
+
return Object.assign({}, query, {
|
|
308
|
+
json: utils.isValidObject(json) ? JSON.stringify(json) : ''
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
}
|
package/utils/useAuth.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 初始化鉴权状态
|
|
3
|
+
*/
|
|
4
|
+
export function initAuthStore() {
|
|
5
|
+
// 获取管理员信息缓存
|
|
6
|
+
const cache = utils.cookie.get('_tk')
|
|
7
|
+
return checkAdminUserInfo(cache) ? cache : {
|
|
8
|
+
id: 0,
|
|
9
|
+
isLogin: false,
|
|
10
|
+
info: {},
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 验证管理员信息
|
|
16
|
+
*/
|
|
17
|
+
export function checkAdminUserInfo(data) {
|
|
18
|
+
return ! utils.validator(data, {
|
|
19
|
+
// 管理员 id
|
|
20
|
+
id: 'required|natural_no_zero',
|
|
21
|
+
// 登录 token
|
|
22
|
+
token: 'required|string',
|
|
23
|
+
// 管理员信息
|
|
24
|
+
info: 'required',
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import routers from '@/router/routers'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取路由
|
|
5
|
+
*/
|
|
6
|
+
export function getRouters(mainRouter, errorRouter) {
|
|
7
|
+
|
|
8
|
+
const routes = [
|
|
9
|
+
mainRouter
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
utils.forIn(routers, function(item, key) {
|
|
13
|
+
|
|
14
|
+
// 如果没有 meta
|
|
15
|
+
if (! _.has(item, 'meta')) {
|
|
16
|
+
item.meta = {}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// path
|
|
20
|
+
item.path = utils.slash(key, 'start', true)
|
|
21
|
+
|
|
22
|
+
// 如果是单独路由
|
|
23
|
+
if (_.get(item.meta, 'parent') === false) {
|
|
24
|
+
routes.push(item)
|
|
25
|
+
|
|
26
|
+
// 否则为框架页面
|
|
27
|
+
} else {
|
|
28
|
+
mainRouter.children.push(item)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// 添加错误路由
|
|
33
|
+
routes.push(errorRouter)
|
|
34
|
+
|
|
35
|
+
return routes
|
|
36
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件请求地址
|
|
3
|
+
*/
|
|
4
|
+
export const REQUEST_URL = 'system/file/index?call='
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 文件类型映射
|
|
8
|
+
*/
|
|
9
|
+
export const FilE_TYPE = {
|
|
10
|
+
file: 1,
|
|
11
|
+
image: 2,
|
|
12
|
+
video: 3,
|
|
13
|
+
audio: 4,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 文件名称映射
|
|
18
|
+
*/
|
|
19
|
+
export const FilE_NAME = {
|
|
20
|
+
1: '文件',
|
|
21
|
+
2: '图片',
|
|
22
|
+
3: '视频',
|
|
23
|
+
4: '音频',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 上传状态
|
|
28
|
+
*/
|
|
29
|
+
export const UPLOAD_STATUS = {
|
|
30
|
+
// 等待上传中
|
|
31
|
+
waiting: 1,
|
|
32
|
+
// 检查 hash 中
|
|
33
|
+
hashChecking: 2,
|
|
34
|
+
// 检查 hash 完成
|
|
35
|
+
hashChecked: 3,
|
|
36
|
+
// 检查是否存在服务器中
|
|
37
|
+
existChecking: 4,
|
|
38
|
+
// 检查是否存在服务器完成
|
|
39
|
+
existChecked: 5,
|
|
40
|
+
// 上传中
|
|
41
|
+
uploading: 6,
|
|
42
|
+
// 上传完成
|
|
43
|
+
success: 7,
|
|
44
|
+
// 上传失败
|
|
45
|
+
fail: 8,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 上传器
|
|
50
|
+
*/
|
|
51
|
+
export const UPLOADERS = {
|
|
52
|
+
// 本地上传
|
|
53
|
+
'local': ()=>import('./uploader/local'),
|
|
54
|
+
// 七牛云上传
|
|
55
|
+
'qiniu': ()=>import('./uploader/qiniu'),
|
|
56
|
+
// 阿里云上传
|
|
57
|
+
'aliyun': ()=>import('./uploader/aliyun'),
|
|
58
|
+
}
|