Skip to content

Frontend refresh causing window.go binding disapper in Wails v2  #4332

Description

@MoYuan-CN

Description

Wails v2 无法处理刷新,无论是由 Vite 带来的 HMR调试 F5 刷新 还是 javascript:window.location.reload(),导致 window.go 对象丢失
Wails v2 cannot handle refreshes, whether it is HMR brought by Vite, Debug F5 refresh or javascript:window.location.reload(), causing the window.go object to be lost

To Reproduce

创建一个新的 Wails 项目,在 app.go 中绑定函数到 App,然后在前端调用
Create a new Wails project, bind the function to the App in app.go, and then call it on the frontend

Expected behaviour

正常绑定对象到 window.go
Binding interface to window.go successfully

Screenshots

Image

(我使用了下方这个 Wrapper 来处理 window.go 不存在的情况)
(I used a wrapper to handle the case when window.go is missing, as shown below.)

图片 Image

Image

Attempted Fixes

No response

System Details

Wails Doctor          
                                


# Wails
Version | v2.10.1


# System
┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Windows 10 IoT Enterprise LTSC 2024                                                   |
| Version      | 2009 (Build: 26100)                                                                   |
| ID           | 24H2                                                                                  |
| Go Version   | go1.24.1                                                                              |
| Platform     | windows                                                                               |
| Architecture | amd64                                                                                 |
| CPU          | 13th Gen Intel(R) Core(TM) i7-1360P                                                   |
| GPU 1        | AskLinkIddDriver Device (Shanghai Kongkong Technology Co., Ltd) - Driver: 18.36.3.757 |
| GPU 2        | Intel(R) Iris(R) Xe Graphics (Intel Corporation) - Driver: 32.0.101.6458              |
| Memory       | 32GB                                                                                  |
└──────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version       |
| WebView2   | N/A          | Installed | 136.0.3240.92 |
| Nodejs     | N/A          | Installed | 22.12.0       |
| npm        | N/A          | Installed | 10.9.0        |
| *upx       | N/A          | Available |               |
| *nsis      | N/A          | Available |               |
|                                                       |
└─────────────── * - Optional Dependency ───────────────┘

# Diagnosis
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions