tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
16.25k stars 1.68k forks source link

[N-Image] Download in preview modal is wrong when url is local Url generated by URL.createObjectURL #6394

Open simonliang20 opened 1 month ago

simonliang20 commented 1 month ago

Describe the bug

  1. I have a url generated by URL.createObjectURL
  2. N-Image show and priview is no problem
  3. But preview and click download is wrong,such as:

image

  1. And the result is open new tab, such as: image

  2. I check the source code related download,the problem in here:

image

Steps to reproduce

i upload the detail code link by codesandbox

Link to minimal reproduction

https://codesandbox.io/p/sandbox/beautiful-cache-5jfrvt?workspaceId=be254d71-098e-48a3-a6ef-3612a43349d7

System Info

System:
    OS: macOS 13.4.1
    CPU: (8) x64 Apple M1 Pro
    Memory: 62.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 10.21.0 - ~/.nvm/versions/node/v10.21.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v10.21.0/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v10.21.0/bin/npm
  Browsers:
    Chrome: 129.0.6668.70
    Edge: 129.0.2792.52
    Safari: 16.5.1
  npmPackages:
    naive-ui: ^2.39.0 => 2.38.2 
    vue: ^3.4.29 => 3.4.31

Used Package Manager

npm

Validations

MrWangCQ commented 4 days ago

how to solve

simonliang20 commented 4 days ago

how to solve

now i rewrite toolbar:

const renderToolbar = ({ nodes }: ImageRenderToolbarProps) => {
  return [
    nodes.rotateCounterclockwise,
    nodes.rotateClockwise,
    nodes.resizeToOriginalSize,
    nodes.zoomOut,
    nodes.zoomIn,
    h('div', {
      style: {
        marginTop: '5px'
      },
      onClickCapture: (e) => {
        e.stopPropagation()
        // rewrite download
        saveAs(pic.value, '111.svg')
      }
    }, nodes.download),
    nodes.close,
  ]
}

:render-toolbar="renderToolbar"