diff --git a/.github/workflows/docker-image-amd64.yml b/.github/workflows/docker-image-amd64.yml
index 1a77775c..e3b8439a 100644
--- a/.github/workflows/docker-image-amd64.yml
+++ b/.github/workflows/docker-image-amd64.yml
@@ -42,7 +42,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
- justsong/gin-template
+ justsong/one-api
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
diff --git a/.github/workflows/docker-image-arm64.yml b/.github/workflows/docker-image-arm64.yml
index 5ffd1555..7304e5c9 100644
--- a/.github/workflows/docker-image-arm64.yml
+++ b/.github/workflows/docker-image-arm64.yml
@@ -48,7 +48,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
- justsong/gin-template
+ justsong/one-api
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
diff --git a/.github/workflows/linux-release.yml b/.github/workflows/linux-release.yml
index ac84675d..2696fbfb 100644
--- a/.github/workflows/linux-release.yml
+++ b/.github/workflows/linux-release.yml
@@ -30,20 +30,20 @@ jobs:
- 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
+ go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o one-api
- 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
+ CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o one-api-arm64
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
- gin-template
- gin-template-arm64
+ one-api
+ one-api-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/macos-release.yml b/.github/workflows/macos-release.yml
index 39850d86..7f4e48b1 100644
--- a/.github/workflows/macos-release.yml
+++ b/.github/workflows/macos-release.yml
@@ -30,11 +30,11 @@ jobs:
- name: Build Backend
run: |
go mod download
- go build -ldflags "-X 'gin-template/common.Version=$(git describe --tags)'" -o gin-template-macos
+ go build -ldflags "-X 'one-api/common.Version=$(git describe --tags)'" -o one-api-macos
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
- files: gin-template-macos
+ files: one-api-macos
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/windows-release.yml b/.github/workflows/windows-release.yml
index e9877f87..525f0524 100644
--- a/.github/workflows/windows-release.yml
+++ b/.github/workflows/windows-release.yml
@@ -33,11 +33,11 @@ jobs:
- name: Build Backend
run: |
go mod download
- go build -ldflags "-s -w -X 'gin-template/common.Version=$(git describe --tags)'" -o gin-template.exe
+ go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)'" -o one-api.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
- files: gin-template.exe
+ files: one-api.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 7b2dc9ae..a8df7683 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,7 +16,7 @@ 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
+RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
FROM alpine
@@ -25,7 +25,7 @@ RUN apk update \
&& apk add --no-cache ca-certificates tzdata \
&& update-ca-certificates 2>/dev/null || true
ENV PORT=3000
-COPY --from=builder2 /build/gin-template /
+COPY --from=builder2 /build/one-api /
EXPOSE 3000
WORKDIR /data
-ENTRYPOINT ["/gin-template"]
+ENTRYPOINT ["/one-api"]
diff --git a/README.en.md b/README.en.md
index eb98bc16..7387244e 100644
--- a/README.en.md
+++ b/README.en.md
@@ -3,7 +3,7 @@
-
+
@@ -15,28 +15,28 @@ _✨ Template for Gin & React projects ✨_
-
-
+
+
-
-
+
+
-
-
+
+
-
+
- Download
+ Download
·
- Tutorial
+ Tutorial
·
- Feedback
+ Feedback
·
- Demo
+ Demo
## Features
@@ -54,23 +54,23 @@ _✨ Template for Gin & React projects ✨_
## Deployment
### Manual deployment
-1. Download built binary from [GitHub Releases](https://github.com/songquanpeng/gin-template/releases/latest) or build from source:
+1. Download built binary from [GitHub Releases](https://github.com/songquanpeng/one-api/releases/latest) or build from source:
```shell
- git clone https://github.com/songquanpeng/gin-template.git
+ git clone https://github.com/songquanpeng/one-api.git
go mod download
- go build -ldflags "-s -w" -o gin-template
+ go build -ldflags "-s -w" -o one-api
````
2. Run it:
```shell
- chmod u+x gin-template
- ./gin-template --port 3000 --log-dir ./logs
+ chmod u+x one-api
+ ./one-api --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`
+Execute: `docker run -d --restart always -p 3000:3000 -v /home/ubuntu/data/one-api:/data -v /etc/ssl/certs:/etc/ssl/certs:ro justsong/one-api`
-Data will be saved in `/home/ubuntu/data/gin-template`.
+Data will be saved in `/home/ubuntu/data/one-api`.
## Configurations
The system works out of the box.
@@ -85,7 +85,7 @@ After the system starts, use `root` user to log in to the system and do further
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`
+ + Example: `SQL_DSN=root:123456@tcp(localhost:3306)/one-api`
### Command line Arguments
1. `--port `: specify the port number, the default value is `3000`.
diff --git a/README.md b/README.md
index ca31553d..316f7ed4 100644
--- a/README.md
+++ b/README.md
@@ -3,40 +3,40 @@
-
+
-# Gin 项目模板
+# Gin One API
_✨ 用于 Gin & React 项目的模板 ✨_
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
- 程序下载
+ 程序下载
·
- 部署教程
+ 部署教程
·
- 意见反馈
+ 意见反馈
·
- 在线演示
+ 在线演示
## 功能
@@ -54,25 +54,25 @@ _✨ 用于 Gin & React 项目的模板 ✨_
## 部署
### 手动部署
-1. 从 [GitHub Releases](https://github.com/songquanpeng/gin-template/releases/latest) 下载可执行文件或者从源码编译:
+1. 从 [GitHub Releases](https://github.com/songquanpeng/one-api/releases/latest) 下载可执行文件或者从源码编译:
```shell
- git clone https://github.com/songquanpeng/gin-template.git
+ git clone https://github.com/songquanpeng/one-api.git
go mod download
- go build -ldflags "-s -w" -o gin-template
+ go build -ldflags "-s -w" -o one-api
````
2. 运行:
```shell
- chmod u+x gin-template
- ./gin-template --port 3000 --log-dir ./logs
+ chmod u+x one-api
+ ./one-api --port 3000 --log-dir ./logs
```
3. 访问 [http://localhost:3000/](http://localhost:3000/) 并登录。初始账号用户名为 `root`,密码为 `123456`。
更加详细的部署教程[参见此处](https://iamazing.cn/page/how-to-deploy-a-website)。
### 基于 Docker 进行部署
-执行:`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`
+执行:`docker run -d --restart always -p 3000:3000 -v /home/ubuntu/data/one-api:/data -v /etc/ssl/certs:/etc/ssl/certs:ro justsong/one-api`
-数据将会保存在宿主机的 `/home/ubuntu/data/gin-template` 目录。
+数据将会保存在宿主机的 `/home/ubuntu/data/one-api` 目录。
## 配置
系统本身开箱即用。
@@ -87,7 +87,7 @@ _✨ 用于 Gin & React 项目的模板 ✨_
2. `SESSION_SECRET`:设置之后将使用固定的会话密钥,这样系统重新启动后已登录用户的 cookie 将依旧有效。
+ 例子:`SESSION_SECRET=random_string`
3. `SQL_DSN`:设置之后将使用指定数据库而非 SQLite。
- + 例子:`SQL_DSN=root:123456@tcp(localhost:3306)/gin-template`
+ + 例子:`SQL_DSN=root:123456@tcp(localhost:3306)/one-api`
### 命令行参数
1. `--port `: 指定服务器监听的端口号,默认为 `3000`。
diff --git a/common/constants.go b/common/constants.go
index 15bdba0c..f3294a42 100644
--- a/common/constants.go
+++ b/common/constants.go
@@ -8,14 +8,14 @@ import (
var StartTime = time.Now().Unix() // unit: second
var Version = "v0.0.0" // this hard coding will be replaced automatically when building, no need to manually change
-var SystemName = "项目模板"
+var SystemName = "One API"
var ServerAddress = "http://localhost:3000"
var Footer = ""
// Any options with "Secret", "Token" in its key won't be return by GetOptions
var SessionSecret = uuid.New().String()
-var SQLitePath = "gin-template.db"
+var SQLitePath = "one-api.db"
var OptionMap map[string]string
var OptionMapRWMutex sync.RWMutex
diff --git a/controller/file.go b/controller/file.go
index 0c1e2efb..64523622 100644
--- a/controller/file.go
+++ b/controller/file.go
@@ -2,10 +2,10 @@ package controller
import (
"fmt"
- "gin-template/common"
- "gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/model"
"path/filepath"
"strconv"
"strings"
diff --git a/controller/github.go b/controller/github.go
index 780de43b..93c2e8d3 100644
--- a/controller/github.go
+++ b/controller/github.go
@@ -5,11 +5,11 @@ import (
"encoding/json"
"errors"
"fmt"
- "gin-template/common"
- "gin-template/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/model"
"strconv"
"time"
)
diff --git a/controller/misc.go b/controller/misc.go
index 8cda624c..aa5a77f8 100644
--- a/controller/misc.go
+++ b/controller/misc.go
@@ -3,10 +3,10 @@ package controller
import (
"encoding/json"
"fmt"
- "gin-template/common"
- "gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/model"
)
func GetStatus(c *gin.Context) {
diff --git a/controller/option.go b/controller/option.go
index 394f2896..b5b675c6 100644
--- a/controller/option.go
+++ b/controller/option.go
@@ -2,10 +2,10 @@ package controller
import (
"encoding/json"
- "gin-template/common"
- "gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/model"
"strings"
)
diff --git a/controller/user.go b/controller/user.go
index 7cbef9f7..ce5f2862 100644
--- a/controller/user.go
+++ b/controller/user.go
@@ -2,12 +2,12 @@ package controller
import (
"encoding/json"
- "gin-template/common"
- "gin-template/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"net/http"
+ "one-api/common"
+ "one-api/model"
"strconv"
"strings"
)
diff --git a/controller/wechat.go b/controller/wechat.go
index f7d8dfc2..5620e8d3 100644
--- a/controller/wechat.go
+++ b/controller/wechat.go
@@ -4,10 +4,10 @@ import (
"encoding/json"
"errors"
"fmt"
- "gin-template/common"
- "gin-template/model"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/model"
"strconv"
"time"
)
diff --git a/go.mod b/go.mod
index 047dabb2..7da19284 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module gin-template
+module one-api
// +heroku goVersion go1.18
go 1.18
diff --git a/main.go b/main.go
index 42fadbbb..3fd87c1c 100644
--- a/main.go
+++ b/main.go
@@ -2,16 +2,16 @@ package main
import (
"embed"
- "gin-template/common"
- "gin-template/middleware"
- "gin-template/model"
- "gin-template/router"
"github.com/gin-contrib/gzip"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-contrib/sessions/redis"
"github.com/gin-gonic/gin"
"log"
+ "one-api/common"
+ "one-api/middleware"
+ "one-api/model"
+ "one-api/router"
"os"
"strconv"
)
diff --git a/middleware/auth.go b/middleware/auth.go
index 488bf02b..427217e2 100644
--- a/middleware/auth.go
+++ b/middleware/auth.go
@@ -1,11 +1,11 @@
package middleware
import (
- "gin-template/common"
- "gin-template/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/model"
)
func authHelper(c *gin.Context, minRole int) {
diff --git a/middleware/cors.go b/middleware/cors.go
index 170cca3e..39c05697 100644
--- a/middleware/cors.go
+++ b/middleware/cors.go
@@ -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://one-api.vercel.app", "http://localhost:3000/"}
return cors.New(config)
}
diff --git a/middleware/rate-limit.go b/middleware/rate-limit.go
index 410ed19e..8e5cff6c 100644
--- a/middleware/rate-limit.go
+++ b/middleware/rate-limit.go
@@ -3,9 +3,9 @@ package middleware
import (
"context"
"fmt"
- "gin-template/common"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
"time"
)
diff --git a/middleware/turnstile-check.go b/middleware/turnstile-check.go
index b7401b79..26688810 100644
--- a/middleware/turnstile-check.go
+++ b/middleware/turnstile-check.go
@@ -2,11 +2,11 @@ package middleware
import (
"encoding/json"
- "gin-template/common"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
"net/url"
+ "one-api/common"
)
type turnstileCheckResponse struct {
diff --git a/model/file.go b/model/file.go
index 2ff7a1f8..390b2e2e 100644
--- a/model/file.go
+++ b/model/file.go
@@ -1,9 +1,9 @@
package model
import (
- "gin-template/common"
_ "gorm.io/driver/sqlite"
"gorm.io/gorm"
+ "one-api/common"
"os"
"path"
)
diff --git a/model/main.go b/model/main.go
index 0a64651f..d8f7ac3a 100644
--- a/model/main.go
+++ b/model/main.go
@@ -1,10 +1,10 @@
package model
import (
- "gin-template/common"
"gorm.io/driver/mysql"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
+ "one-api/common"
"os"
)
diff --git a/model/option.go b/model/option.go
index 881d0282..a30a8b1d 100644
--- a/model/option.go
+++ b/model/option.go
@@ -1,7 +1,7 @@
package model
import (
- "gin-template/common"
+ "one-api/common"
"strconv"
"strings"
)
diff --git a/model/user.go b/model/user.go
index b5dd9900..496417b4 100644
--- a/model/user.go
+++ b/model/user.go
@@ -2,7 +2,7 @@ package model
import (
"errors"
- "gin-template/common"
+ "one-api/common"
"strings"
)
diff --git a/router/api-router.go b/router/api-router.go
index e43665af..57775431 100644
--- a/router/api-router.go
+++ b/router/api-router.go
@@ -1,9 +1,9 @@
package router
import (
- "gin-template/controller"
- "gin-template/middleware"
"github.com/gin-gonic/gin"
+ "one-api/controller"
+ "one-api/middleware"
)
func SetApiRouter(router *gin.Engine) {
diff --git a/router/web-router.go b/router/web-router.go
index 1cb06633..8201b09e 100644
--- a/router/web-router.go
+++ b/router/web-router.go
@@ -2,12 +2,12 @@ package router
import (
"embed"
- "gin-template/common"
- "gin-template/controller"
- "gin-template/middleware"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"net/http"
+ "one-api/common"
+ "one-api/controller"
+ "one-api/middleware"
)
func setWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
diff --git a/web/public/favicon.ico b/web/public/favicon.ico
index a11777cc..c2c8de0c 100644
Binary files a/web/public/favicon.ico and b/web/public/favicon.ico differ
diff --git a/web/public/index.html b/web/public/index.html
index ea91592b..b7134f53 100644
--- a/web/public/index.html
+++ b/web/public/index.html
@@ -9,7 +9,7 @@
name="description"
content="Web site created using create-react-app"
/>
- 项目模板
+ One API
You need to enable JavaScript to run this app.
diff --git a/web/public/logo.png b/web/public/logo.png
index fc44b0a3..0f237a22 100644
Binary files a/web/public/logo.png and b/web/public/logo.png differ
diff --git a/web/src/components/Footer.js b/web/src/components/Footer.js
index 122e2fcc..d51ccce3 100644
--- a/web/src/components/Footer.js
+++ b/web/src/components/Footer.js
@@ -16,10 +16,10 @@ const Footer = () => {
{Footer === '' ? (