|
@@ -33,12 +33,11 @@
|
|
|
:itemSize="itemSize"
|
|
:itemSize="itemSize"
|
|
|
:showDelete="showDelete"
|
|
:showDelete="showDelete"
|
|
|
:defaultSource="props.itemDefaultSource"
|
|
:defaultSource="props.itemDefaultSource"
|
|
|
-
|
|
|
|
|
>
|
|
>
|
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
|
<UploaderListItem
|
|
<UploaderListItem
|
|
|
:item="item"
|
|
:item="item"
|
|
|
- :showDelete="showDelete"
|
|
|
|
|
|
|
+ :showDelete="showDelete && !disabled && !readonly"
|
|
|
:isListStyle="props.listType === 'list'"
|
|
:isListStyle="props.listType === 'list'"
|
|
|
:style="itemStyle"
|
|
:style="itemStyle"
|
|
|
:imageStyle="itemImageStyle"
|
|
:imageStyle="itemImageStyle"
|
|
@@ -270,14 +269,6 @@ export interface UploaderInstance {
|
|
|
pick: () => void;
|
|
pick: () => void;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const isImageExt = [
|
|
|
|
|
- '.png',
|
|
|
|
|
- '.jpg',
|
|
|
|
|
- '.jpeg',
|
|
|
|
|
- '.bmp',
|
|
|
|
|
- '.webp',
|
|
|
|
|
-];
|
|
|
|
|
-
|
|
|
|
|
const toast = ref<ToastInstance>();
|
|
const toast = ref<ToastInstance>();
|
|
|
const dialog = ref<DialogAlertRoot>();
|
|
const dialog = ref<DialogAlertRoot>();
|
|
|
|
|
|
|
@@ -320,11 +311,8 @@ function onUploadPress() {
|
|
|
}[]) {
|
|
}[]) {
|
|
|
resolve(res.map((item) => {
|
|
resolve(res.map((item) => {
|
|
|
let isImage = typeof (item as any).type === 'string' ? (item as any).type.startsWith('image/') : false;
|
|
let isImage = typeof (item as any).type === 'string' ? (item as any).type.startsWith('image/') : false;
|
|
|
- for (const ext of isImageExt) {
|
|
|
|
|
- if (item.path.endsWith(ext)) {
|
|
|
|
|
- isImage = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!isImage) {
|
|
|
|
|
+ isImage = isImagePath(item.path);
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
filePath: item.path,
|
|
filePath: item.path,
|
|
@@ -436,6 +424,13 @@ function onUploadPress() {
|
|
|
}
|
|
}
|
|
|
//条目点击
|
|
//条目点击
|
|
|
function onItemPress(item: UploaderItem) {
|
|
function onItemPress(item: UploaderItem) {
|
|
|
|
|
+ if (props.readonly) {
|
|
|
|
|
+ props.onPreviewClick ?
|
|
|
|
|
+ props.onPreviewClick(item) :
|
|
|
|
|
+ onItemPreview(item); //默认预览
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (item.state === 'fail') {
|
|
if (item.state === 'fail') {
|
|
|
props.onRetryClick ?
|
|
props.onRetryClick ?
|
|
|
props.onRetryClick(item) :
|
|
props.onRetryClick(item) :
|
|
@@ -451,7 +446,7 @@ function onItemPress(item: UploaderItem) {
|
|
|
function onItemPreview(item: UploaderItem) {
|
|
function onItemPreview(item: UploaderItem) {
|
|
|
//判断后缀是不是图片
|
|
//判断后缀是不是图片
|
|
|
const previewPath = item.previewPath || item.uploadedPath || item.filePath;
|
|
const previewPath = item.previewPath || item.uploadedPath || item.filePath;
|
|
|
- if (item.isImage) {
|
|
|
|
|
|
|
+ if (item.isImage || isImagePath(previewPath)) {
|
|
|
uni.previewImage({
|
|
uni.previewImage({
|
|
|
urls: [
|
|
urls: [
|
|
|
previewPath
|
|
previewPath
|
|
@@ -465,6 +460,8 @@ function onItemPreview(item: UploaderItem) {
|
|
|
}
|
|
}
|
|
|
//条目删除点击
|
|
//条目删除点击
|
|
|
function onItemDeletePress(item: UploaderItem) {
|
|
function onItemDeletePress(item: UploaderItem) {
|
|
|
|
|
+ if (props.disabled || props.readonly)
|
|
|
|
|
+ return;
|
|
|
props.onDeleteClick ?
|
|
props.onDeleteClick ?
|
|
|
props.onDeleteClick(item).then(() => {
|
|
props.onDeleteClick(item).then(() => {
|
|
|
deleteListItem(item);
|
|
deleteListItem(item);
|
|
@@ -492,6 +489,9 @@ function deleteListItem(item: UploaderItem) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function isImagePath(path: string) {
|
|
|
|
|
+ return path.match(/\.(jpg|jpeg|png|gif|webp)$/) !== null;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始上传条目
|
|
//开始上传条目
|