mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-12 21:58:58 +09:00
MisskeyPagesで値が0の変数が表示されない問題を修正
This commit is contained in:
parent
e86d0007c6
commit
c886c09cdb
@ -316,8 +316,10 @@ export class AiScript {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private interpolate(str: string, values: { name: string, value: any }[]) {
|
private interpolate(str: string, values: { name: string, value: any }[]) {
|
||||||
return str.replace(/\{(.+?)\}/g, match =>
|
return str.replace(/\{(.+?)\}/g, match => {
|
||||||
(this.getVariableValue(match.slice(1, -1).trim(), values) || '').toString());
|
const v = this.getVariableValue(match.slice(1, -1).trim(), values);
|
||||||
|
return v == null ? 'NULL' : v.toString();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
|
@ -31,6 +31,7 @@ class Script {
|
|||||||
constructor(aiScript) {
|
constructor(aiScript) {
|
||||||
this.aiScript = aiScript;
|
this.aiScript = aiScript;
|
||||||
this.vars = this.aiScript.evaluateVars();
|
this.vars = this.aiScript.evaluateVars();
|
||||||
|
console.log(this.vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public reEval() {
|
public reEval() {
|
||||||
@ -38,8 +39,10 @@ class Script {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interpolate(str: string) {
|
public interpolate(str: string) {
|
||||||
return str.replace(/\{(.+?)\}/g, match =>
|
return str.replace(/\{(.+?)\}/g, match => {
|
||||||
(this.vars.find(x => x.name === match.slice(1, -1).trim()).value || '').toString());
|
const v = this.vars.find(x => x.name === match.slice(1, -1).trim()).value;
|
||||||
|
return v == null ? 'NULL' : v.toString();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user