From d9c2dd0d47341cb08451e309e6bff20f02b77d47 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Wed, 16 Aug 2023 07:48:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=88=A0=E9=99=A4=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E5=88=86=E6=94=AF=E7=9A=84=E5=A4=9A=E4=BD=99=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=202.=20admin=20=E7=9A=84=20=E4=BB=A3=E7=90=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=83=A8=E5=88=86=20api=20=E6=9B=BF=E6=8D=A2=E6=88=90?= =?UTF-8?q?=20proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 7 - admin/src/pages/login.vue | 121 +- admin/src/router/index.js | 1 - app/Http/Controllers/GatewayController.php | 21 - bot/.gitignore | 4 - bot/LICENSE | 9 - bot/bot/bot_example.php | 23 - bot/logs/给这个文件夹权限 | 0 bot/start.php | 21 - bot/workerman/.gitignore | 5 - bot/workerman/Autoloader.php | 69 - .../Connection/AsyncTcpConnection.php | 372 --- .../Connection/AsyncUdpConnection.php | 209 -- .../Connection/ConnectionInterface.php | 125 - bot/workerman/Connection/TcpConnection.php | 1005 ------- bot/workerman/Connection/UdpConnection.php | 191 -- bot/workerman/Events/Ev.php | 194 -- bot/workerman/Events/Event.php | 219 -- bot/workerman/Events/EventInterface.php | 107 - bot/workerman/Events/Libevent.php | 227 -- bot/workerman/Events/React/Base.php | 262 -- bot/workerman/Events/React/ExtEventLoop.php | 27 - .../Events/React/ExtLibEventLoop.php | 27 - .../Events/React/StreamSelectLoop.php | 26 - bot/workerman/Events/Select.php | 340 --- bot/workerman/Events/Swoole.php | 221 -- bot/workerman/Lib/Constants.php | 40 - bot/workerman/Lib/Db.php | 139 - bot/workerman/Lib/Db2.php | 43 - bot/workerman/Lib/Timer.php | 179 -- bot/workerman/Lib/Tool.php | 89 - bot/workerman/MIT-LICENSE.txt | 21 - bot/workerman/Protocols/Frame.php | 61 - bot/workerman/Protocols/Http.php | 701 ----- bot/workerman/Protocols/Http/mime.types | 80 - bot/workerman/Protocols/ProtocolInterface.php | 52 - bot/workerman/Protocols/Text.php | 70 - bot/workerman/Protocols/Websocket.php | 503 ---- bot/workerman/Protocols/Ws.php | 471 --- bot/workerman/README.md | 604 ---- bot/workerman/WebServer.php | 327 --- bot/workerman/Worker.php | 2492 ---------------- bot/workerman/composer.json | 38 - composer.json | 3 +- composer.lock | 23 +- .../2023_07_29_143353_push_config_data.php | 7 - gateway/.gitignore | 5 - gateway/Applications/Lib/Db.php | 139 - gateway/Applications/Lib/Db2.php | 42 - gateway/Applications/Lib/Tool.php | 88 - gateway/Applications/YourApp/Events.php | 98 - .../YourApp/start_businessworker.php | 34 - .../Applications/YourApp/start_gateway.php | 63 - .../Applications/YourApp/start_register.php | 28 - gateway/MIT-LICENSE.txt | 21 - gateway/README.md | 37 - gateway/composer.json | 15 - gateway/start.bat | 2 - gateway/start.php | 37 - routes/web.php | 3 - zero/.gitignore | 24 - zero/index.html | 38 - zero/package.json | 31 - zero/pnpm-lock.yaml | 2530 ----------------- zero/public/favicon.png | Bin 9104 -> 0 bytes zero/src/App.vue | 18 - zero/src/api/index.js | 55 - zero/src/components/Icon.vue | 27 - zero/src/components/Mounting.vue | 24 - zero/src/layouts/404.vue | 5 - zero/src/layouts/default.vue | 12 - zero/src/layouts/none.vue | 7 - zero/src/main.js | 14 - zero/src/pages/[...all].vue | 27 - zero/src/pages/index.vue | 27 - zero/src/router/index.js | 61 - zero/src/store/index.js | 17 - zero/src/styles/main.css | 7 - zero/src/tool/axios.js | 37 - zero/src/tool/favicon.js | 10 - zero/vite.config.js | 52 - 81 files changed, 50 insertions(+), 13361 deletions(-) delete mode 100644 app/Http/Controllers/GatewayController.php delete mode 100644 bot/.gitignore delete mode 100644 bot/LICENSE delete mode 100644 bot/bot/bot_example.php delete mode 100644 bot/logs/给这个文件夹权限 delete mode 100755 bot/start.php delete mode 100755 bot/workerman/.gitignore delete mode 100755 bot/workerman/Autoloader.php delete mode 100755 bot/workerman/Connection/AsyncTcpConnection.php delete mode 100755 bot/workerman/Connection/AsyncUdpConnection.php delete mode 100755 bot/workerman/Connection/ConnectionInterface.php delete mode 100755 bot/workerman/Connection/TcpConnection.php delete mode 100755 bot/workerman/Connection/UdpConnection.php delete mode 100755 bot/workerman/Events/Ev.php delete mode 100755 bot/workerman/Events/Event.php delete mode 100755 bot/workerman/Events/EventInterface.php delete mode 100755 bot/workerman/Events/Libevent.php delete mode 100755 bot/workerman/Events/React/Base.php delete mode 100755 bot/workerman/Events/React/ExtEventLoop.php delete mode 100755 bot/workerman/Events/React/ExtLibEventLoop.php delete mode 100755 bot/workerman/Events/React/StreamSelectLoop.php delete mode 100755 bot/workerman/Events/Select.php delete mode 100755 bot/workerman/Events/Swoole.php delete mode 100755 bot/workerman/Lib/Constants.php delete mode 100644 bot/workerman/Lib/Db.php delete mode 100644 bot/workerman/Lib/Db2.php delete mode 100755 bot/workerman/Lib/Timer.php delete mode 100644 bot/workerman/Lib/Tool.php delete mode 100755 bot/workerman/MIT-LICENSE.txt delete mode 100755 bot/workerman/Protocols/Frame.php delete mode 100755 bot/workerman/Protocols/Http.php delete mode 100755 bot/workerman/Protocols/Http/mime.types delete mode 100755 bot/workerman/Protocols/ProtocolInterface.php delete mode 100755 bot/workerman/Protocols/Text.php delete mode 100755 bot/workerman/Protocols/Websocket.php delete mode 100755 bot/workerman/Protocols/Ws.php delete mode 100755 bot/workerman/README.md delete mode 100755 bot/workerman/WebServer.php delete mode 100755 bot/workerman/Worker.php delete mode 100755 bot/workerman/composer.json delete mode 100644 gateway/.gitignore delete mode 100644 gateway/Applications/Lib/Db.php delete mode 100644 gateway/Applications/Lib/Db2.php delete mode 100644 gateway/Applications/Lib/Tool.php delete mode 100644 gateway/Applications/YourApp/Events.php delete mode 100644 gateway/Applications/YourApp/start_businessworker.php delete mode 100644 gateway/Applications/YourApp/start_gateway.php delete mode 100644 gateway/Applications/YourApp/start_register.php delete mode 100644 gateway/MIT-LICENSE.txt delete mode 100644 gateway/README.md delete mode 100644 gateway/composer.json delete mode 100644 gateway/start.bat delete mode 100644 gateway/start.php delete mode 100644 zero/.gitignore delete mode 100644 zero/index.html delete mode 100644 zero/package.json delete mode 100644 zero/pnpm-lock.yaml delete mode 100644 zero/public/favicon.png delete mode 100644 zero/src/App.vue delete mode 100644 zero/src/api/index.js delete mode 100644 zero/src/components/Icon.vue delete mode 100644 zero/src/components/Mounting.vue delete mode 100644 zero/src/layouts/404.vue delete mode 100644 zero/src/layouts/default.vue delete mode 100644 zero/src/layouts/none.vue delete mode 100644 zero/src/main.js delete mode 100755 zero/src/pages/[...all].vue delete mode 100644 zero/src/pages/index.vue delete mode 100644 zero/src/router/index.js delete mode 100644 zero/src/store/index.js delete mode 100755 zero/src/styles/main.css delete mode 100644 zero/src/tool/axios.js delete mode 100644 zero/src/tool/favicon.js delete mode 100644 zero/vite.config.js diff --git a/.env.example b/.env.example index 2d4a58a..eeecc31 100644 --- a/.env.example +++ b/.env.example @@ -4,13 +4,6 @@ APP_KEY=base64:q3NPkuRVhdHFRkVskaqQatUEs+fXcFVgJNiDtE9nSAA= APP_DEBUG=true APP_URL=http://127.0.0.1:8000 -GATEWAY_PORT=4000 -GATEWAY_REGISTER=4001 -GATEWAY_START=4002 -GATEWAY_PING='{"action":"ping"}' -GATEWAY_PANG='{"action":"pang"}' -GATEWAY_CLOSE=/api/Gateway/close - REQUEST_LOG=true TIMEZONE=Asia/Shanghai diff --git a/admin/src/pages/login.vue b/admin/src/pages/login.vue index 81a856f..2941643 100644 --- a/admin/src/pages/login.vue +++ b/admin/src/pages/login.vue @@ -44,7 +44,7 @@ const routerChange = (query) => { f: query.f || default_page_options.f, m: Number(query.m) || default_page_options.m, } - if (page_options.value.m === 1) apiManaShow() + if (page_options.value.m === 1) proxyManaShow() } const getCaptchaCreate = (reload = true) => { if (login_type_active.value === 'password') { @@ -128,65 +128,65 @@ const AdminQuit = async () => { } }) } -const api_list = ref([]) -const api_mana_show = ref(false) -const apiManaShow = () => { - api_list.value = JSON.parse(JSON.stringify($config.value.api.url)) - api_mana_show.value = true +const proxy_list = ref([]) +const proxy_mana_show = ref(false) +const proxyManaShow = () => { + proxy_list.value = JSON.parse(JSON.stringify($config.value.api.url)) + proxy_mana_show.value = true } -const add_api_data = ref({ +const add_proxy_data = ref({ name: '', url: '', active: false }) const addApiClick = () => { - if (!add_api_data.value.name) return window.$message().error('请输入名称') - if (!add_api_data.value.url) return window.$message().error('请输入接口地址') - if (add_api_data.value.url.indexOf('http') !== 0) return window.$message().error('请输入正确的接口地址') - if (add_api_data.value.active) { - api_list.value.forEach((item) => { + if (!add_proxy_data.value.name) return window.$message().error('请输入名称') + if (!add_proxy_data.value.url) return window.$message().error('请输入接口地址') + if (add_proxy_data.value.url.indexOf('http') !== 0) return window.$message().error('请输入正确的接口地址') + if (add_proxy_data.value.active) { + proxy_list.value.forEach((item) => { item.active = false }) } - api_list.value.unshift(JSON.parse(JSON.stringify(add_api_data.value))) - add_api_data.value = { + proxy_list.value.unshift(JSON.parse(JSON.stringify(add_proxy_data.value))) + add_proxy_data.value = { name: '', url: '', active: false } } -const apiDelClick = (k) => { - if (api_list.length === 1) return - let active = api_list.value[k] - api_list.value.splice(k, 1) +const proxyDelClick = (k) => { + if (proxy_list.length === 1) return + let active = proxy_list.value[k] + proxy_list.value.splice(k, 1) if (!!active) { - api_list.value[0].active = true + proxy_list.value[0].active = true } } -const apiActiveChange = (e, k) => { +const proxyActiveChange = (e, k) => { if (!!e) { - api_list.value.forEach((item) => { + proxy_list.value.forEach((item) => { item.active = false }) - api_list.value[k].active = true + proxy_list.value[k].active = true } else { - api_list.value[k].active = false - api_list.value[0].active = true + proxy_list.value[k].active = false + proxy_list.value[0].active = true } } -const apiSaveClick = () => { +const proxySaveClick = () => { const active_item = $config.value.api.url.filter((item) => { return item.active }) - const change_item = api_list.value.filter((item) => { + const change_item = proxy_list.value.filter((item) => { return item.active }) - $config.value.api.url = JSON.parse(JSON.stringify(api_list.value)) - api_mana_show.value = false + $config.value.api.url = JSON.parse(JSON.stringify(proxy_list.value)) + proxy_mana_show.value = false if (change_item[0].url !== active_item[0].url) { if (page_options.value.m === 1) { window.location.href = '/#/login' @@ -197,7 +197,7 @@ const apiSaveClick = () => { } } -const apiResetClick = () => { +const proxyResetClick = () => { window.$box.confirm( '确定要重置代理配置吗?', '提示', @@ -239,12 +239,6 @@ const apiResetClick = () => { size="small">密码登录 -
- - -
-
- -
- - - - - 刷新二维码 - -
- 扫码登录功能暂未开启 -
-
-
-
@@ -334,15 +309,15 @@ const apiResetClick = () => { @@ -354,20 +329,20 @@ const apiResetClick = () => { - +
- + - -
- + - + - + - + @@ -379,17 +354,17 @@ const apiResetClick = () => { -
- +
+
@@ -397,20 +372,20 @@ const apiResetClick = () => {
diff --git a/zero/src/api/index.js b/zero/src/api/index.js deleted file mode 100644 index cdb4e6a..0000000 --- a/zero/src/api/index.js +++ /dev/null @@ -1,55 +0,0 @@ -import {$post} from '~/tool/axios' -import {useConfig, useSessionToken, useSaveTokenType, useToken} from "~/store"; - -const $save_token_type = useSaveTokenType() -const $config = useConfig() -const app_name = 'Zero' -let url = '' -const urlPick = () => { - if ($config.value.api.url.length > 0) { - url = $config.value.api.url[0].url - for (let i in $config.value.api.url) { - if (!!$config.value.api.url[i].active) { - url = $config.value.api.url[i].url - break - } - } - } -} -urlPick() -export const ConfigGetAction = async (data) => await $post({ - url: `${url}/api/${app_name}/Config/get?client=user`, - data -}, true) -export const yo = async (data) => await $post({url: `${url}/api/yo`, data}, true) -export const $headers = () => { - let $token - if ($save_token_type.value === 'local') { - $token = useToken() - } else { - $token = useSessionToken() - } - return { - 'Authorization': 'Bearer ' + $token.value - } -} -export const $image = (path) => { - const path_ret = ['http://', 'https://', ';base64,'] - for (let i = 0; i < path_ret.length; i++) { - if (path.indexOf(path_ret[i]) !== -1) { - return path - } - } - return `${url}${path}` -} -export const $base64 = async (file) => { - let reader = new FileReader() - reader.readAsDataURL(file) - return await new Promise(resolve => (reader.onloadend = () => resolve(reader.result))) -} -export const $response = (res, then, next = false) => { - if (res) { - if (res.code !== $config.value.api.success_code) return window.$message().error(res.message) - then() - } -} diff --git a/zero/src/components/Icon.vue b/zero/src/components/Icon.vue deleted file mode 100644 index 9ca278a..0000000 --- a/zero/src/components/Icon.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - diff --git a/zero/src/components/Mounting.vue b/zero/src/components/Mounting.vue deleted file mode 100644 index 5068811..0000000 --- a/zero/src/components/Mounting.vue +++ /dev/null @@ -1,24 +0,0 @@ - - diff --git a/zero/src/layouts/404.vue b/zero/src/layouts/404.vue deleted file mode 100644 index c74af7f..0000000 --- a/zero/src/layouts/404.vue +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/zero/src/layouts/default.vue b/zero/src/layouts/default.vue deleted file mode 100644 index 3c47e25..0000000 --- a/zero/src/layouts/default.vue +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/zero/src/layouts/none.vue b/zero/src/layouts/none.vue deleted file mode 100644 index f4edaf1..0000000 --- a/zero/src/layouts/none.vue +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/zero/src/main.js b/zero/src/main.js deleted file mode 100644 index a8cad17..0000000 --- a/zero/src/main.js +++ /dev/null @@ -1,14 +0,0 @@ -import {createApp} from 'vue' -import App from './App.vue' -import router from '~/router' -import {createPinia} from 'pinia' -import './styles/main.css' -import 'uno.css' -import 'normalize.css' -import '@icon-park/vue-next/styles/index.css' -import 'element-plus/dist/index.css' - -const app = createApp(App) -app.use(router) -app.use(createPinia()) -app.mount('#app') diff --git a/zero/src/pages/[...all].vue b/zero/src/pages/[...all].vue deleted file mode 100755 index b6c110e..0000000 --- a/zero/src/pages/[...all].vue +++ /dev/null @@ -1,27 +0,0 @@ - - - - -{"name":"404","meta":{"layout":"404"}} - diff --git a/zero/src/pages/index.vue b/zero/src/pages/index.vue deleted file mode 100644 index bc67215..0000000 --- a/zero/src/pages/index.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - - -{"meta":{"title":"首页"}} - - diff --git a/zero/src/router/index.js b/zero/src/router/index.js deleted file mode 100644 index 0046c5f..0000000 --- a/zero/src/router/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import {createRouter, createWebHashHistory} from 'vue-router' -import {setupLayouts} from 'virtual:generated-layouts' -import generatedRoutes from 'virtual:generated-pages' -import {$favicon} from "~/tool/favicon" -import { - useStore, useRouterActive -} from '~/store' -import {$image, $response, ConfigGetAction} from "~/api"; - -const allow_unlogged_in_page = ['404']; -const $router_active = useRouterActive() -const router = createRouter({ - history: createWebHashHistory(import.meta.env.BASE_URL), routes: setupLayouts(generatedRoutes) -}) - -const updateRouterActive = (matched) => { - matched.shift() - const last = matched[matched.length - 1] - if (allow_unlogged_in_page.indexOf(last.name) !== -1) return - setTimeout(() => { - $router_active.value = matched.map((item) => { - return { - title: 'title' in item.meta ? item.meta.title : item.name, - key: 'active' in item.meta ? item.meta.active : item.name, - } - }) - }) -} -let token_check = '' -let error_status = false -router.beforeEach(async (to, from, next) => { - const $store = useStore() - if (!$store.config) { - const response = await ConfigGetAction({ - config_arr: [ - "Favicon", - "网站名称", - ] - }) - $response(response, () => { - $store.config = response.data - $favicon($image(response.data['Favicon'])) - }) - if (!response) error_status = true - } - if (!!error_status) { - $store.config = { - "Favicon": "https://www.sa0.online/storage/assets/default/favicon.png", - "网站名称": "网络错误", - } - $favicon($image($store.config['Favicon'])) - } - document.title = ('title' in to.meta && to.meta.title !== '首页') ? `${to.meta.title} ${$store.config['网站名称']}` : $store.config['网站名称'] - if (allow_unlogged_in_page.indexOf(to.name) === -1) { - updateRouterActive(to.matched.map(item => item)) - next() - } else { - next() - } -}) -export default router diff --git a/zero/src/store/index.js b/zero/src/store/index.js deleted file mode 100644 index 928c9ce..0000000 --- a/zero/src/store/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import {defineStore} from 'pinia' - -export const useStore = defineStore('main', { - state: () => { - return { - config: false, - info: false, - loading: 0 - } - } -}) -const TOKEN_KEY = JSON.parse(localStorage.getItem('APP_CONFIG') ?? '{}').token -export const useConfig = createGlobalState(() => useStorage('APP_CONFIG', JSON.parse(localStorage.getItem('APP_CONFIG') ?? '{}'))) -export const useToken = createGlobalState(() => useStorage(TOKEN_KEY, '')) -export const useSessionToken = createGlobalState(() => useStorage(TOKEN_KEY, '', sessionStorage)) -export const useSaveTokenType = createGlobalState(() => useStorage('SAVE_TOKEN_TYPE', 'session')) -export const useRouterActive = createGlobalState(() => useStorage('ROUTER_ACTIVE', [])) diff --git a/zero/src/styles/main.css b/zero/src/styles/main.css deleted file mode 100755 index 05928c3..0000000 --- a/zero/src/styles/main.css +++ /dev/null @@ -1,7 +0,0 @@ -html, -body, -#app { - height: 100%; - margin: 0; - padding: 0; -} diff --git a/zero/src/tool/axios.js b/zero/src/tool/axios.js deleted file mode 100644 index e4eef7a..0000000 --- a/zero/src/tool/axios.js +++ /dev/null @@ -1,37 +0,0 @@ -import axios from 'axios' -import {useToken, useStore, useConfig, useSaveTokenType, useSessionToken} from '~/store' -const $save_token_type = useSaveTokenType() -let $token -let loading_active -const post = axios.create({ - method: 'POST' -}) -post.interceptors.request.use(config => { - if ($save_token_type.value === 'local') { - $token = useToken() - } else { - $token = useSessionToken() - } - config.headers['Authorization'] = 'Bearer ' + $token.value - return config -}, error => Promise.reject(error)) -post.interceptors.response.use(response => { - return (response.status === 200) ? response : Promise.reject('[ERROR] response.status: ' + response.status) -}, error => Promise.reject(error)) - -const $config = useConfig() -export const $post = async (request, loading = false) => { - const $store = useStore() - if (loading) { - $store.loading++ - if ($store.loading === 1) window.$loading().open() - } - const response = await post(request).catch((e) => { - window.$message().error($config.value.api.error_message) - }) - if (loading) { - $store.loading-- - if ($store.loading === 0) window.$loading().close() - } - return !!response ? response.data : false -} diff --git a/zero/src/tool/favicon.js b/zero/src/tool/favicon.js deleted file mode 100644 index e2d8198..0000000 --- a/zero/src/tool/favicon.js +++ /dev/null @@ -1,10 +0,0 @@ -import {$image} from "~/api"; - -export const $favicon = (path, t = false) => { - const link = document.querySelector("link[rel*='icon']") || document.createElement('link') - link.type = 'image/x-icon' - link.rel = 'shortcut icon' - let href = $image(path) - link.href = t ? [href, 't=' + String(new Date() / 1)].join(href.indexOf('?') === -1 ? '?' : '&') : href - document.getElementsByTagName('head')[0].appendChild(link) -} diff --git a/zero/vite.config.js b/zero/vite.config.js deleted file mode 100644 index 154fe4d..0000000 --- a/zero/vite.config.js +++ /dev/null @@ -1,52 +0,0 @@ -import {defineConfig} from 'vite' -import Vue from '@vitejs/plugin-vue' -import path from 'path' -import Pages from 'vite-plugin-pages' -import Layouts from 'vite-plugin-vue-layouts' -import Components from 'unplugin-vue-components/vite' -import AutoImport from 'unplugin-auto-import/vite' -import {ElementPlusResolver} from 'unplugin-vue-components/resolvers' -import {viteCommonjs} from '@originjs/vite-plugin-commonjs' -import Unocss from 'unocss/vite' -import {presetAttributify, presetUno, presetIcons} from 'unocss' - -const package_path = 'zero' -export default defineConfig({ - base: `/${package_path}/`, - build: { - outDir: `../public/${package_path}`, - assetsDir: 'lib' - }, - resolve: { - alias: { - '~/': `${path.resolve(__dirname, 'src')}/` - } - }, - plugins: [ - Vue({ - reactivityTransform: true - }), - viteCommonjs(), - Pages(), - Layouts(), - AutoImport({ - resolvers: [ElementPlusResolver()], - imports: [ - 'vue', - 'vue/macros', - 'vue-router', - '@vueuse/core' - ], - }), - Components({ - resolvers: [ElementPlusResolver()] - }), - Unocss({ - presets: [ - presetAttributify({}), - presetUno(), - presetIcons({ - warn: true, - })], - })] -})