mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
refactor(upload): instance misses openOpenFileDialog
method
This commit is contained in:
parent
ec61bbf906
commit
26fc49f233
@ -10,7 +10,7 @@
|
||||
### Fixes
|
||||
|
||||
- Fix `n-alert` `contentTextColor` and `titleTextColor` type theme variable not working, closes [#1495](https://github.com/TuSimple/naive-ui/issues/1495).
|
||||
- Fix `n-upload` export `openFileDialog` method.
|
||||
- Fix `n-upload` instance misses `openOpenFileDialog` method.
|
||||
|
||||
### i18n
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
### Fixes
|
||||
|
||||
- 修复 `n-alert` `contentTextColor` 和 `titleTextColor` 的类型主题变量不起作用,关闭 [#1495](https://github.com/TuSimple/naive-ui/issues/1495)
|
||||
- 修复 `n-upload` 未导出 `openFileDialog` 方法
|
||||
- 修复 `n-upload` 实例缺少 `openOpenFileDialog` 方法
|
||||
|
||||
### i18n
|
||||
|
||||
|
@ -76,7 +76,7 @@ abstract
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| submit | `(fileId?: string \| number)` | Submit all files with pending status. |
|
||||
| openFileDialog | `() => void` | Open the file dialog window. |
|
||||
| openOpenFileDialog | `() => void` | Open the file dialog window. |
|
||||
|
||||
### Upload Slots
|
||||
|
||||
|
@ -76,7 +76,7 @@ retry-debug
|
||||
| 名称 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| submit | `(fileId?: string \| number)` | 提交当前所有处于 pending 状态的文件 |
|
||||
| openFileDialog | `() => void` | 打开文件选择对话框 |
|
||||
| openOpenFileDialog | `() => void` | 打开文件选择对话框 |
|
||||
|
||||
### Upload Slots
|
||||
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
XhrHandlers,
|
||||
FileInfo,
|
||||
DoChange,
|
||||
UploadInst,
|
||||
UploadInternalInst,
|
||||
FuncOrRecordOrUndef,
|
||||
OnFinish,
|
||||
@ -301,7 +302,7 @@ export default defineComponent({
|
||||
controlledFileListRef,
|
||||
uncontrolledFileListRef
|
||||
)
|
||||
function openFileDialog (): void {
|
||||
function openOpenFileDialog (): void {
|
||||
inputElRef.value?.click()
|
||||
}
|
||||
function handleFileInputChange (e: Event): void {
|
||||
@ -509,7 +510,7 @@ export default defineComponent({
|
||||
getFileThumbnailUrl,
|
||||
listTypeRef: toRef(props, 'listType'),
|
||||
dragOverRef,
|
||||
openFileDialog,
|
||||
openOpenFileDialog,
|
||||
draggerInsideRef,
|
||||
handleFileAddition,
|
||||
mergedDisabledRef: formItem.mergedDisabledRef,
|
||||
@ -518,6 +519,12 @@ export default defineComponent({
|
||||
abstractRef: toRef(props, 'abstract'),
|
||||
cssVarsRef
|
||||
})
|
||||
|
||||
const exposedMethods: UploadInst = {
|
||||
submit,
|
||||
openOpenFileDialog
|
||||
}
|
||||
|
||||
return {
|
||||
mergedClsPrefix: mergedClsPrefixRef,
|
||||
draggerInsideRef,
|
||||
@ -525,9 +532,8 @@ export default defineComponent({
|
||||
mergedTheme: themeRef,
|
||||
dragOver: dragOverRef,
|
||||
handleFileInputChange,
|
||||
submit,
|
||||
openFileDialog,
|
||||
cssVars: cssVarsRef
|
||||
cssVars: cssVarsRef,
|
||||
...exposedMethods
|
||||
}
|
||||
},
|
||||
render () {
|
||||
|
@ -25,7 +25,7 @@ export default defineComponent({
|
||||
maxReachedRef,
|
||||
listTypeRef,
|
||||
dragOverRef,
|
||||
openFileDialog,
|
||||
openOpenFileDialog,
|
||||
draggerInsideRef,
|
||||
handleFileAddition
|
||||
} = NUpload
|
||||
@ -36,7 +36,7 @@ export default defineComponent({
|
||||
|
||||
function handleTriggerClick (): void {
|
||||
if (mergedDisabledRef.value || maxReachedRef.value) return
|
||||
openFileDialog()
|
||||
openOpenFileDialog()
|
||||
}
|
||||
function handleTriggerDragOver (e: DragEvent): void {
|
||||
e.preventDefault()
|
||||
|
@ -78,7 +78,7 @@ export interface UploadInjection {
|
||||
submit: (fileId?: string) => void
|
||||
getFileThumbnailUrl: (file: FileInfo) => Promise<string>
|
||||
handleFileAddition: (files: FileList | null, e?: Event) => void
|
||||
openFileDialog: () => void
|
||||
openOpenFileDialog: () => void
|
||||
}
|
||||
|
||||
export const uploadInjectionKey: InjectionKey<UploadInjection> =
|
||||
@ -92,6 +92,7 @@ export interface XhrHandlers {
|
||||
}
|
||||
|
||||
export interface UploadInst {
|
||||
openOpenFileDialog: () => void
|
||||
submit: () => void
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user