Files
Zakk 3364953513 feat(gui): documentation inside the app
The documentation site's domain has expired and its pages described a
2021 v2rayA. The page now carries its own docs, written against the
current code and shipped with the build, so what a user reads matches the
binary they run: quick start, transparent proxy, routing rules, inbounds
and sharing, flags and environment, troubleshooting. English and
Simplified Chinese; the other locales read the English text and say so.

The sections are Markdown under gui/src/docs/<locale>/, compiled to HTML
at build time by a small vite plugin around marked (a devDependency; the
bundle carries no parser) and loaded on demand, so the first load does not
grow. Headings get ids from their text. The flag table is not written by
hand: GET /api/params reads conf.Params' struct tags (id, short, default,
desc) through reflection, the same tags gonfig parses, and the page renders
it, so a new flag documents itself.

"#docs" and "#docs/<section>" open the page; the RoutingA dialog's help
button, the About page and small book icons in the settings sections and
the inbound dialogs point there instead of at the dead site or the wiki.
The navigation gains a fifth destination.
2026-09-20 14:45:55 +10:00

81 lines
2.2 KiB
Go

package controller
import (
"net/http"
"os"
"runtime"
"time"
"github.com/gin-gonic/gin"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/conf"
"github.com/v2rayA/v2rayA/db/configure"
v2ray "github.com/v2rayA/v2rayA/kernel/v2ray"
"github.com/v2rayA/v2rayA/kernel/v2ray/asset/dat"
"github.com/v2rayA/v2rayA/kernel/v2ray/service"
"github.com/v2rayA/v2rayA/kernel/v2ray/where"
"github.com/v2rayA/v2rayA/pkg/util/privilege"
)
func GetVersion(ctx *gin.Context) {
var lite int
if conf.GetEnvironmentConfig().Lite {
lite = 1
}
// Detect if running as root (Linux/macOS only)
isRoot := false
switch runtime.GOOS {
case "linux", "darwin":
isRoot = os.Geteuid() == 0
case "windows":
isRoot = privilege.IsRootOrAdmin()
}
versionErr := service.CheckCoreVersionMatch()
// the core's own version, for the dashboard; empty when the binary cannot be asked
coreVersion := ""
if _, ver, err := where.GetV2rayServiceVersion(); err == nil {
coreVersion = ver
}
common.ResponseSuccess(ctx, gin.H{
"version": conf.Version,
"foundNew": conf.FoundNew,
"remoteVersion": conf.RemoteVersion,
"serviceValid": service.IsV2rayServiceValid(),
"v5": versionErr == nil,
"lite": lite,
"loadBalanceValid": true,
"variant": where.V2rayaCore,
"coreVersion": coreVersion,
"os": runtime.GOOS,
"isRoot": isRoot,
"tunSupported": v2ray.TunSupported(),
"coreVersionValid": versionErr == nil,
"coreVersionErr": func() string {
if versionErr != nil {
return versionErr.Error()
}
return ""
}(),
"hasAccounts": configure.HasAnyAccounts(),
"lastKernelExit": configure.GetLastKernelExitStatus(),
"docker": common.IsDocker(),
})
}
func GetRemoteGFWListVersion(ctx *gin.Context) {
g, err := dat.GetRemoteGFWListUpdateTime(&http.Client{Timeout: 10 * time.Second})
if err != nil {
common.ResponseError(ctx, logError(err))
return
}
common.ResponseSuccess(ctx, gin.H{"remoteGFWListVersion": g.UpdateTime.Local().Format("2006-01-02")})
}
// GetParams lists the command-line flags for the documentation page.
func GetParams(ctx *gin.Context) {
common.ResponseSuccess(ctx, gin.H{"params": conf.Parameters()})
}