wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.46k stars 1.23k forks source link

Clipboard Image Paste Issue with mac App #3342

Open b1win0y opened 8 months ago

b1win0y commented 8 months ago

Description

mac m2 The program I compiled through the command wails build -platform=windows/amd64 can directly copy the image with control+v. However, programs compiled through wails build cannot directly paste images through control+v.

To Reproduce

create project command:wails init -n myproject -t vue

main.js

` import {createApp} from 'vue' import App from './App.vue' import './style.css'; import naive from 'naive-ui'

const app = createApp(App) app.use(naive) app.mount('#app') `

App.vue

`

` The program I compiled through the command wails build -platform=windows/amd64 can directly copy the image with control+v.

image

However, programs compiled through wails build cannot directly paste images through control+v.

How can I solve this problem?

Expected behaviour

I want Mac compiled programs to be able to paste pictures directly through control+v

Screenshots

No response

Attempted Fixes

No response

System Details

➜  myproject wails doctor      

          Wails Doctor          

# Wails
Version | v2.8.0

# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                       |
| Version      | 14.2.1                                                                                                                      |
| ID           | 23C71                                                                                                                       |
| Go Version   | go1.21.4                                                                                                                    |
| Platform     | darwin                                                                                                                      |
| Architecture | arm64                                                                                                                       |
| CPU          | Apple M2 Pro                                                                                                                |
| GPU          | Chipset Model: Apple M2 Pro Type: GPU Bus: Built-In Total Number of Cores: 16 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory       | 32GB                                                                                                                        |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version   |
| Xcode command line tools  | N/A          | Installed | 2405      |
| Nodejs                    | N/A          | Installed | 20.5.1    |
| npm                       | N/A          | Installed | 9.8.0     |
| *Xcode                    | N/A          | Available |           |
| *upx                      | N/A          | Installed | upx 4.1.0 |
| *nsis                     | N/A          | Installed | v3.09     |
└──────────────────── * - Optional Dependency ─────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - Xcode: Available at https://apps.apple.com/us/app/xcode/id497799835

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

No response

leaanthony commented 8 months ago

Try both build options again, passing in -v 2 for verbose logging and see if you can pick up any differences between the 2 builds.

b1win0y commented 8 months ago

Try both build options again, passing in -v 2 for verbose logging and see if you can pick up any differences between the 2 builds.再次尝试这两个生成选项,传入 -v 2 详细日志记录,看看是否可以发现 2 个生成之间的任何差异。

mac

