Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复图片上传中的中文文案问题 #1136

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiled/alipay/demo/pages/ImageUpload/index.axml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<ant-container title="基本用法">
<ant-uploader
onChange="onChange"
onUpload="{{ onUpload ? onUpload : 'onUpload' }}" />
onUpload="{{ onUpload ? onUpload : 'onUpload' }}"
uploadingText="上传中……"
uploadfailedText="上传失败" />
</ant-container>
<ant-container title="初始值">
<ant-uploader
Expand Down
8 changes: 6 additions & 2 deletions compiled/alipay/src/ImageUpload/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@
a:if="{{ item.status === 'uploading' }}"
class="ant-image-upload-cover-loading">
<loading className="ant-image-upload-cover-loading-icon" />
<view class="ant-image-upload-cover-loading-text">上传中...</view>
<view class="ant-image-upload-cover-loading-text">
{{ uploadingText }}
</view>
</view>
<view
a:if="{{ item.status === 'error' }}"
class="ant-image-upload-cover-error">
<icon
className="ant-image-upload-cover-error-icon"
type="CloseCircleOutline" />
<view class="ant-image-upload-cover-error-text">上传失败</view>
<view class="ant-image-upload-cover-error-text">
{{ uploadfailedText }}
</view>
</view>
</view>

Expand Down
2 changes: 2 additions & 0 deletions compiled/alipay/src/ImageUpload/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ toc: 'content'
| defaultFileList | 文件列表初始值 | [File](#file)[] | [] |
| sourceType | 上传选择的来源。可选 `['album']`、`['camera']` 或 `['album', 'camera']` | string[] | ['album', 'camera'] |
| style | 样式 | string | - |
| uploadingText | 上传中提示文案 | string | '上传中……' |
| uploadfailedText | 上传失败提示文案 | string | '上传失败' |
| fileList | 文件列表(受控) | [File](#file)[] | - |
| imageMode | 图片缩放模式和裁剪模式。详见 [图片 mode 说明](https://opendocs.alipay.com/mini/component/image#mode) | string | scaleToFill |
| onBeforeUpload | 上传文件之前的钩子。参数为上传的文件列表,若返回 false 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传(resolve 传入修改后的 localFileList) | (localFileList: [localFile](#localfile)[]) => boolean \| Promise<[localFile](#localfile)[]> | - |
Expand Down
12 changes: 12 additions & 0 deletions compiled/alipay/src/ImageUpload/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ export interface IUploaderProps extends IBaseProps {
* @description 自定义上传方式,只在不存在action字段时生效
*/
onUpload?: (localFile: LocalFile) => Promise<string>;
/**
* @description 上传中文案
* @default "上传中……"
*/
uploadingText?: string;
/**
* @description 上传失败文案
* @default "上传失败"
*/
uploadfailedText?: string;
}

export const UploaderDefaultProps: Partial<IUploaderProps> = {
Expand All @@ -114,4 +124,6 @@ export const UploaderFunctionalProps: Partial<IUploaderProps> = {
onUpload: null,
onBeforeUpload: null,
onRemove: null,
uploadingText: '上传中',
uploadfailedText: '上传失败'
};
4 changes: 3 additions & 1 deletion compiled/wechat/demo/pages/ImageUpload/index.wxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<ant-container title="基本用法">
<ant-uploader
bind:change="onChange"
onUpload="{{ onUpload ? onUpload : 'onUpload' }}" />
onUpload="{{ onUpload ? onUpload : 'onUpload' }}"
uploadingText="上传中……"
uploadfailedText="上传失败" />
</ant-container>
<ant-container title="初始值">
<ant-uploader
Expand Down
2 changes: 2 additions & 0 deletions compiled/wechat/src/ImageUpload/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ toc: 'content'
| defaultFileList | 文件列表初始值 | [File](#file)[] | [] |
| sourceType | 上传选择的来源。可选 `['album']`、`['camera']` 或 `['album', 'camera']` | string[] | ['album', 'camera'] |
| style | 样式 | string | - |
| uploadingText | 上传中提示文案 | string | '上传中……' |
| uploadfailedText | 上传失败提示文案 | string | '上传失败' |
| fileList | 文件列表(受控) | [File](#file)[] | - |
| imageMode | 图片缩放模式和裁剪模式。详见 [图片 mode 说明](https://opendocs.alipay.com/mini/component/image#mode) | string | scaleToFill |
| onBeforeUpload | 上传文件之前的钩子。参数为上传的文件列表,若返回 false 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传(resolve 传入修改后的 localFileList) | (localFileList: [localFile](#localfile)[]) => boolean \| Promise<[localFile](#localfile)[]> | - |
Expand Down
8 changes: 6 additions & 2 deletions compiled/wechat/src/ImageUpload/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
wx:if="{{ item.status === 'uploading' }}"
class="ant-image-upload-cover-loading">
<loading className="ant-image-upload-cover-loading-icon" />
<view class="ant-image-upload-cover-loading-text">上传中...</view>
<view class="ant-image-upload-cover-loading-text">
{{ uploadingText }}
</view>
</view>
<view
wx:if="{{ item.status === 'error' }}"
class="ant-image-upload-cover-error">
<icon
className="ant-image-upload-cover-error-icon"
type="CloseCircleOutline" />
<view class="ant-image-upload-cover-error-text">上传失败</view>
<view class="ant-image-upload-cover-error-text">
{{ uploadfailedText }}
</view>
</view>
</view>

Expand Down
2 changes: 2 additions & 0 deletions compiled/wechat/src/ImageUpload/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export var UploaderFunctionalProps = {
onUpload: null,
onBeforeUpload: null,
onRemove: null,
uploadingText: '上传中',
uploadfailedText: '上传失败'
};
2 changes: 2 additions & 0 deletions demo/pages/ImageUpload/index.axml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default ({
<AntUploader
onChange="onChange"
onUpload={onUpload ? onUpload : 'onUpload'}
uploadingText="上传中……"
uploadfailedText="上传失败"
/>
</AntContainer>
<AntContainer title="初始值">
Expand Down
12 changes: 9 additions & 3 deletions src/ImageUpload/index.axml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { View, Slot, InternalData, TSXMLProps, Image } from 'tsxml';
import { IUploaderProps } from './props';

export default (
{ className, style, imageMode, maxCount }: TSXMLProps<IUploaderProps>,
{ className,
style,
imageMode,
maxCount,
uploadingText,
uploadfailedText
}: TSXMLProps<IUploaderProps>,
{ mixin }: InternalData
) => (
<View class={`ant-image-upload ${className || ''}`} style={style || ''}>
Expand All @@ -31,7 +37,7 @@ export default (
<View class="ant-image-upload-cover-loading">
<Loading className="ant-image-upload-cover-loading-icon" />
<View class="ant-image-upload-cover-loading-text">
上传中...
{uploadingText}
</View>
</View>
)}
Expand All @@ -42,7 +48,7 @@ export default (
type="CloseCircleOutline"
/>
<View class="ant-image-upload-cover-error-text">
上传失败
{uploadfailedText}
</View>
</View>
)}
Expand Down
2 changes: 2 additions & 0 deletions src/ImageUpload/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ toc: 'content'
| defaultFileList | 文件列表初始值 | [File](#file)[] | [] |
| sourceType | 上传选择的来源。可选 `['album']`、`['camera']` 或 `['album', 'camera']` | string[] | ['album', 'camera'] |
| style | 样式 | string | - |
| uploadingText | 上传中提示文案 | string | '上传中……' |
| uploadfailedText | 上传失败提示文案 | string | '上传失败' |
| fileList | 文件列表(受控) | [File](#file)[] | - |
| imageMode | 图片缩放模式和裁剪模式。详见 [图片 mode 说明](https://opendocs.alipay.com/mini/component/image#mode) | string | scaleToFill |
| onBeforeUpload | 上传文件之前的钩子。参数为上传的文件列表,若返回 false 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传(resolve 传入修改后的 localFileList) | (localFileList: [localFile](#localfile)[]) => boolean \| Promise<[localFile](#localfile)[]> | - |
Expand Down
12 changes: 12 additions & 0 deletions src/ImageUpload/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ export interface IUploaderProps extends IBaseProps {
* @description 自定义上传方式,只在不存在action字段时生效
*/
onUpload?: (localFile: LocalFile) => Promise<string>;
/**
* @description 上传中文案
* @default "上传中……"
*/
uploadingText?: string;
/**
* @description 上传失败文案
* @default "上传失败"
*/
uploadfailedText?: string;
}

export const UploaderDefaultProps: Partial<IUploaderProps> = {
Expand All @@ -114,4 +124,6 @@ export const UploaderFunctionalProps: Partial<IUploaderProps> = {
onUpload: null,
onBeforeUpload: null,
onRemove: null,
uploadingText: '上传中',
uploadfailedText: '上传失败'
};
Loading