fix bug
This commit is contained in:
@@ -2,7 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"opencatd-open/middleware"
|
||||
@@ -18,6 +20,9 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//go:embed dist/*
|
||||
var web embed.FS
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
var wg sync.WaitGroup
|
||||
@@ -53,6 +58,7 @@ func main() {
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(middleware.CORS())
|
||||
|
||||
teamGroup := r.Group("/1")
|
||||
teamGroup.Use(team.AuthMiddleware())
|
||||
{
|
||||
@@ -122,13 +128,24 @@ func main() {
|
||||
}
|
||||
|
||||
v1 := r.Group("/v1")
|
||||
v1.Use(middleware.AuthLLM(store.DB))
|
||||
v1.Use(middleware.AuthLLM(db))
|
||||
{
|
||||
// v1.POST("/v2/*proxypath", router.HandleProxy)
|
||||
v1.POST("/v1/*proxypath", proxy.HandleProxy)
|
||||
// v1.GET("/models", dashboard.HandleModels)
|
||||
}
|
||||
|
||||
idxFS, err := fs.Sub(web, "dist")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.GET("/", gin.WrapH(http.FileServer(http.FS(idxFS))))
|
||||
assetsFS, err := fs.Sub(web, "dist/assets")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.GET("/assets/*filepath", gin.WrapH(http.StripPrefix("/assets/", http.FileServer(http.FS(assetsFS)))))
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: ":8080",
|
||||
Handler: r,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
FROM node:20-alpine AS frontend
|
||||
WORKDIR /frontend-build
|
||||
COPY ./web/ .
|
||||
RUN npm install && npm run build && rm -rf node_modules
|
||||
COPY ./frontend .
|
||||
|
||||
FROM golang:1.23-alpine as builder
|
||||
RUN npm config set registry https://registry.npmmirror.com && npm install -g pnpm --registry=https://registry.npmmirror.com && pnpm i && pnpm build
|
||||
|
||||
FROM golang:1.23-alpine as backend
|
||||
LABEL anther="github.com/Sakurasan"
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk --no-cache add make cmake upx
|
||||
WORKDIR /build
|
||||
COPY --from=frontend /frontend-build/dist /build/dist
|
||||
COPY . /build
|
||||
COPY . .
|
||||
COPY --from=frontend /frontend-build/dist /build/cmd/openteam/dist
|
||||
ENV GO111MODULE=on
|
||||
# ENV GOPROXY=https://goproxy.cn,direct
|
||||
CMD [ "go mod tidy","go mod download" ]
|
||||
@@ -20,8 +21,8 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
&& echo "Asia/Shanghai" > /etc/timezone
|
||||
# RUN apk update && apk --no-cache add openssl libgcc libstdc++ binutils
|
||||
WORKDIR /app
|
||||
COPY --from=builder /build/bin/opencatd /app/opencatd
|
||||
COPY --from=backend /build/bin/openteam /app/openteam
|
||||
ENV GIN_MODE=release
|
||||
ENV PATH=$PATH:/app
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/app/opencatd"]
|
||||
ENTRYPOINT ["/app/openteam"]
|
||||
@@ -27,6 +27,6 @@
|
||||
"pinia": "^2.3.1",
|
||||
"postcss": "^8.5.3",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"vite": "^6.2.6"
|
||||
"vite": "^6.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
52
frontend/pnpm-lock.yaml
generated
52
frontend/pnpm-lock.yaml
generated
@@ -13,7 +13,7 @@ importers:
|
||||
version: 13.1.0
|
||||
'@vitejs/plugin-basic-ssl':
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0(vite@6.2.6(jiti@1.21.7)(yaml@2.7.1))
|
||||
version: 2.0.0(vite@6.3.0(jiti@1.21.7)(yaml@2.7.1))
|
||||
axios:
|
||||
specifier: ^1.8.4
|
||||
version: 1.8.4
|
||||
@@ -41,7 +41,7 @@ importers:
|
||||
version: 4.3.0(vue@3.5.13)
|
||||
'@vitejs/plugin-vue':
|
||||
specifier: ^5.2.3
|
||||
version: 5.2.3(vite@6.2.6(jiti@1.21.7)(yaml@2.7.1))(vue@3.5.13)
|
||||
version: 5.2.3(vite@6.3.0(jiti@1.21.7)(yaml@2.7.1))(vue@3.5.13)
|
||||
autoprefixer:
|
||||
specifier: ^10.4.21
|
||||
version: 10.4.21(postcss@8.5.3)
|
||||
@@ -58,8 +58,8 @@ importers:
|
||||
specifier: ^3.4.17
|
||||
version: 3.4.17
|
||||
vite:
|
||||
specifier: ^6.2.6
|
||||
version: 6.2.6(jiti@1.21.7)(yaml@2.7.1)
|
||||
specifier: ^6.3.0
|
||||
version: 6.3.0(jiti@1.21.7)(yaml@2.7.1)
|
||||
|
||||
packages:
|
||||
|
||||
@@ -680,6 +680,14 @@ packages:
|
||||
fastq@1.19.1:
|
||||
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
||||
|
||||
fdir@6.4.3:
|
||||
resolution: {integrity: sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==}
|
||||
peerDependencies:
|
||||
picomatch: ^3 || ^4
|
||||
peerDependenciesMeta:
|
||||
picomatch:
|
||||
optional: true
|
||||
|
||||
fill-range@7.1.1:
|
||||
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -895,6 +903,10 @@ packages:
|
||||
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
|
||||
engines: {node: '>=8.6'}
|
||||
|
||||
picomatch@4.0.2:
|
||||
resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
pify@2.3.0:
|
||||
resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -1036,6 +1048,10 @@ packages:
|
||||
thenify@3.3.1:
|
||||
resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==}
|
||||
|
||||
tinyglobby@0.2.12:
|
||||
resolution: {integrity: sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
to-regex-range@5.0.1:
|
||||
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
||||
engines: {node: '>=8.0'}
|
||||
@@ -1052,8 +1068,8 @@ packages:
|
||||
util-deprecate@1.0.2:
|
||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||
|
||||
vite@6.2.6:
|
||||
resolution: {integrity: sha512-9xpjNl3kR4rVDZgPNdTL0/c6ao4km69a/2ihNQbcANz8RuCOK3hQBmLSJf3bRKVQjVMda+YvizNE8AwvogcPbw==}
|
||||
vite@6.3.0:
|
||||
resolution: {integrity: sha512-9aC0n4pr6hIbvi1YOpFjwQ+QOTGssvbJKoeYkuHHGWwlXfdxQlI8L2qNMo9awEEcCPSiS+5mJZk5jH1PAqoDeQ==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@@ -1373,13 +1389,13 @@ snapshots:
|
||||
|
||||
'@types/web-bluetooth@0.0.16': {}
|
||||
|
||||
'@vitejs/plugin-basic-ssl@2.0.0(vite@6.2.6(jiti@1.21.7)(yaml@2.7.1))':
|
||||
'@vitejs/plugin-basic-ssl@2.0.0(vite@6.3.0(jiti@1.21.7)(yaml@2.7.1))':
|
||||
dependencies:
|
||||
vite: 6.2.6(jiti@1.21.7)(yaml@2.7.1)
|
||||
vite: 6.3.0(jiti@1.21.7)(yaml@2.7.1)
|
||||
|
||||
'@vitejs/plugin-vue@5.2.3(vite@6.2.6(jiti@1.21.7)(yaml@2.7.1))(vue@3.5.13)':
|
||||
'@vitejs/plugin-vue@5.2.3(vite@6.3.0(jiti@1.21.7)(yaml@2.7.1))(vue@3.5.13)':
|
||||
dependencies:
|
||||
vite: 6.2.6(jiti@1.21.7)(yaml@2.7.1)
|
||||
vite: 6.3.0(jiti@1.21.7)(yaml@2.7.1)
|
||||
vue: 3.5.13
|
||||
|
||||
'@vue/compiler-core@3.5.13':
|
||||
@@ -1684,6 +1700,10 @@ snapshots:
|
||||
dependencies:
|
||||
reusify: 1.1.0
|
||||
|
||||
fdir@6.4.3(picomatch@4.0.2):
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.2
|
||||
|
||||
fill-range@7.1.1:
|
||||
dependencies:
|
||||
to-regex-range: 5.0.1
|
||||
@@ -1866,6 +1886,8 @@ snapshots:
|
||||
|
||||
picomatch@2.3.1: {}
|
||||
|
||||
picomatch@4.0.2: {}
|
||||
|
||||
pify@2.3.0: {}
|
||||
|
||||
pinia@2.3.1(vue@3.5.13):
|
||||
@@ -2042,6 +2064,11 @@ snapshots:
|
||||
dependencies:
|
||||
any-promise: 1.3.0
|
||||
|
||||
tinyglobby@0.2.12:
|
||||
dependencies:
|
||||
fdir: 6.4.3(picomatch@4.0.2)
|
||||
picomatch: 4.0.2
|
||||
|
||||
to-regex-range@5.0.1:
|
||||
dependencies:
|
||||
is-number: 7.0.0
|
||||
@@ -2056,11 +2083,14 @@ snapshots:
|
||||
|
||||
util-deprecate@1.0.2: {}
|
||||
|
||||
vite@6.2.6(jiti@1.21.7)(yaml@2.7.1):
|
||||
vite@6.3.0(jiti@1.21.7)(yaml@2.7.1):
|
||||
dependencies:
|
||||
esbuild: 0.25.2
|
||||
fdir: 6.4.3(picomatch@4.0.2)
|
||||
picomatch: 4.0.2
|
||||
postcss: 8.5.3
|
||||
rollup: 4.40.0
|
||||
tinyglobby: 0.2.12
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
jiti: 1.21.7
|
||||
|
||||
@@ -79,9 +79,9 @@ const handleRegister = async () => {
|
||||
password: password.value
|
||||
})
|
||||
if (res.status === 200) {
|
||||
setToast(res.data?.msg || '注册成功', 'success');
|
||||
setToast(res.data?.msg || '已注册', 'success');
|
||||
setTimeout(() => {
|
||||
router.push('/sign_in');
|
||||
router.push('/login');
|
||||
}, 100);
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
15
makefile
15
makefile
@@ -18,23 +18,28 @@ LDFlags=" \
|
||||
.PHONY: web
|
||||
# web
|
||||
web:
|
||||
cd web && npm install && npm run build && mv dist ..
|
||||
cd frontend && npm install -g pnpm && pnpm build && mv dist ../cmd/openteam/
|
||||
|
||||
.PHONY: build
|
||||
# build
|
||||
build:
|
||||
# mkdir -p bin/ && go build -ldflags $(LDFlags) -o ./bin/ ./...
|
||||
rm -rf bin
|
||||
mkdir -p bin/ && go build -ldflags "-s -w" -o ./bin/opencatd opencat.go
|
||||
upx -9 bin/opencatd
|
||||
mkdir -p bin/ && go build -ldflags "-s -w" -o ./bin/openteam ./cmd/openteam/
|
||||
upx -9 bin/openteam
|
||||
|
||||
.PHONY:image
|
||||
# build docker images
|
||||
image:
|
||||
docker build -t mirrors2/opencatd-open:latest -f deploy/docker/Dockerfile . --push
|
||||
|
||||
.PHONY:docker
|
||||
# build docker images
|
||||
docker:
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
docker buildx create --use --name xbuilder --driver docker-container
|
||||
# docker buildx create --use --name xbuilder --driver docker-container
|
||||
docker buildx inspect xbuilder --bootstrap
|
||||
docker buildx build --platform linux/amd64,linux/arm64 -t mirrors2/opencatd:latest -f docker/Dockerfile . --push
|
||||
docker buildx build --platform linux/amd64,linux/arm64 -t mirrors2/opencatd-open:latest -f deploy/docker/Dockerfile . --push
|
||||
|
||||
.PHONY: clean
|
||||
# clean
|
||||
|
||||
Reference in New Issue
Block a user