This commit is contained in:
yumoqing 2024-12-06 23:46:51 +08:00
parent b7edc34bdd
commit 7fca12127f
3 changed files with 21 additions and 12 deletions

View File

@ -300,6 +300,7 @@ var _buildWidget = async function(from_widget, target, mode, options){
}
bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
/*
var f = async function(target, mode, options){
bricks.debug('target=', target, 'mode=', mode, 'options=', options);
var w = await (bricks.widgetBuild(options, w));
@ -316,6 +317,7 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
target.add_widget(w);
}
}
*/
var options = objcopy(desc.options||{});
var params = options.params || {};
if (desc.event_params instanceof FormData){
@ -342,6 +344,7 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
return _buildWidget.bind(w, target, target, desc.mode || 'replace', opts);
}
bricks.buildBricksHandler = function(w, target, rtdata, desc){
/*
var f = async function(target, mode, options){
bricks.debug('target=', target, 'mode=', mode, 'options=', options);
var w = await (bricks.widgetBuild(options, wa));
@ -354,7 +357,9 @@ bricks.buildBricksHandler = function(w, target, rtdata, desc){
}
target.add_widget(w);
}
*/
var options = objcopy(desc.options||{});
rtdata = bricks.extend(rtdata, inputdata2dic(desc.event_params));
options = bricks.apply_data(options, rtdata);
return _buildWidget.bind(w, target, target, desc.mode || 'replace', options);
}
@ -371,6 +376,7 @@ bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
if (rtdata){
bricks.extend(params, rtdata);
}
bricks.extend(params, inputdata2dic(desc.event_params));
params = bricks.apply_data(params, rtdata);
return f.bind(target, params);
}
@ -383,6 +389,7 @@ bricks.buildMethodHandler = function(w, target, rtdata, desc){
var params = {};
bricks.extend(params, desc.params)
bricks.extend(params, rtdata);
bricks.extend(params, inputdata2dic(desc.event_params));
params = bricks.apply_data(params, rtdata);
return f.bind(target, params);
}
@ -390,6 +397,7 @@ bricks.buildScriptHandler = function(w, target, rtdata, desc){
var params = {};
bricks.extend(params, desc.params)
bricks.extend(params, rtdata);
bricks.extend(params, inputdata2dic(desc.event_params));
params = bricks.apply_data(params, rtdata);
var AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
var f = new AsyncFunction('params', 'event', desc.script);
@ -403,6 +411,7 @@ bricks.buildDispatchEventHandler = function(w, target, rtdata, desc){
var params = {};
bricks.extend(params, desc.params)
bricks.extend(params, rtdata);
bricks.extend(params, inputdata2dic(desc.event_params));
params = bricks.apply_data(params, rtdata);
return f.bind(target, desc.dispatch_event, params);
}

View File

@ -1,17 +1,5 @@
bricks = window.bricks || {}
var inputdata2dic = function(data){
if (! data instanceof FormData) return data;
var d = {}
for (let k of data.keys()){
var x = data.get(k);
x = x instanceof File? x:x.toString();
y = Object.prototype.toString.call(x)
d[k] = x;
console.log('x=', x, 'k=', k, 'x type=', y);
}
return d;
}
bricks.LlmMsgAudio = class extends bricks.UpStreaming {
constructor(opts){
super(opts);

View File

@ -1,5 +1,17 @@
var bricks = window.bricks || {};
bricks.bug = false;
var inputdata2dic = function(data){
try {
var d = {}
for (let k of data.keys()){
var x = data.get(k);
d[k] = x;
}
return d;
} catch (e){
return data;
}
}
bricks.delete_null_values = function(obj) {
for (let key in obj) {
if (obj[key] === null) {