`➜ myproject wails build -v 2
Wails CLI v2.8.0

Build Options

Platform(s) | darwin/arm64
Compiler | /opt/homebrew/opt/go/libexec/bin/go
Skip Bindings | false
Build Mode | production
Devtools | false
Frontend Directory | /Users/turtle/Documents/study/code/go/scanner/jgui/myproject/frontend Obfuscated | false
Skip Frontend | false
Compress | false
Package | true
Clean Bin Dir | false
LDFlags |
Tags | []
Race Detector | false

Building target: darwin/arm64

• Generating bindings: INFO
Done. • Installing frontend dependencies: INFO Install command: 'npm install' Skipping npm install Done. • Compiling frontend: INFO Build command: 'npm run build'

> frontend@0.0.0 build
> vite build

vite v3.2.10 building for production...
transforming...
✓ 2516 modules transformed.
rendering chunks...
dist/assets/nunito-v16-latin-regular.06f3af3f.woff2   18.53 KiB
dist/index.html                                       0.36 KiB
dist/assets/index.81a5c9f5.css                        20.31 KiB / gzip: 3.46 KiB
dist/assets/index.d1a85496.js                         1612.03 KiB / gzip: 434.31 KiB

(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

Done. • Compiling application: INFO Build command: go build -tags desktop,wv2runtime.download,production -ldflags "-w -s" -o /Users/turtle/Documents/study/code/go/scanner/jgui/myproject/build/bin/myproject • Environment:%!(EXTRA string=PATH=/opt/homebrew/opt/go/libexec/bin:/Users/turtle/go/bin:/Users/turtle/go/bin:/opt/homebrew/opt/ruby@3.0/bin:/Users/turtle/.pyenv/shims:/usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin:/Users/turtle/.jenv/shims:/Users/turtle/.jenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/turtle/.cargo/bin:/Users/turtle/.orbstack/bin:/opt/metasploit-framework/bin:/usr/local/mysql/bin TERM=xterm-256color COMMAND_MODE=unix2003 LOGNAME=turtle XPC_SERVICE_NAME=0 CFBundleIdentifier=com.jetbrains.goland SHELL=/bin/zsh SECURITYSESSIONID=186b0 GOPATH=/Users/turtle/go USER=turtle GOROOT=/opt/homebrew/opt/go/libexec LaunchInstanceID=F960EA41-290E-46A8-9EA0-E596DAEC2F5E TMPDIR=/var/folders/mt/5prsw9810n39v86h49l1l8q80000gn/T/ TERMINAL_EMULATOR=JetBrains-JediTerm GO111MODULE=on SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lYh5cuabEd/Listeners XPC_FLAGS=0x0 TERM_SESSION_ID=76808f36-a7a7-47ba-a415-4d01c3dfc9e9 CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34 LC_CTYPE=UTF-8 IDEA_INITIAL_DIRECTORY=/ HOME=/Users/turtle SHLVL=1 PWD=/Users/turtle/Documents/study/code/go/scanner/jgui/myproject OLDPWD=/Users/turtle/Documents/study/code/go/scanner/jgui/myproject HOMEBREW_PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles HOMEBREW_PREFIX=/opt/homebrew HOMEBREW_CELLAR=/opt/homebrew/Cellar HOMEBREW_REPOSITORY=/opt/homebrew MANPATH=/opt/homebrew/share/man:: INFOPATH=/opt/homebrew/share/info: ZSH=/Users/turtle/.oh-my-zsh PAGER=less LESS=-R LSCOLORS=Gxfxcxdxbxegedabagacad LS_COLORS=di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43 AUTOJUMP_SOURCED=1 AUTOJUMP_ERROR_PATH=/Users/turtle/Library/autojump/errors.log JENV_SHELL=zsh JENV_LOADED=1 JAVAHOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home =/Users/turtle/go/bin/wails CGO_CFLAGS=-mmacosx-version-min=10.13 CGO_CXXFLAGS=-I/Users/turtle/Documents/study/code/go/scanner/jgui/myproject/build CGO_ENABLED=1 CGO_LDFLAGS=-framework UniformTypeIdentifiers -mmacosx-version-min=10.13 GOOS=darwin GOARCH=arm64)Done. • Packaging application: Done. Built '/Users/turtle/Documents/study/code/go/scanner/jgui/myproject/build/bin/myproject.app/Contents/MacOS/myproject' in 5.642s.

♥ If Wails is useful to you or your company, please consider sponsoring the project: https://github.com/sponsors/leaanthony `

windows

