diff --git a/.gitignore b/.gitignore index cfab598..1ee2d97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea *.iml test.db -.idea/ \ No newline at end of file +.idea/ +build/ \ No newline at end of file diff --git a/build.py b/build.py new file mode 100644 index 0000000..fc07bfa --- /dev/null +++ b/build.py @@ -0,0 +1,15 @@ +import subprocess +import os +import shutil + +if os.path.exists("build"): + shutil.rmtree("build") +os.mkdir("build") + +subprocess.run(["go", "build", "-o", "build/", "main.go"]) + +os.chdir("./frontend") +subprocess.run(["npm", "install"], shell=True) +subprocess.run(["npm", "run", "build"], shell=True) +os.chdir("..") +shutil.copytree("./frontend/dist", "./build/static") \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 1bd99ac..2fdecbf 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,11 +1,41 @@ - + + + + + - Vite + React + TS + + + + + + + + + + + + + + + + + + + + + + + {{Title}} +
diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico new file mode 100644 index 0000000..01b2076 Binary files /dev/null and b/frontend/public/favicon.ico differ diff --git a/frontend/public/icon-192.png b/frontend/public/icon-192.png new file mode 100644 index 0000000..f284631 Binary files /dev/null and b/frontend/public/icon-192.png differ diff --git a/frontend/src/app.ts b/frontend/src/app.ts index 849a831..20147e6 100644 --- a/frontend/src/app.ts +++ b/frontend/src/app.ts @@ -1,12 +1,19 @@ import {User} from "./network/models.ts"; +interface MyWindow extends Window { + serverName?: string; + cloudflareTurnstileSiteKey?: string; +} + class App { - appName = "资源库" + appName = "Nysoure" user: User | null = null; token: string | null = null; + cloudflareTurnstileSiteKey: string | null = null; + constructor() { this.init(); } @@ -20,6 +27,8 @@ class App { if (tokenJson) { this.token = JSON.parse(tokenJson); } + this.appName = (window as MyWindow).serverName || this.appName; + this.cloudflareTurnstileSiteKey = (window as MyWindow).cloudflareTurnstileSiteKey || null; } saveData() { diff --git a/frontend/src/components/alert.tsx b/frontend/src/components/alert.tsx index 0999d4d..8ac81e8 100644 --- a/frontend/src/components/alert.tsx +++ b/frontend/src/components/alert.tsx @@ -10,7 +10,7 @@ export function ErrorAlert({ message, className }: { message: string, className? export function InfoAlert({ message, className }: { message: string, className?: string }) { return
- + {message} diff --git a/frontend/src/components/navigator.tsx b/frontend/src/components/navigator.tsx index 773fd39..562cea7 100644 --- a/frontend/src/components/navigator.tsx +++ b/frontend/src/components/navigator.tsx @@ -32,7 +32,7 @@ export default function Navigator() { { - app.isAdmin() &&
}) @@ -125,7 +129,7 @@ export default function PublishPage() {
@@ -139,67 +143,67 @@ export default function PublishPage() {

{ setTags([...tags, tag]) - }}/> + }} />

{t("Description")}

-