Improve AiScript
This commit is contained in:
parent
d0af2c2a98
commit
52ebf2055e
6 changed files with 80 additions and 75 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div v-show="script.vars.find(x => x.name === value.var).value">
|
||||
<div v-show="script.vars[value.var]">
|
||||
<x-block v-for="child in value.children" :value="child" :page="page" :script="script" :key="child.id" :h="h"/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import { url } from '../../../../config';
|
|||
|
||||
class Script {
|
||||
public aiScript: AiScript;
|
||||
public vars: any;
|
||||
public vars: Record<string, any>;
|
||||
|
||||
constructor(aiScript) {
|
||||
this.aiScript = aiScript;
|
||||
|
|
@ -41,7 +41,7 @@ class Script {
|
|||
public interpolate(str: string) {
|
||||
if (str == null) return null;
|
||||
return str.replace(/\{(.+?)\}/g, match => {
|
||||
const v = this.vars.find(x => x.name === match.slice(1, -1).trim()).value;
|
||||
const v = this.vars[match.slice(1, -1).trim()];
|
||||
return v == null ? 'NULL' : v.toString();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue