enhance(frontend/aiscript): セーブ内容を削除できるMk:removeを追加 (#15158)

* enhance(frontend/aiscript): セーブ内容を削除できる`Mk:remove`を追加

* fix

* Update Changelog
This commit is contained in:
かっこかり
2025-01-04 15:16:58 +09:00
committed by GitHub
parent faea401dcc
commit 256560e8ba
2 changed files with 8 additions and 1 deletions

View File

@@ -75,12 +75,18 @@ export function createAiScriptEnv(opts) {
*/
'Mk:save': values.FN_NATIVE(([key, value]) => {
utils.assertString(key);
utils.expectAny(value);
miLocalStorage.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(miLocalStorage.getItem(`aiscript:${opts.storageKey}:${key.value}`)));
return utils.jsToVal(miLocalStorage.getItemAsJson(`aiscript:${opts.storageKey}:${key.value}`) ?? null);
}),
'Mk:remove': values.FN_NATIVE(([key]) => {
utils.assertString(key);
miLocalStorage.removeItem(`aiscript:${opts.storageKey}:${key.value}`);
return values.NULL;
}),
'Mk:url': values.FN_NATIVE(() => {
return values.STR(window.location.href);