WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// App holds Wails-bound state for the desktop shell.
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
backendURL string
|
||||
apiLanBaseURL string
|
||||
listenPublic bool
|
||||
shutdownCh chan struct{}
|
||||
}
|
||||
|
||||
// NewApp creates a new App application struct.
|
||||
func NewApp() *App {
|
||||
return &App{
|
||||
shutdownCh: make(chan struct{}, 1),
|
||||
}
|
||||
}
|
||||
|
||||
// startup is called when the application starts.
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
}
|
||||
|
||||
func (a *App) shutdown(ctx context.Context) {
|
||||
a.shutdownCh <- struct{}{}
|
||||
}
|
||||
|
||||
// GetAPIBaseURL returns the local HTTP base URL for REST API calls (e.g. http://127.0.0.1:PORT/api/v1).
|
||||
// The desktop shell proxies the webview to this address; window.location.origin is not the API host.
|
||||
func (a *App) GetAPIBaseURL() string {
|
||||
if a.backendURL == "" {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimRight(a.backendURL, "/") + "/api/v1"
|
||||
}
|
||||
|
||||
// GetDesktopHTTPPortSetting returns the saved local API port (0 = random port each launch).
|
||||
func (a *App) GetDesktopHTTPPortSetting() int {
|
||||
return LoadDesktopPrefsHTTPPort()
|
||||
}
|
||||
|
||||
// SetDesktopHTTPPortSetting saves the preferred local API port to application support. Restart the app for it to take effect unless it matches the current listener.
|
||||
func (a *App) SetDesktopHTTPPortSetting(port int) error {
|
||||
return SaveDesktopHTTPPortPreference(port)
|
||||
}
|
||||
|
||||
// GetDesktopHTTPBindPublicSetting returns whether API listens on all interfaces (0.0.0.0).
|
||||
func (a *App) GetDesktopHTTPBindPublicSetting() bool {
|
||||
return LoadDesktopHTTPBindPublic()
|
||||
}
|
||||
|
||||
// SetDesktopHTTPBindPublicSetting saves LAN/public listen preference. Restart the app for it to take effect.
|
||||
func (a *App) SetDesktopHTTPBindPublicSetting(v bool) error {
|
||||
return SaveDesktopHTTPBindPublicPreference(v)
|
||||
}
|
||||
|
||||
// GetAPILanBaseURL returns a suggested base URL for other devices on the LAN (…/api/v1), or empty if not in bind-public mode or IP detection failed.
|
||||
func (a *App) GetAPILanBaseURL() string {
|
||||
return a.apiLanBaseURL
|
||||
}
|
||||
|
||||
// GetDesktopListenPublicActive is true when this session’s API server is listening on all interfaces (runtime), not the saved preference.
|
||||
func (a *App) GetDesktopListenPublicActive() bool {
|
||||
return a.listenPublic
|
||||
}
|
||||
|
||||
// CheckForUpdates manually triggers the update check from the frontend.
|
||||
func (a *App) CheckForUpdates() {
|
||||
if a.ctx != nil {
|
||||
checkUpdate(a.ctx, desktopAboutVersion(), true, false)
|
||||
}
|
||||
}
|
||||
|
||||
// AutoCheckForUpdates silently checks for updates and downloads them.
|
||||
func (a *App) AutoCheckForUpdates() {
|
||||
if a.ctx != nil {
|
||||
checkUpdate(a.ctx, desktopAboutVersion(), false, true)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user