feat: save several servers and pick one to connect
Match the first-party mobile client's connection screen: - the first screen lists saved servers, the one last used leading with its connect button or connected state, the others below, and adding is one tap - servers can be added, edited (name, address, proxy, self-signed) and deleted; deleting the live or last one returns to the list - a password sheet prompts only when the server asks for one, keeps the error and the typed password for a retry - while connected, the instances sheet switches servers - proxy and self-signed options stay per server (the native app's own) - the single-server record and its token migrate automatically - permission cards read a plain signal, fixing a flaky update - bump version to 0.1.2 (build 3)
This commit is contained in:
1 parent
ef0b63ceee
commit
13aca21d99
12 files changed
+966
-361
No files matched your search
+10
-62
@@ -10,65 +10,20 @@ import (
|
||||
"github.com/openchamber/openchamber-native/internal/ocapi"
|
||||
)
|
||||
|
||||
func (c *controller) connectScreen() ui.Node {
|
||||
return ui.Scroll(
|
||||
ui.ScrollProps{
|
||||
Style: ui.Style{Grow: 1},
|
||||
ContentStyle: ui.Style{Padding: ui.All(20), Gap: 14},
|
||||
},
|
||||
ui.StaticText("连接到 OpenChamber", ui.Style{Font: fonts.LargeTitle.Weighted(fonts.Bold)}),
|
||||
ui.StaticText("输入正在运行的 OpenChamber 服务器地址。没有设置密码的服务器可以留空密码。",
|
||||
ui.Style{Color: colors.SecondaryLabel}),
|
||||
ui.TextField(ui.TextFieldProps{
|
||||
Value: c.url,
|
||||
Placeholder: ui.Val("http://192.168.1.5:3000"),
|
||||
Keyboard: ui.KeyboardURL,
|
||||
ContentType: "url",
|
||||
Autocapitalize: ui.CapitalizeNone,
|
||||
Autocorrect: ui.AutocorrectNo,
|
||||
ReturnKey: ui.ReturnNext,
|
||||
}),
|
||||
ui.TextField(ui.TextFieldProps{
|
||||
Value: c.password,
|
||||
Placeholder: ui.Val("密码(可选)"),
|
||||
Secure: true,
|
||||
ContentType: ui.ContentPassword,
|
||||
ReturnKey: ui.ReturnGo,
|
||||
OnSubmit: c.connect,
|
||||
}),
|
||||
ui.Row(ui.Style{Align: ui.AlignCenter, Gap: 10},
|
||||
ui.StaticText("使用代理", ui.Style{Grow: 1}),
|
||||
ui.Toggle(ui.ToggleProps{Value: c.useProxy}),
|
||||
),
|
||||
ui.Show(c.useProxy, func() ui.Node {
|
||||
return ui.TextField(ui.TextFieldProps{
|
||||
Value: c.proxy,
|
||||
Placeholder: ui.Val("socks5://127.0.0.1:1080 或 http://127.0.0.1:7890"),
|
||||
Keyboard: ui.KeyboardURL,
|
||||
Autocapitalize: ui.CapitalizeNone,
|
||||
Autocorrect: ui.AutocorrectNo,
|
||||
})
|
||||
}),
|
||||
ui.Row(ui.Style{Align: ui.AlignCenter, Gap: 10},
|
||||
ui.StaticText("信任自签证书", ui.Style{Grow: 1}),
|
||||
ui.Toggle(ui.ToggleProps{Value: c.insecure}),
|
||||
),
|
||||
ui.Button(ui.ButtonProps{
|
||||
Title: ui.Val("连接"),
|
||||
Variant: ui.ButtonFilled,
|
||||
Disabled: c.busy,
|
||||
OnPress: c.connect,
|
||||
}),
|
||||
ui.Text(c.status, ui.Style{Color: colors.SecondaryLabel}),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *controller) sessionsScreen() ui.Node {
|
||||
nav := ui.UseNavigator()
|
||||
c.nav = nav
|
||||
return ui.Column(ui.Style{Grow: 1},
|
||||
ui.Row(ui.Style{Padding: ui.Symmetric(8, 16), Gap: 8, Align: ui.AlignCenter},
|
||||
ui.Text(c.server, ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel, Lines: 1, Grow: 1}),
|
||||
ui.Row(ui.Style{Padding: ui.Symmetric(8, 16), Gap: 4, Align: ui.AlignCenter},
|
||||
ui.Column(ui.Style{Grow: 1, Gap: 2},
|
||||
ui.Text(c.server, ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel, Lines: 1}),
|
||||
ui.Show(signal.Func(func() bool { return c.errorMsg.Get() != "" }),
|
||||
func() ui.Node {
|
||||
return ui.Text(c.errorMsg, ui.Style{Font: fonts.Footnote, Color: colors.Red, Lines: 2})
|
||||
}),
|
||||
),
|
||||
ui.Button(ui.ButtonProps{Title: ui.Val("实例"), Variant: ui.ButtonPlain,
|
||||
OnPress: func() { c.instancesOpen.Set(true) }}),
|
||||
ui.Button(ui.ButtonProps{Title: ui.Val("断开"), Variant: ui.ButtonPlain, OnPress: c.disconnect}),
|
||||
),
|
||||
ui.Show(signal.Func(func() bool { return len(c.sessions.Get()) == 0 }),
|
||||
@@ -103,13 +58,6 @@ func (c *controller) sessionsScreen() ui.Node {
|
||||
OnLongPress: func() { c.sessionMenu(s.Get()) },
|
||||
}, c.sessionRow(s, idx))
|
||||
}),
|
||||
ui.Sheet(ui.SheetProps{
|
||||
Open: c.newOpen,
|
||||
Detents: ui.DetentLarge,
|
||||
Grabber: true,
|
||||
Content: c.newSessionSheet,
|
||||
OnDismiss: func() { c.creating.Set(false) },
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user