mali-applet-ui 1.1.67 → 1.1.69

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/env/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export function defineSwaggerConfig(config: Record<string, any>, defaultRootPath ?: string): Record<string, any>
1
2
  export function getEnvCode(mode: string): string
2
3
  export function getEnvName(mode: string): string
3
4
  export function getCustomName(custom: string): string
package/env/index.js CHANGED
@@ -11,6 +11,8 @@ const pack = require('../package.json')
11
11
 
12
12
  const apiURL = 'http://192.168.10.217:3000'
13
13
 
14
+ const envDir = 'env'
15
+
14
16
  function hasEmptyConf (key) {
15
17
  return !key || key === 'default'
16
18
  }
@@ -141,7 +143,8 @@ function initEnvScript (rootPath, confs) {
141
143
  uni_mpqiwei_build: 'npm run run_before && vue-cli-service uni-build',
142
144
  run_before: 'node script/run-before',
143
145
  clear: 'gulp clear_temp',
144
- 'generate:api': 'npx ts-codegen && eslint --fix --ext .js,.ts src/api'
146
+ 'generate:api': 'npx ts-codegen && eslint --fix --ext .js,.ts src/api',
147
+ 'get:api': 'npm run generate:api'
145
148
  }
146
149
 
147
150
  console.log('\n正在检查配置')
@@ -159,9 +162,9 @@ function initEnvScript (rootPath, confs) {
159
162
 
160
163
  // 生成配置文件
161
164
  const envName = `.env.${customName || 'default'}.${subName || 'default'}.${platform || 'default'}.${getEnvCode(mode)}`
162
- if (!fs.existsSync(path.resolve(rootPath, envName))) {
165
+ if (!fs.existsSync(path.resolve(rootPath, `${envDir}/${envName}`))) {
163
166
  console.log(`${pack.name} 生成配置文件 ${envName}`)
164
- fs.writeFileSync(path.resolve(rootPath, envName), `# ${[customName ? getCustomName(customName) : '', subName ? getSubModuleName(subName) : '', getEnvName(mode)].filter(v => v).map(v => v).join('-')}\n`)
167
+ fs.writeFileSync(path.resolve(rootPath, `${envDir}/${envName}`), `# ${[customName ? getCustomName(customName) : '', subName ? getSubModuleName(subName) : '', getEnvName(mode)].filter(v => v).map(v => v).join('-')}\n`)
165
168
  }
166
169
  })
167
170
  })
@@ -191,33 +194,81 @@ function initEnvScript (rootPath, confs) {
191
194
  }
192
195
 
