From 6b88c298befbee314e3bda309cdd426d04d2dc41 Mon Sep 17 00:00:00 2001 From: enncy <877526278@qq.com> Date: Sun, 15 Oct 2023 13:42:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(script):=20=E5=B0=86=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E8=BE=85=E5=8A=A9=E8=AD=A6=E5=91=8A=E4=BF=AE=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/scripts/src/utils/app.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/scripts/src/utils/app.ts b/packages/scripts/src/utils/app.ts index b68a532b..3339ae82 100644 --- a/packages/scripts/src/utils/app.ts +++ b/packages/scripts/src/utils/app.ts @@ -1,12 +1,13 @@ -import { $, $creator, $message, el, request } from '@ocsjs/core'; +import { $, $creator, $modal, el, request } from '@ocsjs/core'; import { $console } from '../projects/background'; let actions_key = ''; export const $app_actions = { showError: () => { - $message('error', { - duration: 60, + $modal('alert', { + maskCloseable: false, + title: '⚠️警告', content: el('div', [ '软件辅助启动失败,无法执行脚本操作,请开启软件辅助,开启教程=>', $creator.button('软件辅助开启教程', { @@ -115,17 +116,20 @@ export const $app_actions = { }); } }, - setViewPort: async (width: number, height: number) => { + setViewPort: async (width: number | null, height: number | null) => { return await appActionRequest({ - width: width.toString(), - height: height.toString(), + width: width ? width.toString() : 'null', + height: height ? height.toString() : 'null', action: 'set-viewport' }); } }; async function appActionRequest( - data: Record, + data: { + [x: string]: any; + action: string; + }, options?: { baseUrl?: string; responseType?: 'text' | 'json'; @@ -149,11 +153,10 @@ async function appActionRequest( } } ); - return res; } catch (e) { console.error(e); - $console.error('软件辅助错误', String(e)); + $console.error('软件辅助错误', data.action, String(e)); return ''; } }