wl-design-mobile 0.8.4 → 0.8.5

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.
@@ -5,7 +5,16 @@
5
5
  <van-icon name="cross" class="close-icon" @click="handleClose"></van-icon>
6
6
  </div>
7
7
  <div class="modal-content" v-show="visible">
8
- <div class="preview-placeholder">
8
+ <!-- 图片预览 -->
9
+ <div v-if="isImage" class="image-preview">
10
+ <img :src="fileUrl" alt="图片预览" />
11
+ </div>
12
+ <!-- TXT 文本预览 -->
13
+ <div v-else-if="fileType === 'txt'" class="text-preview">
14
+ <pre>{{ textContent }}</pre>
15
+ </div>
16
+ <!-- 其他文件-->
17
+ <div v-else class="preview-placeholder">
9
18
  <van-icon name="description" size="64" color="#ccc"></van-icon>
10
19
  <p>{{ fileName }}</p>
11
20
  </div>
@@ -38,10 +47,26 @@ export default {
38
47
  default: '320px'
39
48
  }
40
49
  },
50
+ data() {
51
+ return {
52
+ textContent: '' // 存放 TXT 内容
53
+ }
54
+ },
41
55
  computed: {
42
56
  fileType() {
43
57
  if (!this.fileName) return ''
44
58
  return this.fileName.split('.').pop().toLowerCase()
59
+ },
60
+ isImage() {
61
+ const imgTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp']
62
+ return imgTypes.includes(this.fileType)
63
+ }
64
+ },
65
+ watch: {
66
+ visible(val) {
67
+ if (val) {
68
+ this.loadPreview()
69
+ }
45
70
  }
46
71
  },
47
72
  methods: {
@@ -66,6 +91,18 @@ export default {
66
91
  document.body.appendChild(link)
67
92
  link.click()
68
93
  document.body.removeChild(link)
94
+ },
95
+
96
+ // 加载 TXT 预览
97
+ async loadPreview() {
98
+ if (this.fileType === 'txt') {
99
+ try {
100
+ const res = await fetch(this.fileUrl)
101
+ this.textContent = await res.text()
102
+ } catch (e) {
103
+ this.textContent = '文本加载失败'
104
+ }
105
+ }
69
106
  }
70
107
  }
71
108
  }
@@ -129,4 +166,29 @@ export default {
129
166
  justify-content: flex-end;
130
167
  gap: 12px;
131
168
  }
169
+
170
+ /* 图片预览 */
171
+ .image-preview {
172
+ display: flex;
173
+ align-items: center;
174
+ justify-content: center;
175
+ }
176
+ .image-preview img {
177
+ max-width: 100%;
178
+ max-height: 60vh;
179
+ object-fit: contain;
180
+ border-radius: 4px;
181
+ }
182
+
183
+ /* TXT 预览 */
184
+ .text-preview {
185
+ padding: 10px;
186
+ background: #f7f8fa;
187
+ border-radius: 4px;
188
+ max-height: 60vh;
189
+ overflow-y: auto;
190
+ white-space: pre-wrap;
191
+ font-size: 14px;
192
+ line-height: 1.6;
193
+ }
132
194
  </style>
@@ -7,11 +7,11 @@
7
7
  <div class="detail-grid">
8
8
  <div class="detail-item">
9
9
  <span class="detail-label">{{ isApplyNode ? '发起时间:' : '审批时间:' }}</span>
10
- <span class="detail-value">{{ (isApplyNode ? nodeInfo.createTime : nodeInfo.auditTime) || '-' }}</span>
10
+ <span class="detail-value">{{ (isApplyNode ? nodeInfo.applyTime : nodeInfo.auditTime) || '-' }}</span>
11
11
  </div>
12
12
  <div class="detail-item">
13
13
  <span class="detail-label">{{ isApplyNode ? '发起人:' : '审批人:' }}</span>
14
- <span class="detail-value">{{ (isApplyNode ? nodeInfo.createUserName : nodeInfo.auditUserName) || '-' }}</span>
14
+ <span class="detail-value">{{ (isApplyNode ? nodeInfo.applyUserName : nodeInfo.auditUserName) || '-' }}</span>
15
15
  </div>
16
16
  </div>
17
17
  <div class="detail-grid" style="margin-top: 8px" v-if="!isApplyNode && (nodeInfo.startTime || nodeInfo.endTime)">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wl-design-mobile",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",