`➜ myproject wails build -platform=windows/amd64 -v 2 Wails CLI v2.8.0

Build Options

Platform(s) | windows/amd64
Compiler | /opt/homebrew/opt/go/libexec/bin/go
Skip Bindings | false
Build Mode | production
Devtools | false
Frontend Directory | /Users/turtle/Documents/study/code/go/scanner/jgui/myproject/frontend Obfuscated | false
Skip Frontend | false
Compress | false
Package | true
Clean Bin Dir | false
LDFlags |
Tags | []
Race Detector | false

Building target: windows/amd64

• Generating bindings: INFO
Done. • Installing frontend dependencies: INFO Install command: 'npm install' Skipping npm install Done. • Compiling frontend: INFO Build command: 'npm run build'

> frontend@0.0.0 build
> vite build

vite v3.2.10 building for production...
transforming...
✓ 2516 modules transformed.
rendering chunks...
dist/assets/nunito-v16-latin-regular.06f3af3f.woff2   18.53 KiB
dist/index.html                                       0.36 KiB
dist/assets/index.81a5c9f5.css                        20.31 KiB / gzip: 3.46 KiB
dist/assets/index.d1a85496.js                         1612.03 KiB / gzip: 434.31 KiB

(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

Done. • Generating application assets: Done. • Compiling application: INFO Build command: go build -tags desktop,wv2runtime.download,production -ldflags "-w -s -H windowsgui" -o /Users/turtle/Documents/study/code/go/scanner/jgui/myproject/build/bin/myproject.exe • Environment:%!(EXTRA string=PATH=/opt/homebrew/opt/go/libexec/bin:/Users/turtle/go/bin:/Users/turtle/go/bin:/opt/homebrew/opt/ruby@3.0/bin:/Users/turtle/.pyenv/shims:/usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin:/Users/turtle/.jenv/shims:/Users/turtle/.jenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/turtle/.cargo/bin:/Users/turtle/.orbstack/bin:/opt/metasploit-framework/bin:/usr/local/mysql/bin TERM=xterm-256color COMMAND_MODE=unix2003 LOGNAME=turtle XPC_SERVICE_NAME=0 CFBundleIdentifier=com.jetbrains.goland SHELL=/bin/zsh SECURITYSESSIONID=186b0 GOPATH=/Users/turtle/go USER=turtle GOROOT=/opt/homebrew/opt/go/libexec LaunchInstanceID=F960EA41-290E-46A8-9EA0-E596DAEC2F5E TMPDIR=/var/folders/mt/5prsw9810n39v86h49l1l8q80000gn/T/ TERMINAL_EMULATOR=JetBrains-JediTerm GO111MODULE=on SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lYh5cuabEd/Listeners XPC_FLAGS=0x0 TERM_SESSION_ID=46406bd2-b37d-4b22-807c-982c37a5888a CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34 LC_CTYPE=UTF-8 IDEA_INITIAL_DIRECTORY=/ HOME=/Users/turtle SHLVL=1 PWD=/Users/turtle/Documents/study/code/go/scanner/jgui/myproject OLDPWD=/Users/turtle/Documents/study/code/go/scanner/jgui/myproject HOMEBREW_PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles HOMEBREW_PREFIX=/opt/homebrew HOMEBREW_CELLAR=/opt/homebrew/Cellar HOMEBREW_REPOSITORY=/opt/homebrew MANPATH=/opt/homebrew/share/man:: INFOPATH=/opt/homebrew/share/info: ZSH=/Users/turtle/.oh-my-zsh PAGER=less LESS=-R LSCOLORS=Gxfxcxdxbxegedabagacad LS_COLORS=di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43 AUTOJUMP_SOURCED=1 AUTOJUMP_ERROR_PATH=/Users/turtle/Library/autojump/errors.log JENV_SHELL=zsh JENV_LOADED=1 JAVAHOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home =/Users/turtle/go/bin/wails GOOS=windows GOARCH=amd64)Done. INFO Wails is now using the new Go WebView2Loader. If you encounter any issues with it, please report them to https://github.com/wailsapp/wails/issues/2004. You could also use the old legacy loader with -tags native_webview2loader, but keep in mind this will be deprecated in the near future. Built '/Users/turtle/Documents/study/code/go/scanner/jgui/myproject/build/bin/myproject.exe' in 5.12s.

♥ If Wails is useful to you or your company, please consider sponsoring the project: https://github.com/sponsors/leaanthony ➜ myproject ` The build command is basically the same. I think Windows' ability to paste directly should be related to WebView2, but mac doesn't.

b1win0y commented 8 months ago

When I access http://localhost:34115/ on the web through the wails dev command, I can paste pictures directly, but when compiled into an app through wails build, I cannot paste pictures. The above operation values ​​are for pictures, and text can be pasted normally.

fyonecon commented 8 months ago

做一个选中div,然后用js点击复制就可以了,wails原生的不太了解

b1win0y commented 8 months ago

做一个选中div,然后用js点击复制就可以了,wails原生的不太了解

你说的方法可能可以解决,但我的问题不仅仅是粘贴图片这个问题,可能还有下载或是其他,我只是以粘贴图片为例子,我觉得Windows可以可能是因为嵌入了WebView2,而mac好像没有