mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 07:43:09 +02:00
Resolve #6242
This commit is contained in:
parent
f07047d1e8
commit
e7da10ae58
2 changed files with 13 additions and 2 deletions
|
@ -72,7 +72,9 @@ export default Vue.extend({
|
||||||
methods: {
|
methods: {
|
||||||
async run() {
|
async run() {
|
||||||
this.logs = [];
|
this.logs = [];
|
||||||
const aiscript = new AiScript(createAiScriptEnv(this), {
|
const aiscript = new AiScript(createAiScriptEnv(this, {
|
||||||
|
storageKey: 'scratchpad'
|
||||||
|
}), {
|
||||||
in: (q) => {
|
in: (q) => {
|
||||||
return new Promise(ok => {
|
return new Promise(ok => {
|
||||||
this.$root.dialog({
|
this.$root.dialog({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { utils, values } from '@syuilo/aiscript';
|
import { utils, values } from '@syuilo/aiscript';
|
||||||
|
|
||||||
export function createAiScriptEnv(vm) {
|
export function createAiScriptEnv(vm, opts) {
|
||||||
return {
|
return {
|
||||||
USER_ID: values.STR(vm.$store.state.i.id),
|
USER_ID: values.STR(vm.$store.state.i.id),
|
||||||
USER_USERNAME: values.STR(vm.$store.state.i.username),
|
USER_USERNAME: values.STR(vm.$store.state.i.username),
|
||||||
|
@ -24,5 +24,14 @@ export function createAiScriptEnv(vm) {
|
||||||
const res = await vm.$root.api(ep.value, utils.valToJs(param), token || null);
|
const res = await vm.$root.api(ep.value, utils.valToJs(param), token || null);
|
||||||
return utils.jsToVal(res);
|
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)));
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue