From 6085ae1b87e31667bd4a5f117687b9d35b6bf9c3 Mon Sep 17 00:00:00 2001 From: ThinaticSystem Date: Sun, 19 Jun 2022 00:28:55 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/client/src/scripts/aiscript/api.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/client/src/scripts/aiscript/api.ts b/packages/client/src/scripts/aiscript/api.ts index 66aac9986..526628aa3 100644 --- a/packages/client/src/scripts/aiscript/api.ts +++ b/packages/client/src/scripts/aiscript/api.ts @@ -30,6 +30,15 @@ export function createAiScriptEnv(opts) { const res = await os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token || null)); return utils.jsToVal(res); }), + 'Mk:save': values.FN_NATIVE(([key, value]) => { + utils.assertString(key); + localStorage.setItem('aiscript:' + opts.storageKey + ':' + key.value, JSON.stringify(utils.valToJs(value))); + return values.NULL; + }), + 'Mk:load': values.FN_NATIVE(([key]) => { + utils.assertString(key); + return utils.jsToVal(JSON.parse(localStorage.getItem('aiscript:' + opts.storageKey + ':' + key.value))); + }), 'Mk:restApi': values.FN_NATIVE(async ([url, method, body, headers]) => { const init: {method?: string, body?: string, headers?: Headers} = new Object(); utils.assertString(url); @@ -63,14 +72,5 @@ export function createAiScriptEnv(opts) { } return utils.jsToVal(await response.text()); }), - 'Mk:save': values.FN_NATIVE(([key, value]) => { - utils.assertString(key); - localStorage.setItem('aiscript:' + opts.storageKey + ':' + key.value, JSON.stringify(utils.valToJs(value))); - return values.NULL; - }), - 'Mk:load': values.FN_NATIVE(([key]) => { - utils.assertString(key); - return utils.jsToVal(JSON.parse(localStorage.getItem('aiscript:' + opts.storageKey + ':' + key.value))); - }), }; }