diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml index 5c843f8..3d8a0a3 100644 --- a/.gitea/workflows/build-push.yml +++ b/.gitea/workflows/build-push.yml @@ -1,13 +1,11 @@ name: Build image on: [push] -env: - HTTPS_PROXY: "http://192.168.31.55:10809" jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: build run: docker build -t ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 -f Dockerfile . - name: tag diff --git a/Dockerfile b/Dockerfile index 12b80a1..310af84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,19 +5,11 @@ WORKDIR /build COPY . /build RUN CGO_ENABLED=0 go build -trimpath -ldflags '-w -s' -o watcher ./main -FROM oven/bun:1 as front -ARG HTTP_PROXY=http://192.168.31.55:10809 -ARG HTTPS_PROXY=http://192.168.31.55:10809 -COPY . /build -WORKDIR /build/wwwroot -RUN bun install && bun run build - FROM alpine:latest ARG HTTP_PROXY=http://192.168.31.55:10809 ARG HTTPS_PROXY=http://192.168.31.55:10809 RUN apk add --no-cache ca-certificates tzdata WORKDIR /work COPY --from=back /build/watcher /work/ -COPY --from=front /build/wwwroot/dist /work/dist/ ENTRYPOINT ["/work/watcher"] diff --git a/main/main.go b/main/main.go index f14f182..b1c21c5 100644 --- a/main/main.go +++ b/main/main.go @@ -3,6 +3,7 @@ package main import ( "context" "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/cors" "github.com/golang/glog" "haitao_watcher/pkg/database" "haitao_watcher/pkg/model" @@ -41,8 +42,7 @@ func main() { watcherCtl := watcher.NewController(_ctx, db, pool, ch) r := fiber.New() - - r.Static("/", "/work/dist") + r.Use(cors.New()) api := r.Group("/api/v1") @@ -50,7 +50,7 @@ func main() { server.NewPusherSvcController(pusherCtl).RegistryRouter(api) server.NewProxySvc(pool).RegistryRouter(api) - if err = r.Listen(":2280"); err != nil { + if err = r.Listen(":8080"); err != nil { glog.Warningf("server over: %v", err) } } diff --git a/wwwroot/.gitignore b/wwwroot/.gitignore deleted file mode 100644 index a547bf3..0000000 --- a/wwwroot/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/wwwroot/.vscode/extensions.json b/wwwroot/.vscode/extensions.json deleted file mode 100644 index a7cea0b..0000000 --- a/wwwroot/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["Vue.volar"] -} diff --git a/wwwroot/README.md b/wwwroot/README.md deleted file mode 100644 index e0acb37..0000000 --- a/wwwroot/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Vue 3 + Vite - -This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` - - diff --git a/wwwroot/package.json b/wwwroot/package.json deleted file mode 100644 index 14fbd17..0000000 --- a/wwwroot/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "wwwroot", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" - }, - "dependencies": { - "@ant-design/icons-vue": "^7.0.1", - "ant-design-vue": "4.x", - "mande": "^2.0.8", - "moment": "^2.30.1", - "vue": "^3.4.21", - "vue-router": "4" - }, - "devDependencies": { - "@types/node": "^20.12.5", - "@vitejs/plugin-vue": "^5.0.4", - "unocss": "^0.59.0", - "unplugin-vue-components": "^0.26.0", - "vite": "^5.2.0" - } -} diff --git a/wwwroot/src/App.vue b/wwwroot/src/App.vue deleted file mode 100644 index 604710e..0000000 --- a/wwwroot/src/App.vue +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - diff --git a/wwwroot/src/api/proxies.js b/wwwroot/src/api/proxies.js deleted file mode 100644 index eaac8fd..0000000 --- a/wwwroot/src/api/proxies.js +++ /dev/null @@ -1,7 +0,0 @@ -import {mande} from "mande"; - -const pushers = mande('/api/v1/proxies') - -export const getProxiesStatus = () => { - return pushers.get("/status") -} \ No newline at end of file diff --git a/wwwroot/src/api/pusher.js b/wwwroot/src/api/pusher.js deleted file mode 100644 index 025d50d..0000000 --- a/wwwroot/src/api/pusher.js +++ /dev/null @@ -1,11 +0,0 @@ -import {mande} from "mande"; - -const pushers = mande('/api/v1/pushers') - -export const ListPushers = (query) => { - return pushers.get({query:query}) -} - -export const AddPusher = (opt)=>{ - return pushers.post(opt) -} \ No newline at end of file diff --git a/wwwroot/src/api/watcher.js b/wwwroot/src/api/watcher.js deleted file mode 100644 index d665cae..0000000 --- a/wwwroot/src/api/watcher.js +++ /dev/null @@ -1,22 +0,0 @@ -import {mande} from "mande"; - -const watchers = mande('/api/v1/watchers') - -export const ListWatchers = (query) => { - return watchers.get({query:query}) -} - -export const CreateWatcher = (opt)=>{ - return watchers.post(opt) -} - -export const DeleteWatcher = (uid)=>{ - return watchers.delete(`/${encodeURIComponent(uid)}`) -} - -export const StopWatcher = (uid)=>{ - return watchers.delete(`/${encodeURIComponent(uid)}/status`) -} -export const StartWatcher = (uid)=>{ - return watchers.post(`/${encodeURIComponent(uid)}/status`) -} \ No newline at end of file diff --git a/wwwroot/src/assets/logo.png b/wwwroot/src/assets/logo.png deleted file mode 100644 index 3a02aac..0000000 Binary files a/wwwroot/src/assets/logo.png and /dev/null differ diff --git a/wwwroot/src/constants/pusher.js b/wwwroot/src/constants/pusher.js deleted file mode 100644 index 24af822..0000000 --- a/wwwroot/src/constants/pusher.js +++ /dev/null @@ -1,10 +0,0 @@ -export const PUSHER = { - ANPUSHER: 1, -} - -export const WEBSITE_OPTIONS = [ - { - label: 'anPush', - value: PUSHER.ANPUSHER - } -] \ No newline at end of file diff --git a/wwwroot/src/constants/website.js b/wwwroot/src/constants/website.js deleted file mode 100644 index d91712b..0000000 --- a/wwwroot/src/constants/website.js +++ /dev/null @@ -1,15 +0,0 @@ -export const WEBSITES = { - UNKNOWN: 0, - COACHOUTLET: 1, -} - -export const WEBSITE_OPTIONS = [ - { - label: '未知', - value: WEBSITES.UNKNOWN - }, - { - label: 'coachoutlet', - value: WEBSITES.COACHOUTLET - } -] \ No newline at end of file diff --git a/wwwroot/src/css/base.css b/wwwroot/src/css/base.css deleted file mode 100644 index d155e04..0000000 --- a/wwwroot/src/css/base.css +++ /dev/null @@ -1,6 +0,0 @@ -html,body,#app { - height: 100%; - width: 100%; - padding: 0; - margin: 0; -} \ No newline at end of file diff --git a/wwwroot/src/main.js b/wwwroot/src/main.js deleted file mode 100644 index e83a210..0000000 --- a/wwwroot/src/main.js +++ /dev/null @@ -1,9 +0,0 @@ -import { createApp } from 'vue' -import './css/base.css' -import App from './App.vue' -import 'virtual:uno.css' -import router from "@/routers/index.js"; - -const app = createApp(App) -app.use(router) -app.mount('#app') diff --git a/wwwroot/src/routers/index.js b/wwwroot/src/routers/index.js deleted file mode 100644 index 3e3bcf9..0000000 --- a/wwwroot/src/routers/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import {createRouter, createWebHashHistory} from "vue-router"; - -const routes = [ - { - path: '/', - redirect: '/watcher' - }, - { - path: '/watcher', - name: 'watcher', - component: ()=>import('@/views/Watcher/index.vue') - }, - { - path: '/pusher', - name: 'pusher', - component: ()=>import('@/views/Pusher/index.vue') - } -] - -const router = createRouter({ - history: createWebHashHistory(), - routes -}) - -export default router \ No newline at end of file diff --git a/wwwroot/src/views/Pusher/index.vue b/wwwroot/src/views/Pusher/index.vue deleted file mode 100644 index 732555b..0000000 --- a/wwwroot/src/views/Pusher/index.vue +++ /dev/null @@ -1,178 +0,0 @@ - - - - - \ No newline at end of file diff --git a/wwwroot/src/views/Watcher/index.vue b/wwwroot/src/views/Watcher/index.vue deleted file mode 100644 index d280d42..0000000 --- a/wwwroot/src/views/Watcher/index.vue +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/wwwroot/src/views/layout/Aside.vue b/wwwroot/src/views/layout/Aside.vue deleted file mode 100644 index 4100d45..0000000 --- a/wwwroot/src/views/layout/Aside.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - \ No newline at end of file diff --git a/wwwroot/src/views/layout/Header.vue b/wwwroot/src/views/layout/Header.vue deleted file mode 100644 index b74e438..0000000 --- a/wwwroot/src/views/layout/Header.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - - \ No newline at end of file diff --git a/wwwroot/src/views/layout/Main.vue b/wwwroot/src/views/layout/Main.vue deleted file mode 100644 index 657f1ee..0000000 --- a/wwwroot/src/views/layout/Main.vue +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/wwwroot/src/views/layout/index.vue b/wwwroot/src/views/layout/index.vue deleted file mode 100644 index d92d49c..0000000 --- a/wwwroot/src/views/layout/index.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - \ No newline at end of file diff --git a/wwwroot/vite.config.js b/wwwroot/vite.config.js deleted file mode 100644 index bc42ab8..0000000 --- a/wwwroot/vite.config.js +++ /dev/null @@ -1,38 +0,0 @@ -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' -import UnoCSS from 'unocss/vite' -import path from 'path' -import Components from 'unplugin-vue-components/vite'; -import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; - - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [ - vue(), - UnoCSS(), - Components({ - resolvers: [ - AntDesignVueResolver({ - importStyle: false, // css in js - }), - ], - }), - ], - server:{ - open: true, - proxy: { - '/api/v1': { - target: 'http://172.25.168.160:2280/', - changeOrigin: true, - secure: false, - ws: true, - }, - }, - }, - resolve: { - alias: { - '@': path.resolve(__dirname, "./src") - } - } -})