193
196
  function parseEnv (rootPath) {
194
- const envConfig = {}
197
+ let envConfig = {}
198
+
195
199
  envConfig.VUE_APP_MODE = process.env.VUE_APP_MODE || 'prod'
196
200
  envConfig.VUE_APP_CUSTOM_MODULE = process.env.VUE_APP_CUSTOM_MODULE || 'default'
197
201
  envConfig.VUE_APP_SUB_MODULE = process.env.VUE_APP_SUB_MODULE || 'default'
198
202
  envConfig.VUE_APP_PLATFORM_NAME = process.env.VUE_APP_PLATFORM_NAME || 'default'
199
203
  envConfig.VUE_APP_PUBLISH_DATE = XEUtils.toDateString(new Date(), 'yyyyMMddHHmmss')
200
204
 
201
- const cName = `.env.${envConfig.VUE_APP_CUSTOM_MODULE}`
205
+ const gName = '.env'
206
+ const cName = `${gName}.${envConfig.VUE_APP_CUSTOM_MODULE}`
202
207
  const csName = `${cName}.${envConfig.VUE_APP_SUB_MODULE}`
203
208
  const cspName = `${csName}.${envConfig.VUE_APP_PLATFORM_NAME}`
204
209
  const envName = `${cspName}.${getEnvCode(envConfig.VUE_APP_MODE)}`
205
- const globalDev = parseEnvFile(rootPath, '.env')
206
- const cEnv = parseEnvFile(rootPath, cName)
207
- const csEnv = parseEnvFile(rootPath, csName)
208
- const cspEnv = parseEnvFile(rootPath, cspName)
209
- const envEnv = parseEnvFile(rootPath, envName)
210
- const localEnv = parseEnvFile(rootPath, `${envName}.local`)
210
+ const endFiles = [gName, cName, csName, cspName, envName, `${envName}.local`].map(fileName => `${envDir}/${fileName}`).concat([`${envName}.local`])
211
211
 
212
212
  console.log('\n读取配置文件:')
213
- const endFiles = ['.env', cName, csName, cspName, envName, `${envName}.local`]
213
+ if (fs.existsSync(path.resolve(rootPath, envDir))) {
214
+ endFiles.forEach(fileName => {
215
+ if (fs.existsSync(path.resolve(rootPath, fileName))) {
216
+ envConfig = Object.assign(envConfig, parseEnvFile(rootPath, fileName))
217
+ console.log(`${fileName}`)
218
+ }
219
+ })
220
+ } else {
221
+ console.log(`检测不到 Env 配置文件,路径:${envDir}/*`)
222
+ }
223
+
224
+ return envConfig
225
+ }
226
+
227
+ function parseSwaggerEnv (rootPath) {
228
+ let swaggerConfig = {
229
+ VUE_APP_SWAGGER_API_SPECS_PATHS: []
230
+ }
231
+
232
+ const gName = '.env'
233
+ const aName = `${gName}.api`
234
+ const endFiles = [aName, `${aName}.local`].map(fileName => `${envDir}/${fileName}`).concat([`${aName}.local`])
235
+
214
236
  endFiles.forEach(fileName => {
215
- if (fs.existsSync(path.resolve(rootPath, fileName))) {
216
- console.log(`${fileName}`)
217
- }
237
+ swaggerConfig = Object.assign(swaggerConfig, parseEnvFile(rootPath, fileName))
218
238
  })
219
239
 
220
- return Object.assign({}, globalDev, cEnv, csEnv, cspEnv, envEnv, localEnv, envConfig)
240
+ if (swaggerConfig.VUE_APP_SWAGGER_API_URL) {
241
+ swaggerConfig.VUE_APP_SWAGGER_API_SPECS_PATHS = (swaggerConfig.VUE_APP_SWAGGER_MODULES || 'default').split(',').map(name => {
242
+ return {
243
+ path: XEUtils.toFormatString(swaggerConfig.VUE_APP_SWAGGER_API_URL, { name }),
244
+ name
245
+ }
246
+ })
247
+ }
248
+
249
+ return swaggerConfig
250
+ }
251
+
252
+ function defineSwaggerConfig (defaultConfig = {}, defaultRootPath) {
253
+ const rootPath = defaultConfig.rootPath || defaultRootPath
254
+
255
+ if (!fs.existsSync(path.resolve(rootPath, `${envDir}/.env.api`))) {
256
+ console.log(`检测不到 Swagger 配置文件,路径:${envDir}/.env.api`)
257
+ }
258
+
259
+ const swaggerConfig = parseSwaggerEnv(rootPath)
260
+ return {
261
+ outputFolder: 'src/api',
262
+ apiSpecsPaths: swaggerConfig.VUE_APP_SWAGGER_API_SPECS_PATHS,
263
+ options: {
264
+ withComments: true,
265
+ typeWithPrefix: false,
266
+ backwardCompatible: false
267
+ },
268
+ importTopCode: '',
269
+ importHeaderCode: '/* eslint-disable no-use-before-define,camelcase */',
270
+ ...(defaultConfig || {})
271
+ }
221
272
  }
222
273
 
