From 22ead6d55e875ec237e4eb4fcc540d50d6e2a027 Mon Sep 17 00:00:00 2001 From: zyc404 Date: Mon, 16 Oct 2023 17:21:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=85=E5=B7=B4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/modules/guoba.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server/modules/guoba.js b/server/modules/guoba.js index 91a499f..e98a20b 100644 --- a/server/modules/guoba.js +++ b/server/modules/guoba.js @@ -28,16 +28,26 @@ async function Guoba(fastify, options) { let user = UserInfo(token) if (user && user.autho == 'admin' && body.guobaToken) { try { - let { LoginService } = await import('../../../Guoba-Plugin/server/service/both/LoginService.js') - const guobaLoginService = new LoginService() - const { custom, local, remote } = await guobaLoginService.setQuickLogin(user.user) + let { getAllWebAddress } = await import('../../../Guoba-Plugin/utils/common.js') + const { custom, local, remote } = await getAllWebAddress() + console.log(local[0]) if (local.length > 0) { const guobaOptions = { - method: 'GET', + method: body.post ? 'POST' : 'GET', headers: { 'Guoba-Access-Token': body.guobaToken - }, - body: body.data + } + } + if (body.data) { + if (body.post) { + guobaOptions.body = body.data + } else { + let paramsArray = [] + Object.keys(body.data).forEach(key => paramsArray.push(key + '=' + body.data[key])) + if (paramsArray.length > 0) { + body.path += '?' + paramsArray.join('&') + } + } } const response = await fetch(`${local[0]}/${body.path}`, guobaOptions) if (response.ok) {