Rename to One API
This commit is contained in:
parent
ab1f8a2bf4
commit
539eac217f
2
.github/workflows/docker-image-amd64.yml
vendored
2
.github/workflows/docker-image-amd64.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
|||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
justsong/gin-template
|
justsong/one-api
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
|
2
.github/workflows/docker-image-arm64.yml
vendored
2
.github/workflows/docker-image-arm64.yml
vendored
@ -48,7 +48,7 @@ jobs:
|
|||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
justsong/gin-template
|
justsong/one-api
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
|
8
.github/workflows/linux-release.yml
vendored
8
.github/workflows/linux-release.yml
vendored
@ -30,20 +30,20 @@ jobs:
|
|||||||
- name: Build Backend (amd64)
|
- name: Build Backend (amd64)
|
||||||
run: |
|
run: |
|
||||||
go mod download
|
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)
|
- name: Build Backend (arm64)
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install gcc-aarch64-linux-gnu
|
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
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
gin-template
|
one-api
|
||||||
gin-template-arm64
|
one-api-arm64
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
4
.github/workflows/macos-release.yml
vendored
4
.github/workflows/macos-release.yml
vendored
@ -30,11 +30,11 @@ jobs:
|
|||||||
- name: Build Backend
|
- name: Build Backend
|
||||||
run: |
|
run: |
|
||||||
go mod download
|
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
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: gin-template-macos
|
files: one-api-macos
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
4
.github/workflows/windows-release.yml
vendored
4
.github/workflows/windows-release.yml
vendored
@ -33,11 +33,11 @@ jobs:
|
|||||||
- name: Build Backend
|
- name: Build Backend
|
||||||
run: |
|
run: |
|
||||||
go mod download
|
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
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: gin-template.exe
|
files: one-api.exe
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -16,7 +16,7 @@ WORKDIR /build
|
|||||||
COPY . .
|
COPY . .
|
||||||
COPY --from=builder /build/build ./web/build
|
COPY --from=builder /build/build ./web/build
|
||||||
RUN go mod download
|
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
|
FROM alpine
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ RUN apk update \
|
|||||||
&& apk add --no-cache ca-certificates tzdata \
|
&& apk add --no-cache ca-certificates tzdata \
|
||||||
&& update-ca-certificates 2>/dev/null || true
|
&& update-ca-certificates 2>/dev/null || true
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
COPY --from=builder2 /build/gin-template /
|
COPY --from=builder2 /build/one-api /
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
ENTRYPOINT ["/gin-template"]
|
ENTRYPOINT ["/one-api"]
|
||||||
|
40
README.en.md
40
README.en.md
@ -3,7 +3,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<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>
|
<a href="https://github.com/songquanpeng/one-api"><img src="https://raw.githubusercontent.com/songquanpeng/one-api/main/web/public/logo.png" width="150" height="150" alt="one-api logo"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
@ -15,28 +15,28 @@ _✨ Template for Gin & React projects ✨_
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://raw.githubusercontent.com/songquanpeng/gin-template/main/LICENSE">
|
<a href="https://raw.githubusercontent.com/songquanpeng/one-api/main/LICENSE">
|
||||||
<img src="https://img.shields.io/github/license/songquanpeng/gin-template?color=brightgreen" alt="license">
|
<img src="https://img.shields.io/github/license/songquanpeng/one-api?color=brightgreen" alt="license">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/songquanpeng/gin-template/releases/latest">
|
<a href="https://github.com/songquanpeng/one-api/releases/latest">
|
||||||
<img src="https://img.shields.io/github/v/release/songquanpeng/gin-template?color=brightgreen&include_prereleases" alt="release">
|
<img src="https://img.shields.io/github/v/release/songquanpeng/one-api?color=brightgreen&include_prereleases" alt="release">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/songquanpeng/gin-template/releases/latest">
|
<a href="https://github.com/songquanpeng/one-api/releases/latest">
|
||||||
<img src="https://img.shields.io/github/downloads/songquanpeng/gin-template/total?color=brightgreen&include_prereleases" alt="release">
|
<img src="https://img.shields.io/github/downloads/songquanpeng/one-api/total?color=brightgreen&include_prereleases" alt="release">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://goreportcard.com/report/github.com/songquanpeng/go-file">
|
<a href="https://goreportcard.com/report/github.com/songquanpeng/go-file">
|
||||||
<img src="https://goreportcard.com/badge/github.com/songquanpeng/gin-template" alt="GoReportCard">
|
<img src="https://goreportcard.com/badge/github.com/songquanpeng/one-api" alt="GoReportCard">
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/songquanpeng/gin-template/releases">Download</a>
|
<a href="https://github.com/songquanpeng/one-api/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/one-api/blob/main/README.en.md#deployment">Tutorial</a>
|
||||||
·
|
·
|
||||||
<a href="https://github.com/songquanpeng/gin-template/issues">Feedback</a>
|
<a href="https://github.com/songquanpeng/one-api/issues">Feedback</a>
|
||||||
·
|
·
|
||||||
<a href="https://gin-template.vercel.app/">Demo</a>
|
<a href="https://one-api.vercel.app/">Demo</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@ -54,23 +54,23 @@ _✨ Template for Gin & React projects ✨_
|
|||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
### Manual 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
|
```shell
|
||||||
git clone https://github.com/songquanpeng/gin-template.git
|
git clone https://github.com/songquanpeng/one-api.git
|
||||||
go mod download
|
go mod download
|
||||||
go build -ldflags "-s -w" -o gin-template
|
go build -ldflags "-s -w" -o one-api
|
||||||
````
|
````
|
||||||
2. Run it:
|
2. Run it:
|
||||||
```shell
|
```shell
|
||||||
chmod u+x gin-template
|
chmod u+x one-api
|
||||||
./gin-template --port 3000 --log-dir ./logs
|
./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`.
|
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
|
### 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
|
## Configurations
|
||||||
The system works out of the box.
|
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.
|
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`
|
+ Example: `SESSION_SECRET=random_string`
|
||||||
3. `SQL_DSN`: when set, the target SQL database will be used instead of SQLite.
|
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
|
### Command line Arguments
|
||||||
1. `--port <port_number>`: specify the port number, the default value is `3000`.
|
1. `--port <port_number>`: specify the port number, the default value is `3000`.
|
||||||
|
44
README.md
44
README.md
@ -3,40 +3,40 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<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>
|
<a href="https://github.com/songquanpeng/one-api"><img src="https://raw.githubusercontent.com/songquanpeng/one-api/main/web/public/logo.png" width="150" height="150" alt="one-api logo"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
# Gin 项目模板
|
# Gin One API
|
||||||
|
|
||||||
_✨ 用于 Gin & React 项目的模板 ✨_
|
_✨ 用于 Gin & React 项目的模板 ✨_
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://raw.githubusercontent.com/songquanpeng/gin-template/main/LICENSE">
|
<a href="https://raw.githubusercontent.com/songquanpeng/one-api/main/LICENSE">
|
||||||
<img src="https://img.shields.io/github/license/songquanpeng/gin-template?color=brightgreen" alt="license">
|
<img src="https://img.shields.io/github/license/songquanpeng/one-api?color=brightgreen" alt="license">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/songquanpeng/gin-template/releases/latest">
|
<a href="https://github.com/songquanpeng/one-api/releases/latest">
|
||||||
<img src="https://img.shields.io/github/v/release/songquanpeng/gin-template?color=brightgreen&include_prereleases" alt="release">
|
<img src="https://img.shields.io/github/v/release/songquanpeng/one-api?color=brightgreen&include_prereleases" alt="release">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/songquanpeng/gin-template/releases/latest">
|
<a href="https://github.com/songquanpeng/one-api/releases/latest">
|
||||||
<img src="https://img.shields.io/github/downloads/songquanpeng/gin-template/total?color=brightgreen&include_prereleases" alt="release">
|
<img src="https://img.shields.io/github/downloads/songquanpeng/one-api/total?color=brightgreen&include_prereleases" alt="release">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://goreportcard.com/report/github.com/songquanpeng/gin-template">
|
<a href="https://goreportcard.com/report/github.com/songquanpeng/one-api">
|
||||||
<img src="https://goreportcard.com/badge/github.com/songquanpeng/gin-template" alt="GoReportCard">
|
<img src="https://goreportcard.com/badge/github.com/songquanpeng/one-api" alt="GoReportCard">
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/songquanpeng/gin-template/releases">程序下载</a>
|
<a href="https://github.com/songquanpeng/one-api/releases">程序下载</a>
|
||||||
·
|
·
|
||||||
<a href="https://github.com/songquanpeng/gin-template#部署">部署教程</a>
|
<a href="https://github.com/songquanpeng/one-api#部署">部署教程</a>
|
||||||
·
|
·
|
||||||
<a href="https://github.com/songquanpeng/gin-template/issues">意见反馈</a>
|
<a href="https://github.com/songquanpeng/one-api/issues">意见反馈</a>
|
||||||
·
|
·
|
||||||
<a href="https://gin-template.vercel.app/">在线演示</a>
|
<a href="https://one-api.vercel.app/">在线演示</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
@ -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
|
```shell
|
||||||
git clone https://github.com/songquanpeng/gin-template.git
|
git clone https://github.com/songquanpeng/one-api.git
|
||||||
go mod download
|
go mod download
|
||||||
go build -ldflags "-s -w" -o gin-template
|
go build -ldflags "-s -w" -o one-api
|
||||||
````
|
````
|
||||||
2. 运行:
|
2. 运行:
|
||||||
```shell
|
```shell
|
||||||
chmod u+x gin-template
|
chmod u+x one-api
|
||||||
./gin-template --port 3000 --log-dir ./logs
|
./one-api --port 3000 --log-dir ./logs
|
||||||
```
|
```
|
||||||
3. 访问 [http://localhost:3000/](http://localhost:3000/) 并登录。初始账号用户名为 `root`,密码为 `123456`。
|
3. 访问 [http://localhost:3000/](http://localhost:3000/) 并登录。初始账号用户名为 `root`,密码为 `123456`。
|
||||||
|
|
||||||
更加详细的部署教程[参见此处](https://iamazing.cn/page/how-to-deploy-a-website)。
|
更加详细的部署教程[参见此处](https://iamazing.cn/page/how-to-deploy-a-website)。
|
||||||
|
|
||||||
### 基于 Docker 进行部署
|
### 基于 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 将依旧有效。
|
2. `SESSION_SECRET`:设置之后将使用固定的会话密钥,这样系统重新启动后已登录用户的 cookie 将依旧有效。
|
||||||
+ 例子:`SESSION_SECRET=random_string`
|
+ 例子:`SESSION_SECRET=random_string`
|
||||||
3. `SQL_DSN`:设置之后将使用指定数据库而非 SQLite。
|
3. `SQL_DSN`:设置之后将使用指定数据库而非 SQLite。
|
||||||
+ 例子:`SQL_DSN=root:123456@tcp(localhost:3306)/gin-template`
|
+ 例子:`SQL_DSN=root:123456@tcp(localhost:3306)/one-api`
|
||||||
|
|
||||||
### 命令行参数
|
### 命令行参数
|
||||||
1. `--port <port_number>`: 指定服务器监听的端口号,默认为 `3000`。
|
1. `--port <port_number>`: 指定服务器监听的端口号,默认为 `3000`。
|
||||||
|
@ -8,14 +8,14 @@ import (
|
|||||||
|
|
||||||
var StartTime = time.Now().Unix() // unit: second
|
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 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 ServerAddress = "http://localhost:3000"
|
||||||
var Footer = ""
|
var Footer = ""
|
||||||
|
|
||||||
// Any options with "Secret", "Token" in its key won't be return by GetOptions
|
// Any options with "Secret", "Token" in its key won't be return by GetOptions
|
||||||
|
|
||||||
var SessionSecret = uuid.New().String()
|
var SessionSecret = uuid.New().String()
|
||||||
var SQLitePath = "gin-template.db"
|
var SQLitePath = "one-api.db"
|
||||||
|
|
||||||
var OptionMap map[string]string
|
var OptionMap map[string]string
|
||||||
var OptionMapRWMutex sync.RWMutex
|
var OptionMapRWMutex sync.RWMutex
|
||||||
|
@ -2,10 +2,10 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -5,11 +5,11 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -3,10 +3,10 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetStatus(c *gin.Context) {
|
func GetStatus(c *gin.Context) {
|
||||||
|
@ -2,10 +2,10 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module gin-template
|
module one-api
|
||||||
|
|
||||||
// +heroku goVersion go1.18
|
// +heroku goVersion go1.18
|
||||||
go 1.18
|
go 1.18
|
||||||
|
8
main.go
8
main.go
@ -2,16 +2,16 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/middleware"
|
|
||||||
"gin-template/model"
|
|
||||||
"gin-template/router"
|
|
||||||
"github.com/gin-contrib/gzip"
|
"github.com/gin-contrib/gzip"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-contrib/sessions/cookie"
|
"github.com/gin-contrib/sessions/cookie"
|
||||||
"github.com/gin-contrib/sessions/redis"
|
"github.com/gin-contrib/sessions/redis"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"log"
|
"log"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/middleware"
|
||||||
|
"one-api/model"
|
||||||
|
"one-api/router"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/model"
|
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func authHelper(c *gin.Context, minRole int) {
|
func authHelper(c *gin.Context, minRole int) {
|
||||||
|
@ -7,6 +7,6 @@ import (
|
|||||||
|
|
||||||
func CORS() gin.HandlerFunc {
|
func CORS() gin.HandlerFunc {
|
||||||
config := cors.DefaultConfig()
|
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)
|
return cors.New(config)
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gin-template/common"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"gin-template/common"
|
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"one-api/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type turnstileCheckResponse struct {
|
type turnstileCheckResponse struct {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gin-template/common"
|
|
||||||
_ "gorm.io/driver/sqlite"
|
_ "gorm.io/driver/sqlite"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"one-api/common"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gin-template/common"
|
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/driver/sqlite"
|
"gorm.io/driver/sqlite"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"one-api/common"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gin-template/common"
|
"one-api/common"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"gin-template/common"
|
"one-api/common"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gin-template/controller"
|
|
||||||
"gin-template/middleware"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"one-api/controller"
|
||||||
|
"one-api/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetApiRouter(router *gin.Engine) {
|
func SetApiRouter(router *gin.Engine) {
|
||||||
|
@ -2,12 +2,12 @@ package router
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"gin-template/common"
|
|
||||||
"gin-template/controller"
|
|
||||||
"gin-template/middleware"
|
|
||||||
"github.com/gin-contrib/static"
|
"github.com/gin-contrib/static"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"one-api/common"
|
||||||
|
"one-api/controller"
|
||||||
|
"one-api/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
|
func setWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 4.2 KiB |
@ -9,7 +9,7 @@
|
|||||||
name="description"
|
name="description"
|
||||||
content="Web site created using create-react-app"
|
content="Web site created using create-react-app"
|
||||||
/>
|
/>
|
||||||
<title>项目模板</title>
|
<title>One API</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 7.9 KiB |
@ -16,10 +16,10 @@ const Footer = () => {
|
|||||||
{Footer === '' ? (
|
{Footer === '' ? (
|
||||||
<div className="custom-footer">
|
<div className="custom-footer">
|
||||||
<a
|
<a
|
||||||
href="https://github.com/songquanpeng/gin-template"
|
href="https://github.com/songquanpeng/one-api"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
项目模板 {process.env.REACT_APP_VERSION}{' '}
|
One API {process.env.REACT_APP_VERSION}{' '}
|
||||||
</a>
|
</a>
|
||||||
由{' '}
|
由{' '}
|
||||||
<a href="https://github.com/songquanpeng" target="_blank">
|
<a href="https://github.com/songquanpeng" target="_blank">
|
||||||
|
@ -105,7 +105,7 @@ const Header = () => {
|
|||||||
style={{ marginRight: '0.75em' }}
|
style={{ marginRight: '0.75em' }}
|
||||||
/>
|
/>
|
||||||
<div style={{ fontSize: '20px' }}>
|
<div style={{ fontSize: '20px' }}>
|
||||||
<b>项目模板</b>
|
<b>One API</b>
|
||||||
</div>
|
</div>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Menu position='right'>
|
<Menu.Menu position='right'>
|
||||||
@ -159,7 +159,7 @@ const Header = () => {
|
|||||||
<Menu.Item as={Link} to='/' className={'hide-on-mobile'}>
|
<Menu.Item as={Link} to='/' className={'hide-on-mobile'}>
|
||||||
<img src='/logo.png' alt='logo' style={{ marginRight: '0.75em' }} />
|
<img src='/logo.png' alt='logo' style={{ marginRight: '0.75em' }} />
|
||||||
<div style={{ fontSize: '20px' }}>
|
<div style={{ fontSize: '20px' }}>
|
||||||
<b>项目模板</b>
|
<b>One API</b>
|
||||||
</div>
|
</div>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
{renderButtons(false)}
|
{renderButtons(false)}
|
||||||
|
@ -90,7 +90,7 @@ const LoginForm = () => {
|
|||||||
return (
|
return (
|
||||||
<Grid textAlign="center" style={{ marginTop: '48px' }}>
|
<Grid textAlign="center" style={{ marginTop: '48px' }}>
|
||||||
<Grid.Column style={{ maxWidth: 450 }}>
|
<Grid.Column style={{ maxWidth: 450 }}>
|
||||||
<Header as="h2" color="teal" textAlign="center">
|
<Header as="h2" color="" textAlign="center">
|
||||||
<Image src="/logo.png" /> 用户登录
|
<Image src="/logo.png" /> 用户登录
|
||||||
</Header>
|
</Header>
|
||||||
<Form size="large">
|
<Form size="large">
|
||||||
@ -114,7 +114,7 @@ const LoginForm = () => {
|
|||||||
value={password}
|
value={password}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<Button color="teal" fluid size="large" onClick={handleSubmit}>
|
<Button color="" fluid size="large" onClick={handleSubmit}>
|
||||||
登录
|
登录
|
||||||
</Button>
|
</Button>
|
||||||
</Segment>
|
</Segment>
|
||||||
@ -179,7 +179,7 @@ const LoginForm = () => {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
color="teal"
|
color=""
|
||||||
fluid
|
fluid
|
||||||
size="large"
|
size="large"
|
||||||
onClick={onSubmitWeChatVerificationCode}
|
onClick={onSubmitWeChatVerificationCode}
|
||||||
|
@ -71,12 +71,12 @@ const OtherSetting = () => {
|
|||||||
|
|
||||||
const openGitHubRelease = () => {
|
const openGitHubRelease = () => {
|
||||||
window.location =
|
window.location =
|
||||||
'https://github.com/songquanpeng/gin-template/releases/latest';
|
'https://github.com/songquanpeng/one-api/releases/latest';
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkUpdate = async () => {
|
const checkUpdate = async () => {
|
||||||
const res = await API.get(
|
const res = await API.get(
|
||||||
'https://api.github.com/repos/songquanpeng/gin-template/releases/latest'
|
'https://api.github.com/repos/songquanpeng/one-api/releases/latest'
|
||||||
);
|
);
|
||||||
const { tag_name, body } = res.data;
|
const { tag_name, body } = res.data;
|
||||||
if (tag_name === process.env.REACT_APP_VERSION) {
|
if (tag_name === process.env.REACT_APP_VERSION) {
|
||||||
|
@ -43,7 +43,7 @@ const PasswordResetConfirm = () => {
|
|||||||
return (
|
return (
|
||||||
<Grid textAlign='center' style={{ marginTop: '48px' }}>
|
<Grid textAlign='center' style={{ marginTop: '48px' }}>
|
||||||
<Grid.Column style={{ maxWidth: 450 }}>
|
<Grid.Column style={{ maxWidth: 450 }}>
|
||||||
<Header as='h2' color='teal' textAlign='center'>
|
<Header as='h2' color='' textAlign='center'>
|
||||||
<Image src='/logo.png' /> 密码重置确认
|
<Image src='/logo.png' /> 密码重置确认
|
||||||
</Header>
|
</Header>
|
||||||
<Form size='large'>
|
<Form size='large'>
|
||||||
@ -58,7 +58,7 @@ const PasswordResetConfirm = () => {
|
|||||||
readOnly
|
readOnly
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
color='teal'
|
color=''
|
||||||
fluid
|
fluid
|
||||||
size='large'
|
size='large'
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
|
@ -53,7 +53,7 @@ const PasswordResetForm = () => {
|
|||||||
return (
|
return (
|
||||||
<Grid textAlign='center' style={{ marginTop: '48px' }}>
|
<Grid textAlign='center' style={{ marginTop: '48px' }}>
|
||||||
<Grid.Column style={{ maxWidth: 450 }}>
|
<Grid.Column style={{ maxWidth: 450 }}>
|
||||||
<Header as='h2' color='teal' textAlign='center'>
|
<Header as='h2' color='' textAlign='center'>
|
||||||
<Image src='/logo.png' /> 密码重置
|
<Image src='/logo.png' /> 密码重置
|
||||||
</Header>
|
</Header>
|
||||||
<Form size='large'>
|
<Form size='large'>
|
||||||
@ -78,7 +78,7 @@ const PasswordResetForm = () => {
|
|||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
color='teal'
|
color=''
|
||||||
fluid
|
fluid
|
||||||
size='large'
|
size='large'
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
|
@ -138,7 +138,7 @@ const PersonalSetting = () => {
|
|||||||
value={inputs.wechat_verification_code}
|
value={inputs.wechat_verification_code}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
/>
|
/>
|
||||||
<Button color='teal' fluid size='large' onClick={bindWeChat}>
|
<Button color='' fluid size='large' onClick={bindWeChat}>
|
||||||
绑定
|
绑定
|
||||||
</Button>
|
</Button>
|
||||||
</Form>
|
</Form>
|
||||||
@ -194,7 +194,7 @@ const PersonalSetting = () => {
|
|||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
color='teal'
|
color=''
|
||||||
fluid
|
fluid
|
||||||
size='large'
|
size='large'
|
||||||
onClick={bindEmail}
|
onClick={bindEmail}
|
||||||
|
@ -99,7 +99,7 @@ const RegisterForm = () => {
|
|||||||
return (
|
return (
|
||||||
<Grid textAlign='center' style={{ marginTop: '48px' }}>
|
<Grid textAlign='center' style={{ marginTop: '48px' }}>
|
||||||
<Grid.Column style={{ maxWidth: 450 }}>
|
<Grid.Column style={{ maxWidth: 450 }}>
|
||||||
<Header as='h2' color='teal' textAlign='center'>
|
<Header as='h2' color='' textAlign='center'>
|
||||||
<Image src='/logo.png' /> 新用户注册
|
<Image src='/logo.png' /> 新用户注册
|
||||||
</Header>
|
</Header>
|
||||||
<Form size='large'>
|
<Form size='large'>
|
||||||
@ -169,7 +169,7 @@ const RegisterForm = () => {
|
|||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
color='teal'
|
color=''
|
||||||
fluid
|
fluid
|
||||||
size='large'
|
size='large'
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
|
@ -31,8 +31,8 @@ const About = () => {
|
|||||||
<Header as='h3'>关于</Header>
|
<Header as='h3'>关于</Header>
|
||||||
<p>可在设置页面设置关于内容,支持 HTML & Markdown</p>
|
<p>可在设置页面设置关于内容,支持 HTML & Markdown</p>
|
||||||
项目仓库地址:
|
项目仓库地址:
|
||||||
<a href="https://github.com/songquanpeng/gin-template">
|
<a href="https://github.com/songquanpeng/one-api">
|
||||||
https://github.com/songquanpeng/gin-template
|
https://github.com/songquanpeng/one-api
|
||||||
</a>
|
</a>
|
||||||
</> : <>
|
</> : <>
|
||||||
<div dangerouslySetInnerHTML={{ __html: about}}></div>
|
<div dangerouslySetInnerHTML={{ __html: about}}></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user