223
274
  function initEnv (rootPath) {
@@ -452,6 +503,7 @@ ${process.env.BUILD_USER ? `>> 操作人:${process.env.BUILD_USER}` : ''}
452
503
  <font color="comment">-自动化发版</font>`
453
504
  }
454
505
 
506
+ exports.defineSwaggerConfig = defineSwaggerConfig
455
507
  exports.getEnvCode = getEnvCode
456
508
  exports.getEnvName = getEnvName
457
509
  exports.getCustomName = getCustomName
@@ -470,6 +522,7 @@ exports.getBuildMsg = getBuildMsg
470
522
  exports.getBuildSuccessMsg = getBuildSuccessMsg
471
523
 
472
524
  module.exports = {
525
+ defineSwaggerConfig,
473
526
  getEnvCode,
474
527
  getEnvName,
475
528
  getCustomName,
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <text class="ml-icon" :class="[className || '', size ? `size-${size}` : '', status ? `ss-${status}` : '', name ? `${prefix}${name}` : '', {'is-roll': roll}]" :style="styles" @click="clickEvent" @tap="tapEvent"></text>
2
+ <text class="ml-icon" :class="[className || '', size ? `size-${size}` : '', status ? `ss-${status}` : '', name ? `${prefix}${name}` : '', {'is-roll': roll}]" :style="styles" @tap="clickEvent"></text>
3
3
  </template>
4
4
 
5
5
  <script>
@@ -31,11 +31,9 @@ export default {
31
31
  }
32
32
  },
33
33
  methods: {
34
- clickEvent (e) {
35
- },
36
- tapEvent () {
37
- this.$emit('tap', {})
38
- this.$emit('click', {})
34
+ clickEvent (evnt) {
35
+ this.$emit('tap', { $event: evnt })
36
+ this.$emit('click', { $event: evnt })
39
37
  }
40
38
  }
41
39
  }
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <view class="ml-tag" :class="[className || '', status ? `ss-${status}` : '', {'is-round': round}]" @tap="clickEvent">
3
+ <view class="ml-tag-content">
4
+ <slot>{{ content }}</slot>
5
+ </view>
6
+ <view class="ml-tag-close-warpper" v-if="closable" @tap="closeEvent">
7
+ <ml-icon class="ml-tag-close-btn" name="close"></ml-icon>
8
+ </view>
9
+ </view>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ name: 'MlTag',
15
+ options: {
16
+ virtualHost: true
17
+ },
18
+ props: {
19
+ status: String,
20
+ round: Boolean,
21
+ closable: Boolean,
22
+ content: String,
23
+ className: String
24
+ },
25
+ methods: {
26
+ closeEvent (evnt) {
27
+ evnt.stopPropagation()
28
+ this.$emit('close', { $event: evnt })
29
+ },
30
+ clickEvent (evnt) {
31
+ this.$emit('tap', { $event: evnt })
32
+ this.$emit('click', { $event: evnt })
33
+ }
34
+ }
35
+ }
36
+ </script>
37
+
38
+ <style lang="scss">
39
+ .ml-tag {
40
+ display: inline-flex;
41
+ padding: 4rpx 16rpx;
42
+ border: 2rpx solid #e8e8e8;
43
+ margin: 0 8rpx;
44
+ border-radius: 8rpx;
45
+ font-size: 24rpx;
46
+ &.is-round {
47
+ border-radius: $ml-border-radius;
48
+ }
49
+ &.ss-primary {
50
+ color: #fff;
51
+ background: $ml-theme-primary-color;
52
+ }
53
+ &.ss-success {
54
+ color: #fff;
55
+ background: $ml-theme-success-color;
56
+ }
57
+ &.ss-info {
58
+ background: #909399;
59
+ }
60
+ &.ss-warning {
61
+ color: #fff;
62
+ background: $ml-theme-warning-color;
63
+ }
64
+ &.ss-danger {
65
+ color: #fff;
66
+ background: $ml-theme-error-color;
67
+ }
68
+ &.ss-gray {
69
+ background: $ml-gray-color;
70
+ }
71
+ &.ss-blue {
72
+ color: #fff;
73
+ background: $ml-blue-color;
74
+ }
75
+ &.ss-green {
76
+ color: #fff;
77
+ background: $ml-green-color;
78
+ }
79
+ &.ss-pink {
80
+ color: #fff;
81
+ background: $ml-pink-color;
82
+ }
83
+ &.ss-red {
84
+ color: #fff;
85
+ background: $ml-red-color;
86
+ }
87
+ &.ss-orange {
88
+ color: #fff;
89
+ background: $ml-orange-color;
90
+ }
91
+ &.ss-purple {
92
+ color: #fff;
93
+ background: $ml-purple-color;
94
+ }
95
+ &.ss-white {
96
+ background: $ml-white-color;
97
+ }
98
+ .ml-tag-close-warpper {
99
+ flex-shrink: 0;
100
+ padding: 0 8rpx;
101
+ cursor: pointer;
102
+ }
103
+ .ml-tag-close-btn {
104
+ padding: 4rpx;
105
+ font-size: 24rpx;
106
+ &:hover {
107
+ color: #fff;
108
+ background: #909399;
109
+ border-radius: 50%;
110
+ }
111
+ }
112
+ }
113
+ </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="ml-text" :class="[className || '', status ? `ss-${status}` : '', {'is-underline': underline}]" @click="clickEvent" @tap="tapEvent">
2
+ <view class="ml-text" :class="[className || '', status ? `ss-${status}` : '', {'is-underline': underline}]" @tap="tapEvent">
3
3
  <view v-if="prefixIcon && prefixIcon !== 'none'" class="ml-text-left-icon">
4
4
  <ml-icon :className="prefixIcon"></ml-icon>
5
5
  </view>
@@ -44,9 +44,7 @@ export default {
44
44
  }
45
45
  },
46
46
  methods: {
47
- clickEvent () {
48
- },
49
- tapEvent () {
47
+ tapEvent (evnt) {
50
48
  if (this.url) {
51
49
  if (this.redirect) {
52
50
  uni.redirectTo({
@@ -58,8 +56,8 @@ export default {
58
56
  })
59
57
  }
60
58
  }
61
- this.$emit('tap', {})
62
- this.$emit('click', {})
59
+ this.$emit('tap', { $event: evnt })
60
+ this.$emit('click', { $event: evnt })
63
61
  }
64
62
  }
65
63
  }
@@ -8,7 +8,7 @@
8
8
  <ml-icon name="close" />
9
9
  </view>
10
10
  </view>
11
- <template v-if="!isFromReadonly && fileList.length < limit">
11
+ <template v-if="!isFromReadonly && !isLimit">
12
12
  <view v-if="hasForm" class="ml-upload-image-form-add-btn" @tap="chooseEvent">
13
13
  <ml-icon v-if="loading" name="loading" roll />
14
14
  <ml-icon v-else name="add-circle" />
@@ -26,7 +26,7 @@
26
26
  </view>
27
27
  <!-- 上传文件 -->
28
28
  <view v-else class="ml-upload-file-list">
29
- <template v-if="!isFromReadonly && fileList.length < limit">
29
+ <template v-if="!isFromReadonly && !isLimit">
30
30
  <view v-if="hasForm" class="ml-upload-file-form-add-btn" @tap="chooseEvent">
31
31
  <ml-icon v-if="loading" name="loading" roll />
32
32
  <ml-icon v-else name="add-circle" />
@@ -38,7 +38,7 @@
38
38
  <ml-icon v-else name="add" />
39
39
  </text>
40
40
  <text v-if="loading">上传中...</text>
41
- <text v-else>添加文件</text>
41
+ <text v-else>{{ uploadButtonText || '选择文件' }}</text>
42
42
  </view>
43
43
  </view>
44
44
  </template>
@@ -183,15 +183,18 @@ export default {
183
183
  type: Boolean,
184
184
  default: false
185
185
  },
186
- limit: {
186
+ limit: Number,
187
+ limitCount: Number,
188
+ limitSize: {
187
189
  type: Number,
188
- default: 9
190
+ default: 20480
189
191
  },
190
192
  className: String,
191
193
  mediatype: {
192
194
  type: String,
193
195
  default: 'all'
194
196
  },
197
+ uploadButtonText: String,
195
198
  params: {
196
199
  type: Object,
197
200
  default: () => ({})
@@ -238,6 +241,15 @@ export default {
238
241
  hasForm () {
239
242
  return !!this.form
240
243
  },
244
+ limitFileLen () {
245
+ return this.limitCount || this.limit || 9
246
+ },
247
+ isLimit () {
248
+ if (this.multiple) {
249
+ return this.fileList.length >= this.limitFileLen
250
+ }
251
+ return this.fileList.length >= 1
252
+ },
241
253
  isFromReadonly () {
242
254
  if (XEUtils.isBoolean(this.readonly)) {
243
255
  return this.readonly
@@ -510,7 +522,7 @@ export default {
510
522
  chooseMethod({
511
523
  sizeType: this.sizeType,
512
524
  sourceType: this.sourceType,
513
- count: this.limit - this.fileList.length,
525
+ count: this.limitFileLen - this.fileList.length,
514
526
  quality: this.imageQuality
515
527
  }).then(res => {
516
528
  const { tempFiles } = res
@@ -543,7 +555,7 @@ export default {
543
555
  }
544
556
  })
545
557
  ).then(list => {
546
- this.fileList = [...this.fileList, ...list].slice(-this.limit)
558
+ this.fileList = [...this.fileList, ...list].slice(-this.limitFileLen)
547
559
  this.isModelUpdate = true
548
560
  this.updateModel()
549
561
  this.loading = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.1.67",
3
+ "version": "1.1.69",
4
4
  "description": "码里UI-小程序组件库(vue2)",
5
5
  "files": [
6
6
  "lib",