Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/abstract.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const fileList = fileListRef
<n-upload
abstract
:default-file-list="fileList"
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
>
<n-button-group>
<n-button>Useless</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/basic.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:headers="{
'naive-info': 'hello!',
}"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/before-upload.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function beforeUpload(data: {

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
@before-upload="beforeUpload"
>
<n-button>Upload PNG</n-button>
Expand Down
20 changes: 18 additions & 2 deletions src/upload/demos/enUS/controlled.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const fileListRef = ref<UploadFileInfo[]>([
{
id: 'url-test',
name: 'URL Test',
url: '__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f',
status: 'finished'
},
{
Expand Down Expand Up @@ -67,6 +66,22 @@ function handleRemove(data: {
}
}

function handleFinish({
file,
event
}: {
file: UploadFileInfo
event?: ProgressEvent
}) {
const response = (event?.target as XMLHttpRequest).response
const res = JSON.parse(response)
message.success(response)
file.status = res.status
file.url = res.url
file.thumbnailUrl = res.thumbnailUrl
return file
}

function handleFileListChange() {
message.info('Yes, file-list changed.')
}
Expand All @@ -75,9 +90,10 @@ function handleFileListChange() {
<template>
<n-upload
v-model:file-list="fileList"
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
@update:file-list="handleFileListChange"
@change="handleUploadChange"
@finish="handleFinish"
@remove="handleRemove"
>
<n-button>Upload File</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/custom-download.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function handleCustomDownload(file: UploadFileInfo) {

<template>
<n-upload
action="http://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
show-download-button
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/custom-request.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function customRequest({

<template>
<n-upload
action="__HTTP__://naive-upload.free.beeceptor.com/"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:headers="{
'naive-info': 'hello!',
}"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/default-files.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultFileList: UploadFileInfo[] = [

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="defaultFileList"
>
<n-button>Upload File</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/download.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function handleDownload(file: UploadFileInfo) {

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
show-download-button
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/drag.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ArchiveOutline as ArchiveIcon } from '@vicons/ionicons5'
<n-upload
multiple
directory-dnd
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:max="5"
>
<n-upload-dragger>
Expand Down
4 changes: 2 additions & 2 deletions src/upload/demos/enUS/image-card-style.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ const previewFileList = ref<UploadFileInfo[]>([

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image-card"
>
Click to Upload
</n-upload>
<n-divider />
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="previewFileList"
list-type="image-card"
@preview="handlePreview"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/image-style.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function createThumbnailUrl(file: File | null): Promise<string> | undefined {

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
:create-thumbnail-url="createThumbnailUrl"
Expand Down
10 changes: 7 additions & 3 deletions src/upload/demos/enUS/on-finish.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ function handleFinish({
file: UploadFileInfo
event?: ProgressEvent
}) {
message.success((event?.target as XMLHttpRequest).response)
const response = (event?.target as XMLHttpRequest).response
const res = JSON.parse(response)
message.success(response)
const ext = file.name.split('.')[1]
file.name = `renamed.${ext}`
file.url = '__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f'
file.status = res.status
file.url = res.url
file.thumbnailUrl = res.thumbnailUrl
return file
}
</script>

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
@finish="handleFinish"
>
<n-button>Upload</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/enUS/submit-manually.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function handleClick() {
</n-button>
<n-upload
ref="upload"
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-upload="false"
multiple
@change="handleChange"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/abstract.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const fileList = fileListRef
<n-upload
abstract
:default-file-list="fileList"
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
>
<n-button-group>
<n-button>点我没用</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/basic.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:headers="{
'naive-info': 'hello!',
}"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/before-upload.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function beforeUpload(data: {

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
@before-upload="beforeUpload"
>
<n-button>上传 PNG 文件</n-button>
Expand Down
20 changes: 18 additions & 2 deletions src/upload/demos/zhCN/controlled.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const fileListRef = ref<UploadFileInfo[]>([
{
id: 'url-test',
name: 'URL 测试',
url: '__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f',
status: 'finished'
},
{
Expand Down Expand Up @@ -64,6 +63,22 @@ function handleRemove(data: {
}
}

function handleFinish({
file,
event
}: {
file: UploadFileInfo
event?: ProgressEvent
}) {
const response = (event?.target as XMLHttpRequest).response
const res = JSON.parse(response)
message.success(response)
file.status = res.status
file.url = res.url
file.thumbnailUrl = res.thumbnailUrl
return file
}

function handleFileListChange() {
message.info('是的,file-list 的值变了')
}
Expand All @@ -72,9 +87,10 @@ function handleFileListChange() {
<template>
<n-upload
v-model:file-list="fileList"
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
@change="handleUploadChange"
@remove="handleRemove"
@finish="handleFinish"
@update:file-list="handleFileListChange"
>
<n-button>上传文件</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/custom-download.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function handleCustomDownload(file: UploadFileInfo) {

<template>
<n-upload
action="http://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
show-download-button
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/custom-request.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function customRequest({

<template>
<n-upload
action="__HTTP__://naive-upload.free.beeceptor.com/"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:headers="{
'naive-info': 'hello!',
}"
Expand Down
8 changes: 5 additions & 3 deletions src/upload/demos/zhCN/debug.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ const directoryDndUndefined = ref(true)

<template>
Retry
<n-upload action="http://fake-api">
<n-upload
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
>
<n-button>Upload</n-button>
</n-upload>
Multiple <n-switch v-model:value="multiple" /><br>
Directory <n-switch v-model:value="directory" /><br>
DirectoryDnd <n-switch v-model:value="directoryDnd" /><br>
DirectoryDnd undefined <n-switch v-model:value="directoryDndUndefined" />
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:multiple="multiple"
:directory="directory"
:directory-dnd="directoryDndUndefined ? undefined : directoryDnd"
Expand All @@ -35,7 +37,7 @@ const directoryDndUndefined = ref(true)
<n-button>Upload</n-button>
</n-upload>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:multiple="multiple"
:directory="directory"
:directory-dnd="directoryDndUndefined ? undefined : directoryDnd"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/default-files.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultFileList: UploadFileInfo[] = [

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="defaultFileList"
>
<n-button>上传文件</n-button>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/download.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function handleDownload(file: UploadFileInfo) {

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
show-download-button
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/drag.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ArchiveOutline as ArchiveIcon } from '@vicons/ionicons5'
<n-upload
multiple
directory-dnd
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:max="5"
>
<n-upload-dragger>
Expand Down
4 changes: 2 additions & 2 deletions src/upload/demos/zhCN/image-card-style.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ const previewFileList = ref<UploadFileInfo[]>([

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image-card"
>
点击上传
</n-upload>
<n-divider />
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="previewFileList"
list-type="image-card"
@preview="handlePreview"
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/image-style.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function createThumbnailUrl(file: File | null): Promise<string> | undefined {

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
:create-thumbnail-url="createThumbnailUrl"
Expand Down
11 changes: 7 additions & 4 deletions src/upload/demos/zhCN/on-finish.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ function handleFinish({
file: UploadFileInfo
event?: ProgressEvent
}) {
console.log(event)
message.success((event?.target as XMLHttpRequest).response)
const response = (event?.target as XMLHttpRequest).response
const res = JSON.parse(response)
message.success(response)
const ext = file.name.split('.')[1]
file.name = `更名.${ext}`
file.url = '__HTTPS__://www.mocky.io/v2/5e4bafc63100007100d8b70f'
file.status = res.status
file.url = res.url
file.thumbnailUrl = res.thumbnailUrl
return file
}
</script>

<template>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
@finish="handleFinish"
>
<n-button>上传文件</n-button>
Expand Down
4 changes: 2 additions & 2 deletions src/upload/demos/zhCN/rtl-debug.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const fileList = ref<UploadFileInfo[]>([
<n-config-provider :rtl="rtlEnabled ? rtlStyles : undefined">
<n-space vertical>
<n-upload
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image-card"
>
点击上传
</n-upload>

<n-upload
action="http://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-file-list="fileList"
list-type="image"
>
Expand Down
2 changes: 1 addition & 1 deletion src/upload/demos/zhCN/submit-manually.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function handleClick() {
</n-button>
<n-upload
ref="upload"
action="__HTTP__://www.mocky.io/v2/5e4bafc63100007100d8b70f"
action="https://m1.apifoxmock.com/m1/7208154-6934252-default/api/upload"
:default-upload="false"
multiple
@change="handleChange"
Expand Down
Loading