diff --git a/static/js/form.js b/static/js/form.js
index 42d6cdb0..dfec1cfa 100644
--- a/static/js/form.js
+++ b/static/js/form.js
@@ -606,10 +606,12 @@ function _wnd_render_form(container, form_json, add_class = '') {
* - 之所以不直接提取从 field 中提取 value 组合对象,因为表单中可能存在动态字段,此类字段增删目前采用的是直接操作dom,无法同步 VUE
* - 之所以提取表单数据后,又转化为 json,是为了保持后端数据统一为 json,以确保后期适配 APP、小程序等,与站内请求一致
* - 将表单数据与默认表单数据合并的原因在于,表单对未选择的单选,复选字段不会构造数据,从而导致数据键值丢失,无法通过表单签名(_wnd_sign)
+ * - Object.assign 执行浅拷贝,故此需要深拷贝一份 default_data 以防止 this.default_data 被表单数据覆盖,导致修改如取消 checkbox 无效
**/
let form = document.querySelector('#' + this.form.attrs.id);
let form_data = new FormData(form);
- let json = Object.assign(this.default_data, this.formdata_to_object(form_data));
+ let default_data = JSON.parse(JSON.stringify(this.default_data));
+ let json = Object.assign(default_data, this.formdata_to_object(form_data));
let params = {};
if ('get' == this.form.attrs.method.toLowerCase()) {
diff --git a/static/js/form.min.js b/static/js/form.min.js
index 89698c29..bec8f7f5 100644
--- a/static/js/form.min.js
+++ b/static/js/form.min.js
@@ -1 +1 @@
-function _wnd_render_form(e,t,i=""){function s(e){function t(){return`\n
`}function i(e){let t="";for(let s=0;s\n\n\n
\n`),"html"==a.type)t+=a.value;else if(l.includes(a.type))t+=n.build_text(d,s);else if("radio"==a.type||"checkbox"==a.type)t+=n.build_radio(d,s);else if("hidden"==a.type)t+='';else{let e="build_"+a.type;t+=n[e](d,s)}function i(){return e.attrs["is-horizontal"]&&!["html","hidden"].includes(a.type)}i()&&(t+="
")}return t}function a(e){return`\n\n\n
`}let n=s;return build_label=((e,t)=>``),n.build_text=((e,t)=>`\n\n${build_label(e)}\n
\n
\n\n\n\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_radio=((e,t)=>`\n\n${build_label(e)}\n
\n\n\n\n
\n
{{${e}.help.text}}
\n
`),n.build_select=((e,t)=>`\n\n${build_label(e)}\n
\n
\n
\n\n
\n
\n
\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_select_linked=((e,t)=>`\n\n${build_label(e)}\n
\n
\n
\n\n
\n
\n
\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_textarea=((e,t)=>`\n\n${build_label(e)}\n
\n
{{${e}.help.text}}
\n
`),n.build_file_upload=((e,t)=>`\n\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_image_upload=((e,t)=>`\n\n
\n\n${build_label(e)}\n
\n\n\n
\n
{{${e}.help.text}}
\n
\n
`),n.build_editor=((e,t)=>`\n\n${build_label(e)}\n
\n
{{${e}.help.text}}
\n
`),n.build_tag_input=((e,t)=>{let i=document.createElement("style");i.innerHTML="\n.tags-input{width:100%;border-bottom:1px solid #ccc}\n.tags-input input{border:none;width:100%;font-size:1rem;position:absolute;top:0;bottom:0;height:100%;}\n.tags-input input:focus{border:none;box-shadow:none;outline:0;}\n.tags-input .tag{margin:5px}\n.tags-input .autocomplete{position:relative;display:inline-block;min-height:3rem;}\n.tags-input .autocomplete-items{position:absolute;box-shadow:0 2px 10px #999;border-bottom:none;border-top:none;z-index:99;top:100%;left:0}\n.tags-input .autocomplete-items li{padding:10px;cursor:pointer;background-color:#fff;border-bottom:1px solid #eee}\n.tags-input .autocomplete-items li:hover{background-color:#eee}",document.head.appendChild(i);let s=`\n\n{{tag}}\n`,l=`\n\n{{tag}}\n`;return`\n\n${build_label(e)}\n
\n
{{${e}.help.text}}
\n
`}),t()}let l=["text","number","email","password","url","color","date","range","tel"],a=JSON.parse(JSON.stringify(t)),n=document.querySelector(e);i&&n.classList.add(i);let d={template:s(a),data:()=>({form:a,index:{editor:[],captcha:"",ids:[]},default_data:{}}),methods:{html_encode:function(e){let t=document.createElement("div");t.innerText=e;let i=t.innerHTML;return t=null,i},html_decode:function(e){var t=document.createElement("div");t.innerHTML=e;var i=t.innerText;return t=null,i},has_addon:function(e){return e.addon_left||e.addon_right},has_icon:function(e){return e.icon_left||e.icon_right},get_field_class:function(e){return this.has_addon(e)?"field has-addons":"field"},get_control_class:function(e){let t="control";return t+=this.has_addon(e)?" is-expanded":"",t+=e.icon_left?" has-icons-left":"",t+=e.icon_right?" has-icons-right":"",t},get_field_id:function(e,t){return e.id||this.form.attrs.id+"-"+t},get_value:function(e){let t=["checkbox","radio"].includes(e.type)?[]:"",i=e.checked||e.selected;return e.value?t=e.value:i&&("object"!=typeof i||i.length||Object.keys(i).length)&&(t=e.checked||e.selected),t="object"==typeof t?Object.values(t):t,t},parse_input_attr:function(e,t=[]){let i=JSON.parse(JSON.stringify(e));return Object.keys(i).forEach(e=>{i[e]&&""!=i[e]||delete i[e]}),t.forEach(e=>{delete i[e]}),i.class=(l.includes(e.type)?"input":e.type)+" "+(i.class||""),i.class+=" "+this.form.size,delete i.icon_left,delete i.icon_right,delete i.addon_left,delete i.addon_right,delete i.options,delete i.label,delete i.help,delete i.value,delete i.checked,delete i.selected,delete i.options,"file_upload"==i.type?i.type="file":"select"!=i.type&&"select_linked"!=i.type||delete i.type,delete i.data,delete i.linkage,i},build_editor:function(){function e(){i.index.editor.forEach(e=>{t(e)})}function t(e){let t=i.form.fields[e],s=i.form.attrs["data-post-id"]||0,l=`#${i.form.attrs.id}-${e}`;tinymce.init({branding:!1,selector:l,menubar:!1,language:"zh_CN",cache_suffix:cache_suffix,autosave_restore_when_empty:!0,autosave_prefix:"tinymce-autosave-"+s,autosave_ask_before_unload:!1,relative_urls:!1,remove_script_host:!1,pagebreak_separator:"",pagebreak_split_block:!0,plugins:"advlist autolink autoresize autosave code codesample fullscreen image link lists pagebreak wordcount wndimage wndinit",toolbar:"formatselect | alignleft aligncenter alignright bullist numlist | blockquote wndimage link codesample pagebreak wndpaidcontent | removeformat code fullscreen",wnd_config:{rest_nonce:wnd.rest_nonce,upload_url:t.upload_url,post_parent:s,oss_direct_upload:i.form.attrs["data-oss-direct-upload"]},setup:function(s){texarea=document.querySelector(l),texarea.style.removeProperty("display"),s.on("change",function(){t.value=tinymce.get(`${i.form.attrs.id}-${e}`).getContent(),n.style.removeProperty("height")})},init_instance_callback:function(e){i.$nextTick(function(){funTransitionHeight(n,trs_time)})}})}let i=this;if("undefined"==typeof tinymce){let t=static_path+"editor/tinymce/tinymce.min.js"+cache_suffix;wnd_load_script(t,function(){e()})}else e()},click_target(e){document.querySelector(e).click()},should_be_disabled:function(e,t){if("checkbox"==e.type&&e.max>0){let i=e.checked;if(i.length>=e.max&&!i.includes(t))return!0}return!1},change:function(e,t){if(e.linkage){let s=t.target.value,l=e.linkage.query||!1,a=e.linkage.data&&e.linkage.data[s]||!1,n=e.linkage.params||{};function i(t,i){e.linkage.fields.forEach(e=>{let s=t.index.ids[e],l=t.form.fields[s];l=Object.assign(l,i)})}n[e.name]=s,a?i(this,a):l&&wnd_query(l,n,e=>{i(this,e.data)})}e.class=e.class.replace("is-danger",""),e.help.class=e.help.class.replace("is-danger",""),e.help.text=e.help.text.replace(" "+wnd.msg.required,""),this.$nextTick(function(){funTransitionHeight(n,trs_time)})},selected(e,t,i){let s=this.form.fields[i],l=s.data.query,a=Object.assign(s.data.params,{parent:e.target.value});this.change(s),wnd_query(l,a,e=>{let i=e.data;Object.keys(i).length?(s.options.splice(t+1,s.options.length,i),s.selected[t+1]=""):(s.options.splice(t+1,s.options.length),s.selected.length=t+1)})},upload:function(e,t){function i(e,t){let i=new Image,l=new FileReader;l.onload=function(){var a=l.result;i.src=a,i.onload=function(l){s(t,i,e)}},l.readAsDataURL(t)}function s(e,i,s){let n=document.createElement("canvas");n.width=t.data.save_width,n.height=t.data.save_height;let d=Math.max(n.width/i.naturalWidth,n.height/i.naturalHeight),c=n.getContext("2d");c.scale(d,d);var u=(c.canvas.width/d-i.naturalWidth)/2,p=(c.canvas.height/d-i.naturalHeight)/2;c.drawImage(i,u,p),n.toBlob(t=>{let i=new File([t],e.name,{type:e.type});o.append("wnd_file["+s+"]",i),r.form.attrs["data-oss-direct-upload"]?a(i):l(o)},e.type)}function l(){axios({url:wnd_action_api+"/common/wnd_upload_file",method:"post",data:o,headers:{},onUploadProgress:function(e){t.help.text=wnd.msg.waiting,t.help.class="is-primary"}}).then(e=>{if(e.data.status<=0)t.help.text=e.data.msg,t.help.class="is-danger";else{let i=e.data.data;for(let e=0,s=i.length;e'+wnd.msg.view+""),"image_upload"==t.type||"file_upload"==t.type||t.type}r.$nextTick(function(){funTransitionHeight(n,trs_time)})}).catch(e=>{console.log(e)})}async function a(e){let i=await wnd_upload_to_oss(e,t.data);i?(t.help.text=wnd.msg.upload_successfully,t.help.class="is-success",t.thumbnail=i.signed_url||i.url,t.file_id=i.id,t.file_name=wnd.msg.upload_successfully+' '+wnd.msg.view+"",r.$nextTick(function(){funTransitionHeight(n,trs_time)})):(t.help.text=wnd.msg.upload_failed,t.help.class="is-danger")}let d=e.target.files,o=new FormData,r=this;if(t.data)for(const e in t.data)o.append(e,t.data[e]);for(let e=0,s=d.length;e{if(s.data.status<=0)return wnd_alert_notification(s.data.msg,"is-danger"),!1;e.thumbnail=t.fields[i].default_thumbnail,e.file_name=wnd.msg.deleted,e.file_id=0,"image_upload"==e.type||"file_upload"==e.type||e.type}).catch(e=>{console.log(e)})},suggest_tags:function(e,t){let i=this.form.fields[t],s={search:e,taxonomy:i.data.taxonomy};axios({method:"get",url:wnd_query_api+"/wnd_term_searcher",params:s}).then(e=>{i.data.suggestions=e.data.data})},enter_tag:function(e,t){let i=this.form.fields[t];if(!e.target.value||i.value.length>=i.data.max)return!1;i.value.push(e.target.value.trim()),e.target.value=""},enter_tag_by_sg:function(e,t){let i=this.form.fields[t];i.value.push(e.target.innerText.trim()),i.data.suggestions="";let s=e.target.closest(".tags-input").querySelector("[type=text]");s.value=""},delete_tag:function(e,t){let i=this.form.fields[t];i.value=i.value.filter(function(t){return t!==e})},handle_tag_input_click:function(e,t){let i=this.form.fields[t];i.value.length>=i.data.max&&(i.help.text="最多"+i.data.max+"个标签")},formdata_to_object:function(e){let t={};return e.forEach((e,i)=>{i.includes("[]")?(i=i.replace("[]",""),Reflect.has(t,i)?t[i].push(e):t[i]=[e]):t[i]=e}),t},submit:function(e){if(this.form.submit.attrs.class=t.submit.attrs.class+" is-loading",this.index.captcha){let t=this.form.fields[this.index.captcha];if(!t.value)return void wnd_submit_via_captcha(e)}let i=!0;for(const[e,s]of this.form.fields.entries()){if(!s.name||!s.required)continue;let l=!0,a=this.get_value(s),n=Object.values(s.options);n.includes(a)||("string"!=typeof a||a.length?Array.isArray(a)&&a.every(e=>!e)?l=!1:a||0===a||(l=!1):l=!1,l||(s.class=t.fields[e].class+" is-danger",s.help.class=t.fields[e].help.class+" is-danger",s.help.text=t.fields[e].help.text+" "+wnd.msg.required,i=!1))}if(!i)return this.form.submit.attrs.class=t.submit.attrs.class,this.$nextTick(function(){funTransitionHeight(n,trs_time)}),!1;let s=document.querySelector("#"+this.form.attrs.id),l=new FormData(s),a=Object.assign(this.default_data,this.formdata_to_object(l)),d={};"get"==this.form.attrs.method.toLowerCase()&&(d=a),axios({method:this.form.attrs.method,url:this.form.attrs.action,data:a,params:d}).then(e=>{info=wnd_handle_response(e.data,this.form.attrs.route,n),this.form.message.message=!1===info.msg?this.form.message.message:info.msg,this.form.message.attrs.class=t.message.attrs.class+" "+info.msg_class,this.form.submit.attrs.class=t.submit.attrs.class,this.index.captcha&&(this.form.fields[this.index.captcha].value=""),this.$nextTick(function(){funTransitionHeight(n,trs_time)})}).catch(function(e){console.log(e)})}},created(){for(let e=0,t=this.form.fields.length;e0&&this.build_editor(),funTransitionHeight(n,trs_time),wnd_inner_html(`#${this.form.attrs.id} .form-script`,this.form.script)}};wnd_inner_html(n,''),Vue.createApp(d).mount(e+" .vue-app")}document.addEventListener("click",function(e){let t=e.target.closest("button");if(!t)return;let i=t.closest("form");if(!i)return;let s=i.parentNode;if(t.classList.contains("add-row")){let e=t.closest(".field");t.classList.remove("add-row"),t.classList.add("remove-row"),t.innerText="-";let i=t.closest(".field").cloneNode(!0);t.classList.add("add-row"),t.classList.remove("remove-row"),t.innerText="+",e.after(i),funTransitionHeight(s,trs_time)}else t.classList.contains("remove-row")&&(t.closest(".field").outerHTML="",funTransitionHeight(s,trs_time))});
\ No newline at end of file
+function _wnd_render_form(e,t,i=""){function s(e){function t(){return`\n`}function i(e){let t="";for(let s=0;s\n\n\n
\n`),"html"==l.type)t+=l.value;else if(a.includes(l.type))t+=n.build_text(d,s);else if("radio"==l.type||"checkbox"==l.type)t+=n.build_radio(d,s);else if("hidden"==l.type)t+='';else{let e="build_"+l.type;t+=n[e](d,s)}function i(){return e.attrs["is-horizontal"]&&!["html","hidden"].includes(l.type)}i()&&(t+="
")}return t}function l(e){return`\n\n\n
`}let n=s;return build_label=((e,t)=>``),n.build_text=((e,t)=>`\n\n${build_label(e)}\n
\n
\n\n\n\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_radio=((e,t)=>`\n\n${build_label(e)}\n
\n\n\n\n
\n
{{${e}.help.text}}
\n
`),n.build_select=((e,t)=>`\n\n${build_label(e)}\n
\n
\n
\n\n
\n
\n
\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_select_linked=((e,t)=>`\n\n${build_label(e)}\n
\n
\n
\n\n
\n
\n
\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_textarea=((e,t)=>`\n\n${build_label(e)}\n
\n
{{${e}.help.text}}
\n
`),n.build_file_upload=((e,t)=>`\n\n
\n
\n
{{${e}.help.text}}
\n
`),n.build_image_upload=((e,t)=>`\n\n
\n\n${build_label(e)}\n
\n\n\n
\n
{{${e}.help.text}}
\n
\n
`),n.build_editor=((e,t)=>`\n\n${build_label(e)}\n
\n
{{${e}.help.text}}
\n
`),n.build_tag_input=((e,t)=>{let i=document.createElement("style");i.innerHTML="\n.tags-input{width:100%;border-bottom:1px solid #ccc}\n.tags-input input{border:none;width:100%;font-size:1rem;position:absolute;top:0;bottom:0;height:100%;}\n.tags-input input:focus{border:none;box-shadow:none;outline:0;}\n.tags-input .tag{margin:5px}\n.tags-input .autocomplete{position:relative;display:inline-block;min-height:3rem;}\n.tags-input .autocomplete-items{position:absolute;box-shadow:0 2px 10px #999;border-bottom:none;border-top:none;z-index:99;top:100%;left:0}\n.tags-input .autocomplete-items li{padding:10px;cursor:pointer;background-color:#fff;border-bottom:1px solid #eee}\n.tags-input .autocomplete-items li:hover{background-color:#eee}",document.head.appendChild(i);let s=`\n\n{{tag}}\n`,a=`\n\n{{tag}}\n`;return`\n\n${build_label(e)}\n
\n
{{${e}.help.text}}
\n
`}),t()}let a=["text","number","email","password","url","color","date","range","tel"],l=JSON.parse(JSON.stringify(t)),n=document.querySelector(e);i&&n.classList.add(i);let d={template:s(l),data:()=>({form:l,index:{editor:[],captcha:"",ids:[]},default_data:{}}),methods:{html_encode:function(e){let t=document.createElement("div");t.innerText=e;let i=t.innerHTML;return t=null,i},html_decode:function(e){var t=document.createElement("div");t.innerHTML=e;var i=t.innerText;return t=null,i},has_addon:function(e){return e.addon_left||e.addon_right},has_icon:function(e){return e.icon_left||e.icon_right},get_field_class:function(e){return this.has_addon(e)?"field has-addons":"field"},get_control_class:function(e){let t="control";return t+=this.has_addon(e)?" is-expanded":"",t+=e.icon_left?" has-icons-left":"",t+=e.icon_right?" has-icons-right":"",t},get_field_id:function(e,t){return e.id||this.form.attrs.id+"-"+t},get_value:function(e){let t=["checkbox","radio"].includes(e.type)?[]:"",i=e.checked||e.selected;return e.value?t=e.value:i&&("object"!=typeof i||i.length||Object.keys(i).length)&&(t=e.checked||e.selected),t="object"==typeof t?Object.values(t):t,t},parse_input_attr:function(e,t=[]){let i=JSON.parse(JSON.stringify(e));return Object.keys(i).forEach(e=>{i[e]&&""!=i[e]||delete i[e]}),t.forEach(e=>{delete i[e]}),i.class=(a.includes(e.type)?"input":e.type)+" "+(i.class||""),i.class+=" "+this.form.size,delete i.icon_left,delete i.icon_right,delete i.addon_left,delete i.addon_right,delete i.options,delete i.label,delete i.help,delete i.value,delete i.checked,delete i.selected,delete i.options,"file_upload"==i.type?i.type="file":"select"!=i.type&&"select_linked"!=i.type||delete i.type,delete i.data,delete i.linkage,i},build_editor:function(){function e(){i.index.editor.forEach(e=>{t(e)})}function t(e){let t=i.form.fields[e],s=i.form.attrs["data-post-id"]||0,a=`#${i.form.attrs.id}-${e}`;tinymce.init({branding:!1,selector:a,menubar:!1,language:"zh_CN",cache_suffix:cache_suffix,autosave_restore_when_empty:!0,autosave_prefix:"tinymce-autosave-"+s,autosave_ask_before_unload:!1,relative_urls:!1,remove_script_host:!1,pagebreak_separator:"",pagebreak_split_block:!0,plugins:"advlist autolink autoresize autosave code codesample fullscreen image link lists pagebreak wordcount wndimage wndinit",toolbar:"formatselect | alignleft aligncenter alignright bullist numlist | blockquote wndimage link codesample pagebreak wndpaidcontent | removeformat code fullscreen",wnd_config:{rest_nonce:wnd.rest_nonce,upload_url:t.upload_url,post_parent:s,oss_direct_upload:i.form.attrs["data-oss-direct-upload"]},setup:function(s){texarea=document.querySelector(a),texarea.style.removeProperty("display"),s.on("change",function(){t.value=tinymce.get(`${i.form.attrs.id}-${e}`).getContent(),n.style.removeProperty("height")})},init_instance_callback:function(e){i.$nextTick(function(){funTransitionHeight(n,trs_time)})}})}let i=this;if("undefined"==typeof tinymce){let t=static_path+"editor/tinymce/tinymce.min.js"+cache_suffix;wnd_load_script(t,function(){e()})}else e()},click_target(e){document.querySelector(e).click()},should_be_disabled:function(e,t){if("checkbox"==e.type&&e.max>0){let i=e.checked;if(i.length>=e.max&&!i.includes(t))return!0}return!1},change:function(e,t){if(e.linkage){let s=t.target.value,a=e.linkage.query||!1,l=e.linkage.data&&e.linkage.data[s]||!1,n=e.linkage.params||{};function i(t,i){e.linkage.fields.forEach(e=>{let s=t.index.ids[e],a=t.form.fields[s];a=Object.assign(a,i)})}n[e.name]=s,l?i(this,l):a&&wnd_query(a,n,e=>{i(this,e.data)})}e.class=e.class.replace("is-danger",""),e.help.class=e.help.class.replace("is-danger",""),e.help.text=e.help.text.replace(" "+wnd.msg.required,""),this.$nextTick(function(){funTransitionHeight(n,trs_time)})},selected(e,t,i){let s=this.form.fields[i],a=s.data.query,l=Object.assign(s.data.params,{parent:e.target.value});this.change(s),wnd_query(a,l,e=>{let i=e.data;Object.keys(i).length?(s.options.splice(t+1,s.options.length,i),s.selected[t+1]=""):(s.options.splice(t+1,s.options.length),s.selected.length=t+1)})},upload:function(e,t){function i(e,t){let i=new Image,a=new FileReader;a.onload=function(){var l=a.result;i.src=l,i.onload=function(a){s(t,i,e)}},a.readAsDataURL(t)}function s(e,i,s){let n=document.createElement("canvas");n.width=t.data.save_width,n.height=t.data.save_height;let d=Math.max(n.width/i.naturalWidth,n.height/i.naturalHeight),c=n.getContext("2d");c.scale(d,d);var u=(c.canvas.width/d-i.naturalWidth)/2,p=(c.canvas.height/d-i.naturalHeight)/2;c.drawImage(i,u,p),n.toBlob(t=>{let i=new File([t],e.name,{type:e.type});o.append("wnd_file["+s+"]",i),r.form.attrs["data-oss-direct-upload"]?l(i):a(o)},e.type)}function a(){axios({url:wnd_action_api+"/common/wnd_upload_file",method:"post",data:o,headers:{},onUploadProgress:function(e){t.help.text=wnd.msg.waiting,t.help.class="is-primary"}}).then(e=>{if(e.data.status<=0)t.help.text=e.data.msg,t.help.class="is-danger";else{let i=e.data.data;for(let e=0,s=i.length;e'+wnd.msg.view+""),"image_upload"==t.type||"file_upload"==t.type||t.type}r.$nextTick(function(){funTransitionHeight(n,trs_time)})}).catch(e=>{console.log(e)})}async function l(e){let i=await wnd_upload_to_oss(e,t.data);i?(t.help.text=wnd.msg.upload_successfully,t.help.class="is-success",t.thumbnail=i.signed_url||i.url,t.file_id=i.id,t.file_name=wnd.msg.upload_successfully+' '+wnd.msg.view+"",r.$nextTick(function(){funTransitionHeight(n,trs_time)})):(t.help.text=wnd.msg.upload_failed,t.help.class="is-danger")}let d=e.target.files,o=new FormData,r=this;if(t.data)for(const e in t.data)o.append(e,t.data[e]);for(let e=0,s=d.length;e{if(s.data.status<=0)return wnd_alert_notification(s.data.msg,"is-danger"),!1;e.thumbnail=t.fields[i].default_thumbnail,e.file_name=wnd.msg.deleted,e.file_id=0,"image_upload"==e.type||"file_upload"==e.type||e.type}).catch(e=>{console.log(e)})},suggest_tags:function(e,t){let i=this.form.fields[t],s={search:e,taxonomy:i.data.taxonomy};axios({method:"get",url:wnd_query_api+"/wnd_term_searcher",params:s}).then(e=>{i.data.suggestions=e.data.data})},enter_tag:function(e,t){let i=this.form.fields[t];if(!e.target.value||i.value.length>=i.data.max)return!1;i.value.push(e.target.value.trim()),e.target.value=""},enter_tag_by_sg:function(e,t){let i=this.form.fields[t];i.value.push(e.target.innerText.trim()),i.data.suggestions="";let s=e.target.closest(".tags-input").querySelector("[type=text]");s.value=""},delete_tag:function(e,t){let i=this.form.fields[t];i.value=i.value.filter(function(t){return t!==e})},handle_tag_input_click:function(e,t){let i=this.form.fields[t];i.value.length>=i.data.max&&(i.help.text="最多"+i.data.max+"个标签")},formdata_to_object:function(e){let t={};return e.forEach((e,i)=>{i.includes("[]")?(i=i.replace("[]",""),Reflect.has(t,i)?t[i].push(e):t[i]=[e]):t[i]=e}),t},submit:function(e){if(this.form.submit.attrs.class=t.submit.attrs.class+" is-loading",this.index.captcha){let t=this.form.fields[this.index.captcha];if(!t.value)return void wnd_submit_via_captcha(e)}let i=!0;for(const[e,s]of this.form.fields.entries()){if(!s.name||!s.required)continue;let a=!0,l=this.get_value(s),n=Object.values(s.options);n.includes(l)||("string"!=typeof l||l.length?Array.isArray(l)&&l.every(e=>!e)?a=!1:l||0===l||(a=!1):a=!1,a||(s.class=t.fields[e].class+" is-danger",s.help.class=t.fields[e].help.class+" is-danger",s.help.text=t.fields[e].help.text+" "+wnd.msg.required,i=!1))}if(!i)return this.form.submit.attrs.class=t.submit.attrs.class,this.$nextTick(function(){funTransitionHeight(n,trs_time)}),!1;let s=document.querySelector("#"+this.form.attrs.id),a=new FormData(s),l=JSON.parse(JSON.stringify(this.default_data)),d=Object.assign(l,this.formdata_to_object(a)),o={};"get"==this.form.attrs.method.toLowerCase()&&(o=d),axios({method:this.form.attrs.method,url:this.form.attrs.action,data:d,params:o}).then(e=>{info=wnd_handle_response(e.data,this.form.attrs.route,n),this.form.message.message=!1===info.msg?this.form.message.message:info.msg,this.form.message.attrs.class=t.message.attrs.class+" "+info.msg_class,this.form.submit.attrs.class=t.submit.attrs.class,this.index.captcha&&(this.form.fields[this.index.captcha].value=""),this.$nextTick(function(){funTransitionHeight(n,trs_time)})}).catch(function(e){console.log(e)})}},created(){for(let e=0,t=this.form.fields.length;e0&&this.build_editor(),funTransitionHeight(n,trs_time),wnd_inner_html(`#${this.form.attrs.id} .form-script`,this.form.script)}};wnd_inner_html(n,''),Vue.createApp(d).mount(e+" .vue-app")}document.addEventListener("click",function(e){let t=e.target.closest("button");if(!t)return;let i=t.closest("form");if(!i)return;let s=i.parentNode;if(t.classList.contains("add-row")){let e=t.closest(".field");t.classList.remove("add-row"),t.classList.add("remove-row"),t.innerText="-";let i=t.closest(".field").cloneNode(!0);t.classList.add("add-row"),t.classList.remove("remove-row"),t.innerText="+",e.after(i),funTransitionHeight(s,trs_time)}else t.classList.contains("remove-row")&&(t.closest(".field").outerHTML="",funTransitionHeight(s,trs_time))});
\ No newline at end of file
diff --git a/wnd-frontend.php b/wnd-frontend.php
index 2e395b2b..57d53ab6 100644
--- a/wnd-frontend.php
+++ b/wnd-frontend.php
@@ -3,7 +3,7 @@
* Plugin Name: Wnd-Frontend
* Plugin URI: https://github.com/swling/wnd-frontend
* Description: Wnd-Frontend 是一套基于 ajax 交互逻辑的 WordPress 前端基础框架。商业用途需购买授权。更新日志
- * Version: 0.9.59.1
+ * Version: 0.9.59.2
* Author: swling
* Author URI: https://wndwp.com
* Requires PHP: 8.0
@@ -26,7 +26,7 @@
use Wnd\Model\Wnd_Init;
// 版本
-define('WND_VER', '0.9.59.1');
+define('WND_VER', '0.9.59.2');
// 定义插件网址路径
define('WND_URL', plugin_dir_url(__FILE__));