diff --git a/app.go b/app.go
index f1dd4be..b7b4791 100644
--- a/app.go
+++ b/app.go
@@ -5,7 +5,6 @@ import (
"runtime/debug"
"zroker/zrok"
- "github.com/gofiber/fiber/v2/log"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/wailsapp/wails/v2/pkg/runtime"
@@ -98,18 +97,7 @@ func (a *App) Overview() string {
}
func (a *App) Sharing(shareRequest sdk.ShareRequest) *sdk.Share {
- root,_ := environment.LoadRoot()
- share,err := sdk.CreateShare(root, &sdk.ShareRequest{
- BackendMode: shareRequest.BackendMode,
- ShareMode: shareRequest.ShareMode,
- Frontends: []string{"public"}, // 不是很懂这个参数
- Target: shareRequest.Target,
- })
- if(err != nil){
- log.Error("error", err)
- }
- log.Info("share", share)
- return share
+ return zrok.Sharing(shareRequest)
}
// Open link in browser
diff --git a/frontend/package.json.md5 b/frontend/package.json.md5
index b58fbf5..80f06c6 100644
--- a/frontend/package.json.md5
+++ b/frontend/package.json.md5
@@ -1 +1 @@
-de2fdbf1f33b1f587fd3dd6db0957c2e
\ No newline at end of file
+b73133a2876821f79d7e3e9e244623fe
\ No newline at end of file
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index c651bd4..a0897ca 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -7,7 +7,7 @@ import { EnableProvider } from "./contexts/Enable";
import { useAutoDark } from "./hooks/useAutoDark";
const App = () => {
- const [theme] = useAutoDark();
+ const [theme, setTheme] = useAutoDark();
const [dark, setDark] = useState(false);
useEffect(() => {
@@ -23,7 +23,7 @@ const App = () => {
accentColor="crimson"
>
-
+
{
+const Zroker = ({ setTheme }: { setTheme: (theme: Theme) => void }) => {
const { enable } = useEnable();
return (
-
+
{enable ? : }
+
+
+
);
};
diff --git a/frontend/src/components/Enable.tsx b/frontend/src/components/Enable.tsx
index 18452ae..6cbacf1 100644
--- a/frontend/src/components/Enable.tsx
+++ b/frontend/src/components/Enable.tsx
@@ -20,7 +20,7 @@ const EnablePage = () => {
} else {
const ok = await Enable(token);
if (ok) {
- toast.success("Enable success");
+ toast.success("Enabled successfully");
setEnable(true);
} else {
toast.error("Enable failed");
diff --git a/frontend/src/components/Overview.tsx b/frontend/src/components/Overview.tsx
index cd00ae8..98e7a2a 100644
--- a/frontend/src/components/Overview.tsx
+++ b/frontend/src/components/Overview.tsx
@@ -2,8 +2,8 @@ import dayjs from "dayjs";
import Sharing from "./Sharing";
import toast from "react-hot-toast";
import { useEffect, useState } from "react";
-import { XCircle, CopyIcon, Plus, Delete, RefreshCw } from "lucide-react";
import { Share, Environment } from "../../types/zrok";
+import { XCircle, CopyIcon, Plus, Delete, RefreshCw } from "lucide-react";
import { Overview, OpenExternal, DeleteShare } from "../../wailsjs/go/main/App";
import {
Box,
@@ -12,11 +12,12 @@ import {
Link,
Table,
Badge,
+ Card,
Button,
Dialog,
ScrollArea,
+ IconButton,
Separator,
- Card,
} from "@radix-ui/themes";
type Environments = {
@@ -35,6 +36,7 @@ const Page = () => {
const getOverview = async () => {
setLoading(true);
const overview = await Overview();
+ console.log(overview);
const { environments }: { environments: Environments[] } =
JSON.parse(overview);
@@ -48,11 +50,15 @@ const Page = () => {
useEffect(() => {
if (!loading) {
- setShares(environments[0]?.shares?.reverse() ?? []);
+ setShares(environments[1]?.shares?.reverse() ?? []);
}
}, [loading]);
- const handleClickFrontendEndpoint = (url: string) => {
+ const openExternal = (
+ event: React.MouseEvent,
+ url: string
+ ) => {
+ event.stopPropagation();
if (url == "private") {
return;
}
@@ -72,10 +78,10 @@ const Page = () => {
});
if (ok) {
- toast.success("删除成功");
+ toast.success("Delete successful");
setShares([...shares.filter((item) => item.token != share.token)]);
} else {
- toast.error("删除失败");
+ toast.error("Delete failed");
}
setIsLoading(false);
setCurrent({} as Share);
@@ -151,11 +157,11 @@ const Page = () => {
backendMode
+ shareMode
+ frontendEndpoint
backendProxyEndpoint
- frontendEndpoint
- shareMode
createdAt
actions
@@ -190,7 +196,9 @@ const Page = () => {
OpenExternal(share.backendProxyEndpoint)}
+ onClick={(event) =>
+ openExternal(event, share.backendProxyEndpoint)
+ }
>
{share.backendProxyEndpoint}
@@ -201,8 +209,8 @@ const Page = () => {
) : (
- handleClickFrontendEndpoint(share.frontendEndpoint)
+ onClick={(event) =>
+ openExternal(event, share.frontendEndpoint)
}
>
{share.frontendEndpoint}
@@ -257,7 +265,9 @@ const Page = () => {
>
{current.token}
-
+
+
+
{
>
{current.zId}
-
+
+
+
+
+
+
+ createdAt
+
+
+ {dayjs(current.createdAt).format("YYYY/M/DD HH:mm:ss")}
+
{
const [theme, setTheme] = useState("dark");
diff --git a/go.mod b/go.mod
index c427c3f..63c53a7 100644
--- a/go.mod
+++ b/go.mod
@@ -46,6 +46,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/oklog/ulid v1.3.1 // indirect
+ github.com/onsi/gomega v1.27.6 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openziti/channel/v2 v2.0.119 // indirect
github.com/openziti/edge-api v0.26.10 // indirect
@@ -73,7 +74,7 @@ require (
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
- golang.org/x/sync v0.5.0 // indirect
+ golang.org/x/sync v0.6.0 // indirect
golang.org/x/term v0.19.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.32.0 // indirect
@@ -85,11 +86,10 @@ require (
require (
github.com/bep/debounce v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
- github.com/gofiber/fiber/v2 v2.52.4
github.com/google/uuid v1.6.0 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/labstack/echo/v4 v4.10.2 // indirect
- github.com/labstack/gommon v0.4.0 // indirect
+ github.com/labstack/gommon v0.4.0
github.com/leaanthony/go-ansi-parser v1.6.0 // indirect
github.com/leaanthony/gosod v1.0.3 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
diff --git a/go.sum b/go.sum
index aa13274..f28c461 100644
--- a/go.sum
+++ b/go.sum
@@ -117,8 +117,6 @@ github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM=
-github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
@@ -326,8 +324,8 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
-github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
-github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
+github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
+github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openziti/channel/v2 v2.0.119 h1:stfSrnDqoTi78LMvQA3+NSivHjQnRrYKrgij5NaOENI=
@@ -601,8 +599,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
-golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
+golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -881,7 +879,6 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/zrok/share.go b/zrok/share.go
new file mode 100644
index 0000000..0f869d9
--- /dev/null
+++ b/zrok/share.go
@@ -0,0 +1,22 @@
+package zrok
+
+import (
+ "github.com/labstack/gommon/log"
+ "github.com/openziti/zrok/environment"
+ "github.com/openziti/zrok/sdk/golang/sdk"
+)
+
+func Sharing(shareRequest sdk.ShareRequest) *sdk.Share {
+ root, _ := environment.LoadRoot()
+ share, err := sdk.CreateShare(root, &sdk.ShareRequest{
+ BackendMode: shareRequest.BackendMode,
+ ShareMode: shareRequest.ShareMode,
+ Frontends: []string{"public"}, // 不是很懂这个参数
+ Target: shareRequest.Target,
+ })
+ if err != nil {
+ log.Error("error", err)
+ }
+ log.Info("share", share)
+ return share
+}