[优化] 更新包名

This commit is contained in:
ryan
2026-03-10 17:07:36 +08:00
parent 08e4de4898
commit 9d4f4450ca
52 changed files with 975 additions and 986 deletions
+53 -53
View File
@@ -1,54 +1,54 @@
name: Publish Docker image (amd64)
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
name:
description: 'reason'
required: false
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Save version info
run: |
git describe --tags > VERSION
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
justsong/gin-template
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
name: Publish Docker image (amd64)
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
name:
description: 'reason'
required: false
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Save version info
run: |
git describe --tags > VERSION
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/rain-kl/atsflare
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+61 -61
View File
@@ -1,62 +1,62 @@
name: Publish Docker image (arm64)
on:
push:
tags:
- '*'
- '!*-alpha*'
workflow_dispatch:
inputs:
name:
description: 'reason'
required: false
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Save version info
run: |
git describe --tags > VERSION
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
justsong/gin-template
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
name: Publish Docker image (arm64)
on:
push:
tags:
- '*'
- '!*-alpha*'
workflow_dispatch:
inputs:
name:
description: 'reason'
required: false
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Save version info
run: |
git describe --tags > VERSION
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/rain-kl/atsflare
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+53 -53
View File
@@ -1,54 +1,54 @@
name: Linux Release
permissions:
contents: write
on:
push:
tags:
- '*'
- '!*-alpha*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build Frontend
env:
CI: ""
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build Backend (amd64)
run: |
go mod download
go build -ldflags "-s -w -X 'gin-template/common.Version=$(git describe --tags)' -extldflags '-static'" -o gin-template
- name: Build Backend (arm64)
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'gin-template/common.Version=$(git describe --tags)' -extldflags '-static'" -o gin-template-arm64
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
gin-template
gin-template-arm64
draft: false
generate_release_notes: true
env:
name: Linux Release
permissions:
contents: write
on:
push:
tags:
- '*'
- '!*-alpha*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build Frontend
env:
CI: ""
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build Backend (amd64)
run: |
go mod download
go build -ldflags "-s -w -X 'atsflare/common.Version=$(git describe --tags)' -extldflags '-static'" -o atsflare
- name: Build Backend (arm64)
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'atsflare/common.Version=$(git describe --tags)' -extldflags '-static'" -o atsflare-arm64
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
atsflare
atsflare-arm64
draft: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+45 -45
View File
@@ -1,45 +1,45 @@
name: macOS Release
permissions:
contents: write
on:
push:
tags:
- '*'
- '!*-alpha*'
jobs:
release:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build Frontend
env:
CI: ""
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build Backend
run: |
go mod download
go build -ldflags "-X 'gin-template/common.Version=$(git describe --tags)'" -o gin-template-macos
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: gin-template-macos
draft: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: macOS Release
permissions:
contents: write
on:
push:
tags:
- '*'
- '!*-alpha*'
jobs:
release:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build Frontend
env:
CI: ""
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build Backend
run: |
go mod download
go build -ldflags "-X 'atsflare/common.Version=$(git describe --tags)'" -o atsflare-macos
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: atsflare-macos
draft: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+47 -47
View File
@@ -1,48 +1,48 @@
name: Windows Release
permissions:
contents: write
on:
push:
tags:
- '*'
- '!*-alpha*'
jobs:
release:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build Frontend
env:
CI: ""
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build Backend
run: |
go mod download
go build -ldflags "-s -w -X 'gin-template/common.Version=$(git describe --tags)'" -o gin-template.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: gin-template.exe
draft: false
generate_release_notes: true
env:
name: Windows Release
permissions:
contents: write
on:
push:
tags:
- '*'
- '!*-alpha*'
jobs:
release:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build Frontend
env:
CI: ""
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build Backend
run: |
go mod download
go build -ldflags "-s -w -X 'atsflare/common.Version=$(git describe --tags)'" -o atsflare.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: atsflare.exe
draft: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+92 -97
View File
@@ -1,98 +1,93 @@
<p align="right">
<a href="./README.md">中文</a> | <strong>English</strong>
</p>
<p align="center">
<a href="https://github.com/songquanpeng/gin-template"><img src="https://raw.githubusercontent.com/songquanpeng/gin-template/main/web/public/logo.png" width="150" height="150" alt="gin-template logo"></a>
</p>
<div align="center">
# Gin Template
_✨ Template for Gin & React projects ✨_
</div>
<p align="center">
<a href="https://raw.githubusercontent.com/songquanpeng/gin-template/main/LICENSE">
<img src="https://img.shields.io/github/license/songquanpeng/gin-template?color=brightgreen" alt="license">
</a>
<a href="https://github.com/songquanpeng/gin-template/releases/latest">
<img src="https://img.shields.io/github/v/release/songquanpeng/gin-template?color=brightgreen&include_prereleases" alt="release">
</a>
<a href="https://hub.docker.com/repository/docker/justsong/gin-template">
<img src="https://img.shields.io/docker/pulls/justsong/gin-template?color=brightgreen" alt="docker pull">
</a>
<a href="https://github.com/songquanpeng/gin-template/releases/latest">
<img src="https://img.shields.io/github/downloads/songquanpeng/gin-template/total?color=brightgreen&include_prereleases" alt="release">
</a>
<a href="https://goreportcard.com/report/github.com/songquanpeng/go-file">
<img src="https://goreportcard.com/badge/github.com/songquanpeng/gin-template" alt="GoReportCard">
</a>
</p>
<p align="center">
<a href="https://github.com/songquanpeng/gin-template/releases">Download</a>
·
<a href="https://github.com/songquanpeng/gin-template/blob/main/README.en.md#deployment">Tutorial</a>
·
<a href="https://github.com/songquanpeng/gin-template/issues">Feedback</a>
·
<a href="https://gin-template.vercel.app/">Demo</a>
</p>
## Features
+ [x] Built-in user management.
+ [x] Built-in file management.
+ [x] [GitHub OAuth](https://github.com/settings/applications/new).
+ [x] WeChat official account authorization (need [wechat-server](https://github.com/songquanpeng/wechat-server)).
+ [x] Email verification & password reset.
+ [x] Request rate limiting.
+ [x] Static files caching.
+ [x] Mobile friendly UI.
+ [x] Token based authorization.
+ [x] Use GitHub Actions to build releases & Docker images.
+ [x] Cloudflare Turnstile user validation.
## Deployment
### Manual deployment
1. Download built binary from [GitHub Releases](https://github.com/songquanpeng/gin-template/releases/latest) or build from source:
```shell
git clone https://github.com/songquanpeng/gin-template.git
go mod download
go build -ldflags "-s -w" -o gin-template
````
2. Run it:
```shell
chmod u+x gin-template
./gin-template --port 3000 --log-dir ./logs
```
3. Visit [http://localhost:3000/](http://localhost:3000/) and login. The username for the initial account is `root` and the password is `123456`.
### Deploy with Docker
Execute: `docker run -d --restart always -p 3000:3000 -v /home/ubuntu/data/gin-template:/data -v /etc/ssl/certs:/etc/ssl/certs:ro justsong/gin-template`
Data will be saved in `/home/ubuntu/data/gin-template`.
## Configurations
The system works out of the box.
You can configure the system by set environment variables or specify command line arguments.
After the system starts, use `root` user to log in to the system and do further configuration.
### Environment Variables
1. `REDIS_CONN_STRING`: when set, Redis will be used as the storage for request rate limitation instead of memory storage.
+ Example: `REDIS_CONN_STRING=redis://default:redispw@localhost:49153`
2. `SESSION_SECRET`: when set, a fixed session key will be used so that the logged-in users' cookie remains valid across system reboots.
+ Example: `SESSION_SECRET=random_string`
3. `SQL_DSN`: when set, the target SQL database will be used instead of SQLite.
+ Example: `SQL_DSN=root:123456@tcp(localhost:3306)/gin-template`
### Command line Arguments
1. `--port <port_number>`: specify the port number, the default value is `3000`.
+ Example: `--port 3000`
2. `--log-dir <log_dir>`: specify the log dir, if not set, the log won't be saved.
+ Example: `--log-dir ./logs`
<p align="right">
<a href="./README.md">中文</a> | <strong>English</strong>
</p>
<p align="center">
<a href="https://github.com/Rain-kl/ATSFlare"><img src="https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/atsf_server/web/public/logo.png" width="150" height="150" alt="ATSFlare logo"></a>
</p>
<div align="center">
# ATSFlare
_✨ Internal Nginx control plane for reverse proxy management ✨_
</div>
<p align="center">
<a href="https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/LICENSE">
<img src="https://img.shields.io/github/license/Rain-kl/ATSFlare?color=brightgreen" alt="license">
</a>
<a href="https://github.com/Rain-kl/ATSFlare/releases/latest">
<img src="https://img.shields.io/github/v/release/Rain-kl/ATSFlare?color=brightgreen&include_prereleases" alt="release">
</a>
<a href="https://github.com/Rain-kl/ATSFlare/releases/latest">
<img src="https://img.shields.io/github/downloads/Rain-kl/ATSFlare/total?color=brightgreen&include_prereleases" alt="release">
</a>
<a href="https://goreportcard.com/report/github.com/Rain-kl/ATSFlare">
<img src="https://goreportcard.com/badge/github.com/Rain-kl/ATSFlare" alt="GoReportCard">
</a>
</p>
<p align="center">
<a href="https://github.com/Rain-kl/ATSFlare/releases">Download</a>
·
<a href="https://github.com/Rain-kl/ATSFlare/blob/main/README.en.md#deployment">Tutorial</a>
·
<a href="https://github.com/Rain-kl/ATSFlare/issues">Feedback</a>
</p>
## Features
+ [x] Built-in user management.
+ [x] Built-in file management.
+ [x] [GitHub OAuth](https://github.com/settings/applications/new).
+ [x] WeChat official account authorization (need [wechat-server](https://github.com/songquanpeng/wechat-server)).
+ [x] Email verification & password reset.
+ [x] Request rate limiting.
+ [x] Static files caching.
+ [x] Mobile friendly UI.
+ [x] Token based authorization.
+ [x] Use GitHub Actions to build releases & Docker images.
+ [x] Cloudflare Turnstile user validation.
## Deployment
### Manual deployment
1. Download built binary from [GitHub Releases](https://github.com/Rain-kl/ATSFlare/releases/latest) or build from source:
```shell
git clone https://github.com/Rain-kl/ATSFlare.git
go mod download
go build -ldflags "-s -w" -o atsflare
````
2. Run it:
```shell
chmod u+x atsflare
./atsflare --port 3000 --log-dir ./logs
```
3. Visit [http://localhost:3000/](http://localhost:3000/) and login. The username for the initial account is `root` and the password is `123456`.
### Deploy with Docker
Execute: `docker run -d --restart always -p 3000:3000 -v /home/ubuntu/data/atsflare:/data -v /etc/ssl/certs:/etc/ssl/certs:ro ghcr.io/rain-kl/atsflare`
Data will be saved in `/home/ubuntu/data/atsflare`.
## Configurations
The system works out of the box.
You can configure the system by set environment variables or specify command line arguments.
After the system starts, use `root` user to log in to the system and do further configuration.
### Environment Variables
1. `REDIS_CONN_STRING`: when set, Redis will be used as the storage for request rate limitation instead of memory storage.
+ Example: `REDIS_CONN_STRING=redis://default:redispw@localhost:49153`
2. `SESSION_SECRET`: when set, a fixed session key will be used so that the logged-in users' cookie remains valid across system reboots.
+ Example: `SESSION_SECRET=random_string`
3. `SQL_DSN`: when set, the target SQL database will be used instead of SQLite.
+ Example: `SQL_DSN=root:123456@tcp(localhost:3306)/atsflare`
### Command line Arguments
1. `--port <port_number>`: specify the port number, the default value is `3000`.
+ Example: `--port 3000`
2. `--log-dir <log_dir>`: specify the log dir, if not set, the log won't be saved.
+ Example: `--log-dir ./logs`
3. `--version`: print the version and exit.
+31 -31
View File
@@ -1,31 +1,31 @@
FROM node:16 as builder
WORKDIR /build
COPY ./web .
COPY ./VERSION .
RUN npm install
RUN REACT_APP_VERSION=$(cat VERSION) npm run build
FROM golang AS builder2
ENV GO111MODULE=on \
CGO_ENABLED=1 \
GOOS=linux
WORKDIR /build
COPY . .
COPY --from=builder /build/build ./web/build
RUN go mod download
RUN go build -ldflags "-s -w -X 'gin-template/common.Version=$(cat VERSION)' -extldflags '-static'" -o gin-template
FROM alpine
RUN apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates tzdata \
&& update-ca-certificates 2>/dev/null || true
ENV PORT=3000
COPY --from=builder2 /build/gin-template /
EXPOSE 3000
WORKDIR /data
ENTRYPOINT ["/gin-template"]
FROM node:16 as builder
WORKDIR /build
COPY ./web .
COPY ./VERSION .
RUN npm install
RUN REACT_APP_VERSION=$(cat VERSION) npm run build
FROM golang AS builder2
ENV GO111MODULE=on \
CGO_ENABLED=1 \
GOOS=linux
WORKDIR /build
COPY . .
COPY --from=builder /build/build ./web/build
RUN go mod download
RUN go build -ldflags "-s -w -X 'atsflare/common.Version=$(cat VERSION)' -extldflags '-static'" -o atsflare
FROM alpine
RUN apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates tzdata \
&& update-ca-certificates 2>/dev/null || true
ENV PORT=3000
COPY --from=builder2 /build/atsflare /
EXPOSE 3000
WORKDIR /data
ENTRYPOINT ["/atsflare"]
+3 -3
View File
@@ -20,10 +20,10 @@ var (
var UploadPath = "upload"
func printHelp() {
fmt.Println("Gin Template " + Version + " - Your next project starts from here.")
fmt.Println("ATSFlare " + Version + " - Internal Nginx Control Plane.")
fmt.Println("Copyright (C) 2023 JustSong. All rights reserved.")
fmt.Println("GitHub: https://github.com/songquanpeng/gin-template")
fmt.Println("Usage: gin-template [--port <port>] [--log-dir <log directory>] [--version] [--help]")
fmt.Println("GitHub: https://github.com/Rain-kl/ATSFlare")
fmt.Println("Usage: atsflare [--port <port>] [--log-dir <log directory>] [--version] [--help]")
}
func init() {
+2 -2
View File
@@ -1,9 +1,9 @@
package controller
import (
"atsflare/model"
"atsflare/service"
"encoding/json"
"gin-template/model"
"gin-template/service"
"github.com/gin-gonic/gin"
"net/http"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package controller
import (
"gin-template/service"
"atsflare/service"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+2 -2
View File
@@ -1,9 +1,9 @@
package controller
import (
"atsflare/common"
"atsflare/model"
"fmt"
"gin-template/common"
"gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
"path/filepath"
+2 -2
View File
@@ -1,12 +1,12 @@
package controller
import (
"atsflare/common"
"atsflare/model"
"bytes"
"encoding/json"
"errors"
"fmt"
"gin-template/common"
"gin-template/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
+1 -1
View File
@@ -1,8 +1,8 @@
package controller
import (
"atsflare/service"
"encoding/json"
"gin-template/service"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+2 -2
View File
@@ -1,10 +1,10 @@
package controller
import (
"atsflare/common"
"atsflare/model"
"encoding/json"
"fmt"
"gin-template/common"
"gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
)
+1 -1
View File
@@ -1,8 +1,8 @@
package controller
import (
"atsflare/service"
"encoding/json"
"gin-template/service"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+2 -2
View File
@@ -1,9 +1,9 @@
package controller
import (
"atsflare/common"
"atsflare/model"
"encoding/json"
"gin-template/common"
"gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
"strings"
+1 -1
View File
@@ -1,8 +1,8 @@
package controller
import (
"atsflare/service"
"encoding/json"
"gin-template/service"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+1 -1
View File
@@ -1,8 +1,8 @@
package controller
import (
"atsflare/service"
"encoding/json"
"gin-template/service"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+2 -2
View File
@@ -1,9 +1,9 @@
package controller
import (
"atsflare/common"
"atsflare/model"
"encoding/json"
"gin-template/common"
"gin-template/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
+2 -2
View File
@@ -1,11 +1,11 @@
package controller
import (
"atsflare/common"
"atsflare/model"
"encoding/json"
"errors"
"fmt"
"gin-template/common"
"gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+1 -1
View File
@@ -1,4 +1,4 @@
module gin-template
module atsflare
// +heroku goVersion go1.18
go 1.18
+85 -85
View File
@@ -1,85 +1,85 @@
package main
import (
"embed"
"fmt"
"gin-template/common"
"gin-template/middleware"
"gin-template/model"
"gin-template/router"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-contrib/sessions/redis"
"github.com/gin-gonic/gin"
"log"
"os"
"strconv"
)
//go:embed web/build
var buildFS embed.FS
//go:embed web/build/index.html
var indexPage []byte
func main() {
common.SetupGinLog()
common.SysLog("Gin Template " + common.Version + " started")
if os.Getenv("GIN_MODE") != "debug" {
gin.SetMode(gin.ReleaseMode)
}
// Initialize SQL Database
err := model.InitDB()
if err != nil {
common.FatalLog(err)
}
defer func() {
err := model.CloseDB()
if err != nil {
common.FatalLog(err)
}
}()
// Initialize Redis
err = common.InitRedisClient()
if err != nil {
common.FatalLog(err)
}
// Initialize options
model.InitOptionMap()
// Initialize HTTP server
server := gin.Default()
//server.Use(gzip.Gzip(gzip.DefaultCompression))
server.Use(middleware.CORS())
// Initialize session store
if common.RedisEnabled {
opt := common.ParseRedisOption()
store, _ := redis.NewStore(opt.MinIdleConns, opt.Network, opt.Addr, opt.Password, []byte(common.SessionSecret))
server.Use(sessions.Sessions("session", store))
} else {
store := cookie.NewStore([]byte(common.SessionSecret))
server.Use(sessions.Sessions("session", store))
}
router.SetRouter(server, buildFS, indexPage)
var port = os.Getenv("PORT")
if port == "" {
port = strconv.Itoa(*common.Port)
}
common.SysLog(fmt.Sprintf("server config: port=%s gin_mode=%s sqlite_path=%s redis_enabled=%t upload_path=%s log_dir=%s agent_token_configured=%t node_offline_threshold=%s", port, gin.Mode(), common.SQLitePath, common.RedisEnabled, common.UploadPath, valueOrDefault(*common.LogDir, "stdout"), common.AgentToken != "", common.NodeOfflineThreshold))
common.SysLog(fmt.Sprintf("server listening on :%s", port))
err = server.Run(":" + port)
if err != nil {
log.Println(err)
}
}
func valueOrDefault(value string, fallback string) string {
if value == "" {
return fallback
}
return value
}
package main
import (
"atsflare/common"
"atsflare/middleware"
"atsflare/model"
"atsflare/router"
"embed"
"fmt"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-contrib/sessions/redis"
"github.com/gin-gonic/gin"
"log"
"os"
"strconv"
)
//go:embed web/build
var buildFS embed.FS
//go:embed web/build/index.html
var indexPage []byte
func main() {
common.SetupGinLog()
common.SysLog("ATSFlare " + common.Version + " started")
if os.Getenv("GIN_MODE") != "debug" {
gin.SetMode(gin.ReleaseMode)
}
// Initialize SQL Database
err := model.InitDB()
if err != nil {
common.FatalLog(err)
}
defer func() {
err := model.CloseDB()
if err != nil {
common.FatalLog(err)
}
}()
// Initialize Redis
err = common.InitRedisClient()
if err != nil {
common.FatalLog(err)
}
// Initialize options
model.InitOptionMap()
// Initialize HTTP server
server := gin.Default()
//server.Use(gzip.Gzip(gzip.DefaultCompression))
server.Use(middleware.CORS())
// Initialize session store
if common.RedisEnabled {
opt := common.ParseRedisOption()
store, _ := redis.NewStore(opt.MinIdleConns, opt.Network, opt.Addr, opt.Password, []byte(common.SessionSecret))
server.Use(sessions.Sessions("session", store))
} else {
store := cookie.NewStore([]byte(common.SessionSecret))
server.Use(sessions.Sessions("session", store))
}
router.SetRouter(server, buildFS, indexPage)
var port = os.Getenv("PORT")
if port == "" {
port = strconv.Itoa(*common.Port)
}
common.SysLog(fmt.Sprintf("server config: port=%s gin_mode=%s sqlite_path=%s redis_enabled=%t upload_path=%s log_dir=%s agent_token_configured=%t node_offline_threshold=%s", port, gin.Mode(), common.SQLitePath, common.RedisEnabled, common.UploadPath, valueOrDefault(*common.LogDir, "stdout"), common.AgentToken != "", common.NodeOfflineThreshold))
common.SysLog(fmt.Sprintf("server listening on :%s", port))
err = server.Run(":" + port)
if err != nil {
log.Println(err)
}
}
func valueOrDefault(value string, fallback string) string {
if value == "" {
return fallback
}
return value
}
+1 -1
View File
@@ -1,7 +1,7 @@
package middleware
import (
"gin-template/service"
"atsflare/service"
"github.com/gin-gonic/gin"
"net/http"
)
+2 -2
View File
@@ -1,8 +1,8 @@
package middleware
import (
"gin-template/common"
"gin-template/model"
"atsflare/common"
"atsflare/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
+1 -1
View File
@@ -7,6 +7,6 @@ import (
func CORS() gin.HandlerFunc {
config := cors.DefaultConfig()
config.AllowOrigins = []string{"https://gin-template.vercel.app", "http://localhost:3000/"}
config.AllowOrigins = []string{"https://atsflare.vercel.app", "http://localhost:3000/"}
return cors.New(config)
}
+1 -1
View File
@@ -1,9 +1,9 @@
package middleware
import (
"atsflare/common"
"context"
"fmt"
"gin-template/common"
"github.com/gin-gonic/gin"
"net/http"
"time"
+1 -1
View File
@@ -1,8 +1,8 @@
package middleware
import (
"atsflare/common"
"encoding/json"
"gin-template/common"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
+50 -50
View File
@@ -1,50 +1,50 @@
package model
import (
"gin-template/common"
"gorm.io/gorm"
"os"
"path"
)
type File struct {
Id int `json:"id"`
Filename string `json:"filename" gorm:"index"`
Description string `json:"description"`
Uploader string `json:"uploader" gorm:"index"`
UploaderId int `json:"uploader_id" gorm:"index"`
Link string `json:"link" gorm:"unique;index"`
UploadTime string `json:"upload_time"`
DownloadCounter int `json:"download_counter"`
}
func GetAllFiles(startIdx int, num int) ([]*File, error) {
var files []*File
var err error
err = DB.Order("id desc").Limit(num).Offset(startIdx).Find(&files).Error
return files, err
}
func SearchFiles(keyword string) (files []*File, err error) {
err = DB.Select([]string{"id", "filename", "description", "uploader", "uploader_id", "link", "upload_time", "download_counter"}).Where(
"filename LIKE ? or uploader LIKE ? or uploader_id = ?", keyword+"%", keyword+"%", keyword).Find(&files).Error
return files, err
}
func (file *File) Insert() error {
var err error
err = DB.Create(file).Error
return err
}
// Delete Make sure link is valid! Because we will use os.Remove to delete it!
func (file *File) Delete() error {
var err error
err = DB.Delete(file).Error
err = os.Remove(path.Join(common.UploadPath, file.Link))
return err
}
func UpdateDownloadCounter(link string) {
DB.Model(&File{}).Where("link = ?", link).UpdateColumn("download_counter", gorm.Expr("download_counter + 1"))
}
package model
import (
"atsflare/common"
"gorm.io/gorm"
"os"
"path"
)
type File struct {
Id int `json:"id"`
Filename string `json:"filename" gorm:"index"`
Description string `json:"description"`
Uploader string `json:"uploader" gorm:"index"`
UploaderId int `json:"uploader_id" gorm:"index"`
Link string `json:"link" gorm:"unique;index"`
UploadTime string `json:"upload_time"`
DownloadCounter int `json:"download_counter"`
}
func GetAllFiles(startIdx int, num int) ([]*File, error) {
var files []*File
var err error
err = DB.Order("id desc").Limit(num).Offset(startIdx).Find(&files).Error
return files, err
}
func SearchFiles(keyword string) (files []*File, err error) {
err = DB.Select([]string{"id", "filename", "description", "uploader", "uploader_id", "link", "upload_time", "download_counter"}).Where(
"filename LIKE ? or uploader LIKE ? or uploader_id = ?", keyword+"%", keyword+"%", keyword).Find(&files).Error
return files, err
}
func (file *File) Insert() error {
var err error
err = DB.Create(file).Error
return err
}
// Delete Make sure link is valid! Because we will use os.Remove to delete it!
func (file *File) Delete() error {
var err error
err = DB.Delete(file).Error
err = os.Remove(path.Join(common.UploadPath, file.Link))
return err
}
func UpdateDownloadCounter(link string) {
DB.Model(&File{}).Where("link = ?", link).UpdateColumn("download_counter", gorm.Expr("download_counter + 1"))
}
+1 -1
View File
@@ -1,7 +1,7 @@
package model
import (
"gin-template/common"
"atsflare/common"
"github.com/glebarez/sqlite"
"gorm.io/driver/mysql"
"gorm.io/gorm"
+1 -1
View File
@@ -1,7 +1,7 @@
package model
import (
"gin-template/common"
"atsflare/common"
"strconv"
"strings"
)
+1 -1
View File
@@ -1,8 +1,8 @@
package model
import (
"atsflare/common"
"errors"
"gin-template/common"
"strings"
)
+2 -2
View File
@@ -1,8 +1,8 @@
package router
import (
"gin-template/controller"
"gin-template/middleware"
"atsflare/controller"
"atsflare/middleware"
"github.com/gin-gonic/gin"
)
+4 -4
View File
@@ -1,6 +1,10 @@
package router_test
import (
"atsflare/common"
"atsflare/model"
"atsflare/router"
"atsflare/service"
"bytes"
"crypto/rand"
"crypto/rsa"
@@ -8,10 +12,6 @@ import (
"crypto/x509/pkix"
"encoding/json"
"encoding/pem"
"gin-template/common"
"gin-template/model"
"gin-template/router"
"gin-template/service"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
@@ -1,8 +1,8 @@
package router_test
import (
"gin-template/common"
"gin-template/router"
"atsflare/common"
"atsflare/router"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
+4 -4
View File
@@ -1,12 +1,12 @@
package router_test
import (
"atsflare/common"
"atsflare/model"
"atsflare/router"
"atsflare/service"
"bytes"
"encoding/json"
"gin-template/common"
"gin-template/model"
"gin-template/router"
"gin-template/service"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
+3 -3
View File
@@ -1,10 +1,10 @@
package router
import (
"atsflare/common"
"atsflare/controller"
"atsflare/middleware"
"embed"
"gin-template/common"
"gin-template/controller"
"gin-template/middleware"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"net/http"
+2 -2
View File
@@ -1,10 +1,10 @@
package service
import (
"atsflare/common"
"atsflare/model"
"encoding/json"
"errors"
"gin-template/common"
"gin-template/model"
"strings"
"time"
+1 -1
View File
@@ -1,12 +1,12 @@
package service
import (
"atsflare/model"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"gin-template/model"
"sort"
"strings"
"time"
+2 -2
View File
@@ -1,13 +1,13 @@
package service
import (
"atsflare/common"
"atsflare/model"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"gin-template/common"
"gin-template/model"
"math/big"
"path/filepath"
"strings"
+1 -1
View File
@@ -1,9 +1,9 @@
package service
import (
"atsflare/model"
"errors"
"fmt"
"gin-template/model"
"sort"
"strings"
"unicode"
+2 -2
View File
@@ -1,11 +1,11 @@
package service
import (
"atsflare/common"
"atsflare/model"
"crypto/rand"
"encoding/hex"
"errors"
"gin-template/common"
"gin-template/model"
"strings"
"time"
)
+1 -1
View File
@@ -1,9 +1,9 @@
package service
import (
"atsflare/model"
"encoding/json"
"errors"
"gin-template/model"
"net/url"
"regexp"
"strings"
+1 -1
View File
@@ -1,10 +1,10 @@
package service
import (
"atsflare/model"
"crypto/tls"
"errors"
"fmt"
"gin-template/model"
"mime/multipart"
"strings"
)
+1 -3
View File
@@ -41,9 +41,7 @@ function App() {
const res = await API.get('/api/status');
const { success, data } = res.data;
if (success) {
console.log(
`GitHub 仓库地址:https://github.com/songquanpeng/gin-template`
);
console.log(`GitHub 仓库地址:https://github.com/Rain-kl/ATSFlare`);
localStorage.setItem('status', JSON.stringify(data));
statusDispatch({ type: 'set', payload: data });
localStorage.setItem('system_name', data.system_name);
+38 -41
View File
@@ -1,41 +1,38 @@
import React from 'react';
import { Container, Segment } from 'semantic-ui-react';
import { getFooterHTML, getSystemName } from '../helpers';
const Footer = () => {
const systemName = getSystemName();
const footer = getFooterHTML();
return (
<Segment vertical>
<Container textAlign='center'>
{footer ? (
<div
className='custom-footer'
dangerouslySetInnerHTML={{ __html: footer }}
></div>
) : (
<div className='custom-footer'>
<a
href='https://github.com/songquanpeng/gin-template'
target='_blank'
>
{systemName} {process.env.REACT_APP_VERSION}{' '}
</a>
由{' '}
<a href='https://github.com/songquanpeng' target='_blank'>
JustSong
</a>{' '}
构建,源代码遵循{' '}
<a href='https://opensource.org/licenses/mit-license.php'>
MIT 协议
</a>
</div>
)}
</Container>
</Segment>
);
};
export default Footer;
import React from 'react';
import { Container, Segment } from 'semantic-ui-react';
import { getFooterHTML, getSystemName } from '../helpers';
const Footer = () => {
const systemName = getSystemName();
const footer = getFooterHTML();
return (
<Segment vertical>
<Container textAlign='center'>
{footer ? (
<div
className='custom-footer'
dangerouslySetInnerHTML={{ __html: footer }}
></div>
) : (
<div className='custom-footer'>
<a
href='https://github.com/Rain-kl/ATSFlare'
target='_blank'
rel='noreferrer'
>
{systemName} {process.env.REACT_APP_VERSION}{' '}
</a>
开源于 GitHub,源代码遵循{' '}
<a href='https://opensource.org/licenses/mit-license.php'>
MIT 协议
</a>
</div>
)}
</Container>
</Segment>
);
};
export default Footer;
+189 -190
View File
@@ -1,190 +1,189 @@
import React, { useEffect, useState } from 'react';
import { Button, Divider, Form, Grid, Header, Modal } from 'semantic-ui-react';
import { API, showError, showSuccess } from '../helpers';
import { marked } from 'marked';
const OtherSetting = () => {
let [inputs, setInputs] = useState({
Footer: '',
Notice: '',
About: '',
SystemName: '',
HomePageLink: '',
});
let [loading, setLoading] = useState(false);
const [showUpdateModal, setShowUpdateModal] = useState(false);
const [updateData, setUpdateData] = useState({
tag_name: '',
content: '',
});
const getOptions = async () => {
const res = await API.get('/api/option/');
const { success, message, data } = res.data;
if (success) {
let newInputs = {};
data.forEach((item) => {
if (item.key in inputs) {
newInputs[item.key] = item.value;
}
});
setInputs(newInputs);
} else {
showError(message);
}
};
useEffect(() => {
getOptions().then();
}, []);
const updateOption = async (key, value) => {
setLoading(true);
const res = await API.put('/api/option', {
key,
value,
});
const { success, message } = res.data;
if (success) {
setInputs((inputs) => ({ ...inputs, [key]: value }));
} else {
showError(message);
}
setLoading(false);
};
const handleInputChange = async (e, { name, value }) => {
setInputs((inputs) => ({ ...inputs, [name]: value }));
};
const submitNotice = async () => {
await updateOption('Notice', inputs.Notice);
};
const submitFooter = async () => {
await updateOption('Footer', inputs.Footer);
};
const submitSystemName = async () => {
await updateOption('SystemName', inputs.SystemName);
};
const submitHomePageLink = async () => {
await updateOption('HomePageLink', inputs.HomePageLink);
};
const submitAbout = async () => {
await updateOption('About', inputs.About);
};
const openGitHubRelease = () => {
window.location =
'https://github.com/songquanpeng/gin-template/releases/latest';
};
const checkUpdate = async () => {
const res = await API.get(
'https://api.github.com/repos/songquanpeng/gin-template/releases/latest'
);
const { tag_name, body } = res.data;
if (tag_name === process.env.REACT_APP_VERSION) {
showSuccess(`已是最新版本:${tag_name}`);
} else {
setUpdateData({
tag_name: tag_name,
content: marked.parse(body),
});
setShowUpdateModal(true);
}
};
return (
<Grid columns={1}>
<Grid.Column>
<Form loading={loading}>
<Header as='h3'>通用设置</Header>
<Form.Button onClick={checkUpdate}>检查更新</Form.Button>
<Form.Group widths='equal'>
<Form.TextArea
label='公告'
placeholder='在此输入新的公告内容'
value={inputs.Notice}
name='Notice'
onChange={handleInputChange}
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
/>
</Form.Group>
<Form.Button onClick={submitNotice}>保存公告</Form.Button>
<Divider />
<Header as='h3'>个性化设置</Header>
<Form.Group widths='equal'>
<Form.Input
label='系统名称'
placeholder='在此输入系统名称'
value={inputs.SystemName}
name='SystemName'
onChange={handleInputChange}
/>
</Form.Group>
<Form.Button onClick={submitSystemName}>设置系统名称</Form.Button>
<Form.Group widths='equal'>
<Form.Input
label='首页链接'
placeholder='在此输入首页链接,设置后将通过 iframe 方式嵌入该网页'
value={inputs.HomePageLink}
name='HomePageLink'
onChange={handleInputChange}
type='url'
/>
</Form.Group>
<Form.Button onClick={submitHomePageLink}>设置首页链接</Form.Button>
<Form.Group widths='equal'>
<Form.TextArea
label='关于'
placeholder='在此输入新的关于内容,支持 Markdown & HTML 代码'
value={inputs.About}
name='About'
onChange={handleInputChange}
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
/>
</Form.Group>
<Form.Button onClick={submitAbout}>保存关于</Form.Button>
<Form.Group widths='equal'>
<Form.Input
label='页脚'
placeholder='在此输入新的页脚,留空则使用默认页脚,支持 HTML 代码'
value={inputs.Footer}
name='Footer'
onChange={handleInputChange}
/>
</Form.Group>
<Form.Button onClick={submitFooter}>设置页脚</Form.Button>
</Form>
</Grid.Column>
<Modal
onClose={() => setShowUpdateModal(false)}
onOpen={() => setShowUpdateModal(true)}
open={showUpdateModal}
>
<Modal.Header>新版本:{updateData.tag_name}</Modal.Header>
<Modal.Content>
<Modal.Description>
<div dangerouslySetInnerHTML={{ __html: updateData.content }}></div>
</Modal.Description>
</Modal.Content>
<Modal.Actions>
<Button onClick={() => setShowUpdateModal(false)}>关闭</Button>
<Button
content='详情'
onClick={() => {
setShowUpdateModal(false);
openGitHubRelease();
}}
/>
</Modal.Actions>
</Modal>
</Grid>
);
};
export default OtherSetting;
import React, { useEffect, useState } from 'react';
import { Button, Divider, Form, Grid, Header, Modal } from 'semantic-ui-react';
import { API, showError, showSuccess } from '../helpers';
import { marked } from 'marked';
const OtherSetting = () => {
let [inputs, setInputs] = useState({
Footer: '',
Notice: '',
About: '',
SystemName: '',
HomePageLink: '',
});
let [loading, setLoading] = useState(false);
const [showUpdateModal, setShowUpdateModal] = useState(false);
const [updateData, setUpdateData] = useState({
tag_name: '',
content: '',
});
const getOptions = async () => {
const res = await API.get('/api/option/');
const { success, message, data } = res.data;
if (success) {
let newInputs = {};
data.forEach((item) => {
if (item.key in inputs) {
newInputs[item.key] = item.value;
}
});
setInputs(newInputs);
} else {
showError(message);
}
};
useEffect(() => {
getOptions().then();
}, []);
const updateOption = async (key, value) => {
setLoading(true);
const res = await API.put('/api/option', {
key,
value,
});
const { success, message } = res.data;
if (success) {
setInputs((inputs) => ({ ...inputs, [key]: value }));
} else {
showError(message);
}
setLoading(false);
};
const handleInputChange = async (e, { name, value }) => {
setInputs((inputs) => ({ ...inputs, [name]: value }));
};
const submitNotice = async () => {
await updateOption('Notice', inputs.Notice);
};
const submitFooter = async () => {
await updateOption('Footer', inputs.Footer);
};
const submitSystemName = async () => {
await updateOption('SystemName', inputs.SystemName);
};
const submitHomePageLink = async () => {
await updateOption('HomePageLink', inputs.HomePageLink);
};
const submitAbout = async () => {
await updateOption('About', inputs.About);
};
const openGitHubRelease = () => {
window.location = 'https://github.com/Rain-kl/ATSFlare/releases/latest';
};
const checkUpdate = async () => {
const res = await API.get(
'https://api.github.com/repos/Rain-kl/ATSFlare/releases/latest'
);
const { tag_name, body } = res.data;
if (tag_name === process.env.REACT_APP_VERSION) {
showSuccess(`已是最新版本:${tag_name}`);
} else {
setUpdateData({
tag_name: tag_name,
content: marked.parse(body),
});
setShowUpdateModal(true);
}
};
return (
<Grid columns={1}>
<Grid.Column>
<Form loading={loading}>
<Header as='h3'>通用设置</Header>
<Form.Button onClick={checkUpdate}>检查更新</Form.Button>
<Form.Group widths='equal'>
<Form.TextArea
label='公告'
placeholder='在此输入新的公告内容'
value={inputs.Notice}
name='Notice'
onChange={handleInputChange}
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
/>
</Form.Group>
<Form.Button onClick={submitNotice}>保存公告</Form.Button>
<Divider />
<Header as='h3'>个性化设置</Header>
<Form.Group widths='equal'>
<Form.Input
label='系统名称'
placeholder='在此输入系统名称'
value={inputs.SystemName}
name='SystemName'
onChange={handleInputChange}
/>
</Form.Group>
<Form.Button onClick={submitSystemName}>设置系统名称</Form.Button>
<Form.Group widths='equal'>
<Form.Input
label='首页链接'
placeholder='在此输入首页链接,设置后将通过 iframe 方式嵌入该网页'
value={inputs.HomePageLink}
name='HomePageLink'
onChange={handleInputChange}
type='url'
/>
</Form.Group>
<Form.Button onClick={submitHomePageLink}>设置首页链接</Form.Button>
<Form.Group widths='equal'>
<Form.TextArea
label='关于'
placeholder='在此输入新的关于内容,支持 Markdown & HTML 代码'
value={inputs.About}
name='About'
onChange={handleInputChange}
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
/>
</Form.Group>
<Form.Button onClick={submitAbout}>保存关于</Form.Button>
<Form.Group widths='equal'>
<Form.Input
label='页脚'
placeholder='在此输入新的页脚,留空则使用默认页脚,支持 HTML 代码'
value={inputs.Footer}
name='Footer'
onChange={handleInputChange}
/>
</Form.Group>
<Form.Button onClick={submitFooter}>设置页脚</Form.Button>
</Form>
</Grid.Column>
<Modal
onClose={() => setShowUpdateModal(false)}
onOpen={() => setShowUpdateModal(true)}
open={showUpdateModal}
>
<Modal.Header>新版本:{updateData.tag_name}</Modal.Header>
<Modal.Content>
<Modal.Description>
<div dangerouslySetInnerHTML={{ __html: updateData.content }}></div>
</Modal.Description>
</Modal.Content>
<Modal.Actions>
<Button onClick={() => setShowUpdateModal(false)}>关闭</Button>
<Button
content='详情'
onClick={() => {
setShowUpdateModal(false);
openGitHubRelease();
}}
/>
</Modal.Actions>
</Modal>
</Grid>
);
};
export default OtherSetting;
+51 -51
View File
@@ -1,51 +1,51 @@
import React, { useEffect, useState } from 'react';
import { Header, Segment } from 'semantic-ui-react';
import { API, showError } from '../../helpers';
import { marked } from 'marked';
const About = () => {
const [about, setAbout] = useState('');
const [aboutLoaded, setAboutLoaded] = useState(false);
const displayAbout = async () => {
setAbout(localStorage.getItem('about') || '');
const res = await API.get('/api/about');
const { success, message, data } = res.data;
if (success) {
let HTMLAbout = marked.parse(data);
setAbout(HTMLAbout);
localStorage.setItem('about', HTMLAbout);
} else {
showError(message);
setAbout('加载关于内容失败...');
}
setAboutLoaded(true);
};
useEffect(() => {
displayAbout().then();
}, []);
return (
<>
<Segment>
{aboutLoaded && about === '' ? (
<>
<Header as='h3'>关于</Header>
<p>可在设置页面设置关于内容,支持 HTML & Markdown</p>
项目仓库地址:
<a href='https://github.com/songquanpeng/gin-template'>
https://github.com/songquanpeng/gin-template
</a>
</>
) : (
<>
<div dangerouslySetInnerHTML={{ __html: about }}></div>
</>
)}
</Segment>
</>
);
};
export default About;
import React, { useEffect, useState } from 'react';
import { Header, Segment } from 'semantic-ui-react';
import { API, showError } from '../../helpers';
import { marked } from 'marked';
const About = () => {
const [about, setAbout] = useState('');
const [aboutLoaded, setAboutLoaded] = useState(false);
const displayAbout = async () => {
setAbout(localStorage.getItem('about') || '');
const res = await API.get('/api/about');
const { success, message, data } = res.data;
if (success) {
let HTMLAbout = marked.parse(data);
setAbout(HTMLAbout);
localStorage.setItem('about', HTMLAbout);
} else {
showError(message);
setAbout('加载关于内容失败...');
}
setAboutLoaded(true);
};
useEffect(() => {
displayAbout().then();
}, []);
return (
<>
<Segment>
{aboutLoaded && about === '' ? (
<>
<Header as='h3'>关于</Header>
<p>可在设置页面设置关于内容,支持 HTML & Markdown</p>
项目仓库地址:
<a href='https://github.com/Rain-kl/ATSFlare'>
https://github.com/Rain-kl/ATSFlare
</a>
</>
) : (
<>
<div dangerouslySetInnerHTML={{ __html: about }}></div>
</>
)}
</Segment>
</>
);
};
export default About;
+110 -110
View File
@@ -1,110 +1,110 @@
import React, { useContext, useEffect } from 'react';
import { Card, Grid, Header, Segment } from 'semantic-ui-react';
import { API, showError, showNotice, timestamp2string } from '../../helpers';
import { StatusContext } from '../../context/Status';
const Home = () => {
const [statusState, statusDispatch] = useContext(StatusContext);
const homePageLink = localStorage.getItem('home_page_link') || '';
const displayNotice = async () => {
const res = await API.get('/api/notice');
const { success, message, data } = res.data;
if (success) {
let oldNotice = localStorage.getItem('notice');
if (data !== oldNotice && data !== '') {
showNotice(data);
localStorage.setItem('notice', data);
}
} else {
showError(message);
}
};
const getStartTimeString = () => {
const timestamp = statusState?.status?.start_time;
return timestamp2string(timestamp);
};
useEffect(() => {
displayNotice().then();
}, []);
return (
<>
{homePageLink !== '' ? (
<>
<iframe
src={homePageLink}
style={{ width: '100%', height: '100vh', border: 'none' }}
/>
</>
) : (
<>
<Segment>
<Header as='h3'>系统状况</Header>
<Grid columns={2} stackable>
<Grid.Column>
<Card fluid>
<Card.Content>
<Card.Header>系统信息</Card.Header>
<Card.Meta>系统信息总览</Card.Meta>
<Card.Description>
<p>名称:{statusState?.status?.system_name}</p>
<p>版本:{statusState?.status?.version}</p>
<p>
源码:
<a
href='https://github.com/songquanpeng/gin-template'
target='_blank'
>
https://github.com/songquanpeng/gin-template
</a>
</p>
<p>启动时间:{getStartTimeString()}</p>
</Card.Description>
</Card.Content>
</Card>
</Grid.Column>
<Grid.Column>
<Card fluid>
<Card.Content>
<Card.Header>系统配置</Card.Header>
<Card.Meta>系统配置总览</Card.Meta>
<Card.Description>
<p>
邮箱验证:
{statusState?.status?.email_verification === true
? '已启用'
: '未启用'}
</p>
<p>
GitHub 身份验证:
{statusState?.status?.github_oauth === true
? '已启用'
: '未启用'}
</p>
<p>
微信身份验证:
{statusState?.status?.wechat_login === true
? '已启用'
: '未启用'}
</p>
<p>
Turnstile 用户校验:
{statusState?.status?.turnstile_check === true
? '已启用'
: '未启用'}
</p>
</Card.Description>
</Card.Content>
</Card>
</Grid.Column>
</Grid>
</Segment>
</>
)}
</>
);
};
export default Home;
import React, { useContext, useEffect } from 'react';
import { Card, Grid, Header, Segment } from 'semantic-ui-react';
import { API, showError, showNotice, timestamp2string } from '../../helpers';
import { StatusContext } from '../../context/Status';
const Home = () => {
const [statusState, statusDispatch] = useContext(StatusContext);
const homePageLink = localStorage.getItem('home_page_link') || '';
const displayNotice = async () => {
const res = await API.get('/api/notice');
const { success, message, data } = res.data;
if (success) {
let oldNotice = localStorage.getItem('notice');
if (data !== oldNotice && data !== '') {
showNotice(data);
localStorage.setItem('notice', data);
}
} else {
showError(message);
}
};
const getStartTimeString = () => {
const timestamp = statusState?.status?.start_time;
return timestamp2string(timestamp);
};
useEffect(() => {
displayNotice().then();
}, []);
return (
<>
{homePageLink !== '' ? (
<>
<iframe
src={homePageLink}
style={{ width: '100%', height: '100vh', border: 'none' }}
/>
</>
) : (
<>
<Segment>
<Header as='h3'>系统状况</Header>
<Grid columns={2} stackable>
<Grid.Column>
<Card fluid>
<Card.Content>
<Card.Header>系统信息</Card.Header>
<Card.Meta>系统信息总览</Card.Meta>
<Card.Description>
<p>名称:{statusState?.status?.system_name}</p>
<p>版本:{statusState?.status?.version}</p>
<p>
源码:
<a
href='https://github.com/Rain-kl/ATSFlare'
target='_blank'
>
https://github.com/Rain-kl/ATSFlare
</a>
</p>
<p>启动时间:{getStartTimeString()}</p>
</Card.Description>
</Card.Content>
</Card>
</Grid.Column>
<Grid.Column>
<Card fluid>
<Card.Content>
<Card.Header>系统配置</Card.Header>
<Card.Meta>系统配置总览</Card.Meta>
<Card.Description>
<p>
邮箱验证:
{statusState?.status?.email_verification === true
? '已启用'
: '未启用'}
</p>
<p>
GitHub 身份验证:
{statusState?.status?.github_oauth === true
? '已启用'
: '未启用'}
</p>
<p>
微信身份验证:
{statusState?.status?.wechat_login === true
? '已启用'
: '未启用'}
</p>
<p>
Turnstile 用户校验:
{statusState?.status?.turnstile_check === true
? '已启用'
: '未启用'}
</p>
</Card.Description>
</Card.Content>
</Card>
</Grid.Column>
</Grid>
</Segment>
</>
)}
</>
);
};
export default Home;
+2 -2
View File
@@ -40,13 +40,13 @@ npm run build
```bash
cd atsf_server
export SESSION_SECRET='replace-with-random-string'
export SQLITE_PATH='./gin-template.db'
export SQLITE_PATH='./atsflare.db'
go run .
```
说明:
- 如果未设置 `SQLITE_PATH`,默认也会落到 `atsf_server/gin-template.db`
- 如果未设置 `SQLITE_PATH`,默认也会落到 `atsf_server/atsflare.db`
- 当前不再依赖全局 `AGENT_TOKEN` 环境变量
- 节点接入凭证改由数据库保存:节点专属 `agent_token` + 系统级 `discovery token`
- 当前默认监听端口为 `3000`
+5 -5
View File
@@ -94,12 +94,12 @@
### Server
控制中心直接基于现有 `atsf_server` 的 `gin-template` 工程开发:
控制中心直接基于现有 `atsf_server` 的 `ATSFlare` 工程开发:
* Web 框架:Gin
* ORM:GORM
* 前端:沿用现有 web 管理端
* 鉴权:沿用 gin-template 登录体系
* 鉴权:沿用 ATSFlare 登录体系
### 数据库
@@ -139,7 +139,7 @@ Agent 使用 Go 单体程序:
```text
┌────────────────────────────┐
│ ATSFlare Server │
│ gin-template + SQLite │
│ ATSFlare + SQLite │
│ Admin UI + Admin API │
└──────────────┬─────────────┘
│
@@ -548,7 +548,7 @@ Agent 每次上报:
管理端:
* 直接沿用 gin-template 的登录态
* 直接沿用 ATSFlare 的登录态
Agent(第一版):
@@ -567,7 +567,7 @@ Agent(第二版):
### 12.1 登录页
沿用 gin-template 现有登录。
沿用 ATSFlare 现有登录。
### 12.2 反代规则页(第一版,已实现)
+3 -3
View File
@@ -41,7 +41,7 @@
* ORM:GORM
* 数据库:SQLite
* 前端:现有 `atsf_server/web`
* 登录体系:沿用 gin-template 现有能力
* 登录体系:沿用 ATSFlare 现有能力
约束:
@@ -126,7 +126,7 @@ Agent 放在 `atsf_agent`,使用 Go 单体程序开发。
* 所有发布都是"新版本激活",不是在线覆盖编辑。
* 第一版与第二版:所有节点默认拉同一份全量配置,不做节点分组差异化下发。
* 能用 SQLite 解决的问题,不引入额外中间件。
* 新功能优先复用现有 gin-template 结构,不平行造第二套框架。
* 新功能优先复用现有 ATSFlare 结构,不平行造第二套框架。
## 5. 数据模型规范
@@ -205,7 +205,7 @@ Server 代码按以下职责拆分:
管理端:
* 继续复用 gin-template 的登录、角色和 session 体系
* 继续复用 ATSFlare 的登录、角色和 session 体系
Agent(第一版):
+2 -2
View File
@@ -138,7 +138,7 @@ MVP 已于第一版完成。当前进入第二版迭代。
* 节点配置文件填写节点专属 `agent_token` 时,可直接上线;若 `agent_token` 为空且填写全局 discovery token,则会自动注册并完成 token 置换
### V2 Phase 4: 路由自定义头
### V2 Phase 4: 路由自定义头 ✅
目标:
@@ -155,7 +155,7 @@ MVP 已于第一版完成。当前进入第二版迭代。
* 路由配置自定义头后发布,渲染结果包含对应 `proxy_set_header` 指令
* 不配置自定义头的路由渲染行为与之前保持一致
### V2 Phase 5: 配置预览与变更摘要
### V2 Phase 5: 配置预览与变更摘要 ✅
目标: