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