commit 43e2dff6a334603caf50bef6413eaf418dfae924 Author: timerzz Date: Sun May 12 15:53:54 2024 +0800 feat 从之前的服务中将前端分离 diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml new file mode 100644 index 0000000..5c843f8 --- /dev/null +++ b/.gitea/workflows/build-push.yml @@ -0,0 +1,18 @@ +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 + - name: build + run: docker build -t ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 -f Dockerfile . + - name: tag + run: docker tag ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest + - name: push 1.3 + run: docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 + - name: push latest + run: docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# 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/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4ba12a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM oven/bun:1 as front +COPY . /build +WORKDIR /build/wwwroot +RUN bun install && bun run build + +FROM nginx:alpine +COPY --from=front /build/wwwroot/dist /usr/share/ +RUN rm /etc/nginx/conf.d/default.conf + +# 将自定义配置文件nginx.conf复制到容器内/etc/nginx/conf.d/目录 +ADD ./nginx.conf /etc/nginx/conf.d/ + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0acb37 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Vue 3 + Vite + +This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` + + diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..28f3998 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name ht.timerzz.com; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/dist; + index index.html index.htm; + } + + location /api/v1 { + resolver 10.43.0.10 valid=10s; # 6.6.6.6 为自建DNS + proxy_pass http://ht-watcher; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..14fbd17 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "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/src/App.vue b/src/App.vue new file mode 100644 index 0000000..604710e --- /dev/null +++ b/src/App.vue @@ -0,0 +1,15 @@ + + + + + + diff --git a/src/api/proxies.js b/src/api/proxies.js new file mode 100644 index 0000000..eaac8fd --- /dev/null +++ b/src/api/proxies.js @@ -0,0 +1,7 @@ +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/src/api/pusher.js b/src/api/pusher.js new file mode 100644 index 0000000..025d50d --- /dev/null +++ b/src/api/pusher.js @@ -0,0 +1,11 @@ +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/src/api/watcher.js b/src/api/watcher.js new file mode 100644 index 0000000..d665cae --- /dev/null +++ b/src/api/watcher.js @@ -0,0 +1,22 @@ +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/src/assets/logo.png b/src/assets/logo.png new file mode 100644 index 0000000..3a02aac Binary files /dev/null and b/src/assets/logo.png differ diff --git a/src/constants/pusher.js b/src/constants/pusher.js new file mode 100644 index 0000000..24af822 --- /dev/null +++ b/src/constants/pusher.js @@ -0,0 +1,10 @@ +export const PUSHER = { + ANPUSHER: 1, +} + +export const WEBSITE_OPTIONS = [ + { + label: 'anPush', + value: PUSHER.ANPUSHER + } +] \ No newline at end of file diff --git a/src/constants/website.js b/src/constants/website.js new file mode 100644 index 0000000..d91712b --- /dev/null +++ b/src/constants/website.js @@ -0,0 +1,15 @@ +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/src/css/base.css b/src/css/base.css new file mode 100644 index 0000000..d155e04 --- /dev/null +++ b/src/css/base.css @@ -0,0 +1,6 @@ +html,body,#app { + height: 100%; + width: 100%; + padding: 0; + margin: 0; +} \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..e83a210 --- /dev/null +++ b/src/main.js @@ -0,0 +1,9 @@ +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/src/routers/index.js b/src/routers/index.js new file mode 100644 index 0000000..3e3bcf9 --- /dev/null +++ b/src/routers/index.js @@ -0,0 +1,25 @@ +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/src/views/Pusher/index.vue b/src/views/Pusher/index.vue new file mode 100644 index 0000000..732555b --- /dev/null +++ b/src/views/Pusher/index.vue @@ -0,0 +1,178 @@ + + + + + \ No newline at end of file diff --git a/src/views/Watcher/index.vue b/src/views/Watcher/index.vue new file mode 100644 index 0000000..f15a491 --- /dev/null +++ b/src/views/Watcher/index.vue @@ -0,0 +1,258 @@ + + + + + + \ No newline at end of file diff --git a/src/views/layout/Aside.vue b/src/views/layout/Aside.vue new file mode 100644 index 0000000..4100d45 --- /dev/null +++ b/src/views/layout/Aside.vue @@ -0,0 +1,42 @@ + + + + \ No newline at end of file diff --git a/src/views/layout/Header.vue b/src/views/layout/Header.vue new file mode 100644 index 0000000..b74e438 --- /dev/null +++ b/src/views/layout/Header.vue @@ -0,0 +1,38 @@ + + + + \ No newline at end of file diff --git a/src/views/layout/Main.vue b/src/views/layout/Main.vue new file mode 100644 index 0000000..657f1ee --- /dev/null +++ b/src/views/layout/Main.vue @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue new file mode 100644 index 0000000..d92d49c --- /dev/null +++ b/src/views/layout/index.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..e4e8212 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,39 @@ +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/', + // target: 'http://192.168.31.55:2280/', + changeOrigin: true, + secure: false, + ws: true, + }, + }, + }, + resolve: { + alias: { + '@': path.resolve(__dirname, "./src") + } + } +})