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: 裁剪上传接口与uploadModal统一:url #2482

Merged
merged 1 commit into from
Jan 3, 2023
Merged

Conversation

yuhldr
Copy link
Contributor

@yuhldr yuhldr commented Jan 2, 2023

General

✏️ Mark the necessary items without changing the structure of the PR template.

  • Pull request template structure not broken

Type

ℹ️ What types of changes does your code introduce?

👉 Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

👉 Put an x in the boxes that apply.

  • My code follows the style guidelines of this project
  • Is the code format correct
  • Is the git submission information standard?
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@yuhldr
Copy link
Contributor Author

yuhldr commented Jan 2, 2023

上传组件接口是 url,如下,所以建议裁剪组件上传接口统一。

fileList.push(responseData.url);

@jinmao88 jinmao88 merged commit 61d6057 into vbenjs:main Jan 3, 2023
@billyshen26
Copy link
Contributor

billyshen26 commented Feb 3, 2023

emit('uploadSuccess', { source: previewSource.value, data: result.url });
应该改成
emit('uploadSuccess', { source: previewSource.value, data: result.data.url });
才能拿到数据吧。(感受是改出了bug)

当然这也要去后端返回结构里的一级结构就有url这个字段, 感觉不如之前的result.data来的灵活
另外 vue-vben-admin/src/components/Upload/src/UploadModal.vue
里面应该改成
fileList.push(responseData); 比较灵活

@jinmao88 @yuhldr 两位大佬看看

@yuhldr
Copy link
Contributor Author

yuhldr commented Feb 4, 2023

确实应该是 result.data.url,我这么写是因为我自己的内容里,上传接口这里也改了,我给忘了

return this.axiosInstance.request<T>({
...config,
method: 'POST',
data: formData,
headers: {
'Content-type': ContentTypeEnum.FORM_DATA,
// @ts-ignore
ignoreCancelToken: true,
},
});
}

不改的话,没有校验token,谁都能上传,容易被人利用

    return this.post({
      ...config,
      timeout: 10 * 60 * 1000,
      method: 'POST',
      data: formData,
      headers: {
        'Content-type': ContentTypeEnum.FORM_DATA,
        // @ts-ignore
        ignoreCancelToken: true,
      },
    });

@yuhldr
Copy link
Contributor Author

yuhldr commented Feb 4, 2023

@billyshen26 另外我个人认为, fileList.push(responseData); 比较灵活这个不合适,因为接口要有统一的 result 管理,用以区分各种报错,这个项目的其它接口也是这么做的,这也是为什么我把上传的接口也改成统一的 this.post (这个我忘了提交到这个项目了)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants