Files
server-configs/siyuan/data/plugins/kmind-plugin/js/chunk-5a7fea00.js
2026-02-13 22:24:27 +08:00

1 line
18 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(window["webpackJsonpkmind_plugin"]=window["webpackJsonpkmind_plugin"]||[]).push([["chunk-5a7fea00"],{"25fc":function(e,t,a){"use strict";a("efd9")},"2ca4":function(e,t,a){var i=a("24fb");t=i(!1),t.push([e.i,".theme-batch-page[data-v-38ddfa3e]{display:flex;height:100vh;padding:12px;background:#f5f7fa;box-sizing:border-box}.left-panel[data-v-38ddfa3e]{width:300px;background:#fff;border-radius:8px;padding:16px;box-shadow:0 1px 3px rgba(0,0,0,.06);display:flex;flex-direction:column;margin-right:12px}.panel-title[data-v-38ddfa3e]{font-size:16px;font-weight:600;margin:0 0 12px 0}.panel-subtitle[data-v-38ddfa3e]{font-size:13px;font-weight:500;margin-bottom:8px}.options-form[data-v-38ddfa3e]{margin-top:8px}.slider-row[data-v-38ddfa3e]{display:flex;align-items:center;gap:8px}.slider-value[data-v-38ddfa3e]{width:46px;text-align:right;font-size:12px;color:#606266}.actions[data-v-38ddfa3e],.export-actions[data-v-38ddfa3e]{display:flex;flex-direction:column;gap:8px;margin-top:8px}.hint-text[data-v-38ddfa3e]{font-size:12px;color:#909399}.hint-text[data-v-38ddfa3e],.manual-json-input[data-v-38ddfa3e]{margin-top:8px}.manual-actions[data-v-38ddfa3e]{margin-top:8px;display:flex;gap:8px}.right-panel[data-v-38ddfa3e]{flex:1;display:flex;flex-direction:column;background:#fff;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,.06);padding:16px;min-width:0}.right-header[data-v-38ddfa3e]{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:12px}.right-title[data-v-38ddfa3e]{font-size:16px;font-weight:600;margin:0}.right-subtitle[data-v-38ddfa3e]{font-size:13px;color:#909399;margin:4px 0 0 0}.table-wrapper[data-v-38ddfa3e]{flex:1;min-height:0}.cover-preview[data-v-38ddfa3e]{width:180px;height:120px;border-radius:6px;overflow:hidden;background:#f5f7fa;display:flex;align-items:center;justify-content:center}.cover-preview img[data-v-38ddfa3e]{width:100%;height:100%;-o-object-fit:contain;object-fit:contain}.no-cover[data-v-38ddfa3e]{font-size:12px;color:#909399}.action-cell[data-v-38ddfa3e]{display:flex;flex-direction:column;gap:4px;align-items:flex-start}@media (max-width:1000px){.theme-batch-page[data-v-38ddfa3e]{flex-direction:column}.left-panel[data-v-38ddfa3e]{width:100%;margin-bottom:12px}}",""]),e.exports=t},5899:function(e,t,a){"use strict";a.r(t);var i=function(){var e=this,t=e._self._c;return t("div",{staticClass:"theme-batch-page"},[t("div",{staticClass:"left-panel"},[t("h2",{staticClass:"panel-title"},[e._v("Material 3 批量主题生成")]),t("el-form",{staticClass:"options-form",attrs:{"label-width":"100px",size:"small"}},[t("el-form-item",{attrs:{label:"色相数量"}},[t("el-input-number",{attrs:{min:1,max:24},model:{value:e.options.hueCount,callback:function(t){e.$set(e.options,"hueCount",t)},expression:"options.hueCount"}})],1),t("el-form-item",{attrs:{label:"每色相变体"}},[t("el-input-number",{attrs:{min:1,max:6},model:{value:e.options.variantsPerHue,callback:function(t){e.$set(e.options,"variantsPerHue",t)},expression:"options.variantsPerHue"}})],1),t("el-form-item",{attrs:{label:"暗色主题比例"}},[t("div",{staticClass:"slider-row"},[t("el-slider",{staticStyle:{flex:"1"},attrs:{min:0,max:1,step:.1},model:{value:e.options.darkRatio,callback:function(t){e.$set(e.options,"darkRatio",t)},expression:"options.darkRatio"}}),t("span",{staticClass:"slider-value"},[e._v(" "+e._s(Math.round(100*e.options.darkRatio))+"% ")])],1)])],1),t("div",{staticClass:"actions"},[t("el-button",{attrs:{type:"primary",loading:e.generating},on:{click:e.handleGenerate}},[e._v(" 生成主题 (预计 "+e._s(e.estimatedCount)+" 个) ")]),t("el-button",{attrs:{disabled:0===e.generatedThemes.length},on:{click:e.clearAll}},[e._v(" 清空 ")])],1),t("el-divider"),t("h3",{staticClass:"panel-subtitle"},[e._v("导出 & 下载")]),t("div",{staticClass:"export-actions"},[t("el-button",{attrs:{type:"success",disabled:0===e.generatedThemes.length},on:{click:e.exportBundleJson}},[e._v(" 导出导入包 (JSON) ")]),t("el-button",{attrs:{disabled:0===e.generatedThemes.length},on:{click:e.copyBundleJson}},[e._v(" 复制导入包 JSON ")]),t("el-button",{attrs:{disabled:0===e.generatedThemes.length},on:{click:e.downloadAllCovers}},[e._v(" 批量下载封面 (PNG) ")])],1),t("p",{staticClass:"hint-text"},[e._v(" 提示:导出的 JSON 可在 kmind-next 后台「主题导入」页面选择账号后批量导入。 ")]),t("el-divider"),t("h3",{staticClass:"panel-subtitle"},[e._v("手动添加主题")]),t("p",{staticClass:"hint-text"},[e._v(" 在此粘贴单个主题的 JSON结构与主题设计器导出的主题一致点击「解析并添加」后会加入到列表并自动生成封面。 ")]),t("el-input",{staticClass:"manual-json-input",attrs:{type:"textarea",rows:8,placeholder:"粘贴主题 JSON例如从主题设计器导出的内容包含 meta 和样式配置)"},model:{value:e.manualThemeJson,callback:function(t){e.manualThemeJson=t},expression:"manualThemeJson"}}),t("div",{staticClass:"manual-actions"},[t("el-button",{attrs:{size:"small",type:"primary",loading:e.addingFromJson},on:{click:e.handleAddThemeFromJson}},[e._v(" 解析并添加 ")]),t("el-button",{attrs:{size:"small"},on:{click:function(t){e.manualThemeJson=""}}},[e._v(" 清空输入 ")])],1)],1),t("div",{staticClass:"right-panel"},[t("div",{staticClass:"right-header"},[t("div",[t("h3",{staticClass:"right-title"},[e._v("已生成主题 ("+e._s(e.generatedThemes.length)+")")]),t("p",{staticClass:"right-subtitle"},[e._v(" 可在此调整名称和描述,封面为使用示例导图自动渲染的预览图。 ")])])]),t("div",{staticClass:"table-wrapper"},[t("el-table",{staticStyle:{width:"100%"},attrs:{data:e.generatedThemes,height:"100%"}},[t("el-table-column",{attrs:{prop:"name",label:"名称",width:"260"},scopedSlots:e._u([{key:"default",fn:function(a){return[t("el-input",{attrs:{size:"mini",maxlength:"100","show-word-limit":""},model:{value:a.row.name,callback:function(t){e.$set(a.row,"name",t)},expression:"scope.row.name"}})]}}])}),t("el-table-column",{attrs:{prop:"description",label:"描述"},scopedSlots:e._u([{key:"default",fn:function(a){return[t("el-input",{attrs:{size:"mini",maxlength:"200","show-word-limit":""},model:{value:a.row.description,callback:function(t){e.$set(a.row,"description",t)},expression:"scope.row.description"}})]}}])}),t("el-table-column",{attrs:{label:"封面预览",width:"220"},scopedSlots:e._u([{key:"default",fn:function(a){return[t("div",{staticClass:"cover-preview"},[a.row.coverDataUrl?t("img",{attrs:{src:a.row.coverDataUrl,alt:"cover"}}):t("span",{staticClass:"no-cover"},[e._v("生成中...")])])]}}])}),t("el-table-column",{attrs:{prop:"isDark",label:"暗色",width:"80"},scopedSlots:e._u([{key:"default",fn:function(a){return[t("el-tag",{attrs:{type:a.row.isDark?"info":"warning",size:"mini"}},[e._v(" "+e._s(a.row.isDark?"是":"否")+" ")])]}}])}),t("el-table-column",{attrs:{label:"操作",width:"160"},scopedSlots:e._u([{key:"default",fn:function(a){return[t("div",{staticClass:"action-cell"},[t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(t){return e.openInDesigner(a.$index)}}},[e._v(" 用设计器编辑 ")]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(t){return e.previewJson(a.$index)}}},[e._v(" 预览JSON ")]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(t){return e.copyRowJson(a.$index)}}},[e._v(" 复制JSON ")]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(t){return e.removeOne(a.$index)}}},[e._v(" 删除 ")])],1)]}}])})],1)],1)]),t("el-dialog",{attrs:{title:"主题设计器",visible:e.themeDesignerVisible,width:"90%","close-on-click-modal":!1},on:{"update:visible":function(t){e.themeDesignerVisible=t}}},[t("div",{staticStyle:{height:"600px"}},[e.themeDesignerVisible?t("ThemeDesigner",{attrs:{plugin:{},"initial-theme":e.editingThemeData},on:{"update:theme":e.handleDesignerUpdate}}):e._e()],1),t("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(t){e.themeDesignerVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.confirmDesignerChanges}},[e._v(" 应用到当前主题 ")])],1)]),t("el-dialog",{attrs:{title:e.jsonPreviewTitle||"主题 JSON 预览",visible:e.jsonPreviewVisible,width:"70%"},on:{"update:visible":function(t){e.jsonPreviewVisible=t}}},[t("el-input",{attrs:{type:"textarea",rows:20,readonly:""},model:{value:e.jsonPreviewText,callback:function(t){e.jsonPreviewText=t},expression:"jsonPreviewText"}})],1)],1)},n=[],o=(a("14d9"),a("88a7"),a("271a"),a("5494"),a("7145")),s=a("13cc"),r=a("67c2"),l=a("e1bd"),d=a("2e40");s["a"].init(o["a"]),o["a"].usePlugin(r["a"]);const c=Object(l["a"])("0123456789abcdefghijklmnopqrstuvwxyz",24),m={data:{text:"KMIND"},children:[{data:{text:"Subtopic",generalization:{text:"Summary"}},children:[{data:{text:"Add Content"},children:[]},{data:{text:"Add Content"},children:[]}]},{data:{text:"Subtopic"},children:[{data:{text:"Add Content"},children:[]},{data:{text:"Add Content"},children:[]}]}]};function h(e,t,a){return`hsl(${e}, ${t}%, ${a}%)`}function p(e,t,a,i){const n=(new Date).toISOString(),o=i?8:98,s=i?20:30,r=i?28:45,l=i?18:96,d=i?70:30,m=(a-1)*(i?4:-4),p=e=>Math.max(0,Math.min(100,e)),g=h(t,i?10:8,p(o+(i?0:m))),u=h(t,60,p(s+m)),f=h(t,50,p(r+m)),v=h(t,i?28:10,p(l+m)),x=h(t,40,p(d+(i?5:-5))),b="#FFFFFF",y=i?"#E2E8F0":"#2D3748";return{meta:{id:"km-theme-"+c(),name:e,i18n:{name:{zh_CN:e,en_US:e},description:{zh_CN:"",en_US:""}},author:"",version:"1.0.0",description:"",createTime:n,updateTime:n},backgroundColor:g,lineColor:x,lineWidth:1.5,lineStyle:"straight",lineRadius:8,paddingX:16,paddingY:8,generalizationLineWidth:1,generalizationLineColor:x,root:{shape:"rectangle",fillColor:u,color:b,borderColor:"",borderWidth:2,borderDasharray:"",borderRadius:14,fontSize:20,fontWeight:"bold",fontFamily:"",textAlign:"center",textVerticalAlign:"middle",paddingX:24,paddingY:14,imgMaxWidth:100,imgMaxHeight:100},second:{shape:"rectangle",fillColor:f,color:b,borderColor:"",borderWidth:1.5,borderDasharray:"",borderRadius:10,fontSize:16,fontWeight:"normal",fontFamily:"",textAlign:"left",textVerticalAlign:"middle",paddingX:20,paddingY:10,marginX:100,marginY:40,imgMaxWidth:100,imgMaxHeight:100},node:{shape:"rectangle",fillColor:v,color:y,borderColor:"transparent",borderWidth:1,borderDasharray:"",borderRadius:6,fontSize:14,fontWeight:"normal",fontFamily:"",textAlign:"left",textVerticalAlign:"middle",paddingX:16,paddingY:8,marginX:50,marginY:0,imgMaxWidth:100,imgMaxHeight:100},generalization:{shape:"rectangle",fillColor:i?h(t,28,18):"#FFF5F5",color:i?"#FED7D7":"#742A2A",borderColor:i?h(t,40,60):"#FC8181",borderWidth:1,borderDasharray:"",borderRadius:8,fontSize:14,fontWeight:"normal",fontFamily:"",textAlign:"center",textVerticalAlign:"middle",paddingX:12,paddingY:6,imgMaxWidth:100,imgMaxHeight:100}}}var g={name:"ThemeBatchGenerator",components:{ThemeDesigner:d["a"]},data(){return{options:{hueCount:8,variantsPerHue:3,darkRatio:.4},generating:!1,generatedThemes:[],themeDesignerVisible:!1,editingThemeIndex:null,editingThemeData:null,jsonPreviewVisible:!1,jsonPreviewTitle:"",jsonPreviewText:"",manualThemeJson:"",addingFromJson:!1}},computed:{estimatedCount(){return this.options.hueCount*this.options.variantsPerHue}},methods:{buildBundlePayload(){return{version:1,generatedAt:(new Date).toISOString(),themes:this.generatedThemes.map(e=>({name:e.name,description:e.description||"",metaId:e.metaId||e.themeData.meta&&e.themeData.meta.id||null,version:e.version||"1.0.0",changeLog:e.changeLog||"",coverDataUrl:e.coverDataUrl,themeData:e.themeData}))}},async handleGenerate(){if(!this.generating){this.generating=!0;try{const{hueCount:e,variantsPerHue:t,darkRatio:a}=this.options,i=[];for(let n=0;n<e;n++){const o=Math.round(360/e*n);for(let e=1;e<=t;e++){const t=Math.random()<a,s=`KMind M3 ${t?"Dark":"Light"} ${n+1}-${e}`,r=p(s,o,e,t),l=await this.generateCover(r);i.push({name:s,description:"",metaId:r.meta.id,version:r.meta.version,changeLog:"",isDark:t,coverDataUrl:l,themeData:r}),i.length%4===0&&await new Promise(e=>setTimeout(e,20))}}this.generatedThemes=i,this.$message.success(`已生成 ${i.length} 个主题`)}catch(e){console.error("生成主题失败:",e),this.$message.error("生成主题失败")}finally{this.generating=!1}}},async generateCover(e){try{const t=document.createElement("div");t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.style.width="400px",t.style.height="300px",document.body.appendChild(t);const a=`preview-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,i={...e};delete i.meta,o["a"].defineTheme(a,i);const n=new o["a"]({el:t,data:m,theme:a,layout:"logicalStructure",readonly:!0,isShowCreateChildBtnIcon:!1,mousewheelAction:"zoom"});await new Promise(e=>setTimeout(e,120));const s=await n.export("png",!1,"preview");return n.destroy(),document.body.removeChild(t),s}catch(t){return console.error("生成封面失败:",t),""}},exportBundleJson(){if(!this.generatedThemes.length)return;const e=this.buildBundlePayload(),t=new Blob([JSON.stringify(e,null,2)],{type:"application/json;charset=utf-8"}),a=URL.createObjectURL(t),i=document.createElement("a");i.href=a,i.download=`kmind-theme-batch-${Date.now()}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a),this.$message.success("已导出 JSON 导入包")},async copyBundleJson(){if(!this.generatedThemes.length)return;const e=this.buildBundlePayload(),t=JSON.stringify(e,null,2);try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}this.$message.success("已复制导入包 JSON 到剪贴板")}catch(a){console.error("复制导入包 JSON 失败:",a),this.$message.error("复制导入包 JSON 失败")}},downloadAllCovers(){const e=this.generatedThemes.filter(e=>e.coverDataUrl);e.length&&(e.forEach((e,t)=>{setTimeout(()=>{const t=document.createElement("a");t.href=e.coverDataUrl,t.download=(e.name||e.metaId||"theme")+"-cover.png",document.body.appendChild(t),t.click(),document.body.removeChild(t)},200*t)}),this.$message.success(`开始下载 ${e.length} 个封面`))},clearAll(){this.generatedThemes=[],this.$message.success("已清空生成列表")},removeOne(e){this.generatedThemes.splice(e,1)},previewJson(e){const t=this.generatedThemes[e];if(!t)return;this.jsonPreviewTitle=t.name||t.metaId||"主题 "+(e+1);const a={name:t.name,description:t.description,metaId:t.metaId,version:t.version,changeLog:t.changeLog,isDark:t.isDark,coverDataUrl:t.coverDataUrl,themeData:t.themeData};this.jsonPreviewText=JSON.stringify(a,null,2),this.jsonPreviewVisible=!0},async copyRowJson(e){const t=this.generatedThemes[e];if(!t)return;const a={themes:[{name:t.name,description:t.description||"",metaId:t.metaId||t.themeData.meta&&t.themeData.meta.id||null,version:t.version||"1.0.0",changeLog:t.changeLog||"",coverDataUrl:t.coverDataUrl,themeData:t.themeData}]},i=JSON.stringify(a,null,2);try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(i);else{const e=document.createElement("textarea");e.value=i,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}this.$message.success("已复制该主题的导入 JSON")}catch(n){console.error("复制行 JSON 失败:",n),this.$message.error("复制该主题 JSON 失败")}},async handleAddThemeFromJson(){if(this.manualThemeJson&&this.manualThemeJson.trim()){this.addingFromJson=!0;try{let t=null;try{t=JSON.parse(this.manualThemeJson)}catch(e){return void this.$message.error("JSON 解析失败,请检查格式")}const a=Array.isArray(t)?t:[t];if(!a.length)return void this.$message.warning("未解析到有效的主题对象");let i=0;for(let e=0;e<a.length;e++){const t=a[e];if(!t||"object"!==typeof t)continue;const n=t.meta||{},o=n.name||"Imported Theme "+Date.now(),s="string"===typeof n.description?n.description:"",r="km-theme-"+c(),l=n.version||"1.0.0",d=t.backgroundColor||"",m="string"===typeof d&&(d.toLowerCase().includes("#0")||d.toLowerCase().includes("#1")||d.toLowerCase().includes("hsl")&&d.includes("%")),h=JSON.parse(JSON.stringify(t));h.meta||(h.meta={}),h.meta.id=r,h.meta.name||(h.meta.name=o),h.meta.version||(h.meta.version=l),"string"===typeof s&&(h.meta.description=s);const p=await this.generateCover(h);this.generatedThemes.push({name:o,description:s,metaId:r,version:l,changeLog:"",isDark:m,coverDataUrl:p,themeData:h}),i++,e%3===0&&await new Promise(e=>setTimeout(e,10))}i>0?this.$message.success(`已从 JSON 添加 ${i} 个主题`):this.$message.warning("未能从 JSON 中提取有效主题")}finally{this.addingFromJson=!1}}else this.$message.warning("请先粘贴主题 JSON")},openInDesigner(e){const t=this.generatedThemes[e];t&&t.themeData&&(this.editingThemeIndex=e,this.editingThemeData=JSON.parse(JSON.stringify(t.themeData)),this.themeDesignerVisible=!0)},handleDesignerUpdate(e){e&&(this.editingThemeData=JSON.parse(JSON.stringify(e)))},async confirmDesignerChanges(){if(null===this.editingThemeIndex||this.editingThemeIndex<0||this.editingThemeIndex>=this.generatedThemes.length||!this.editingThemeData)this.themeDesignerVisible=!1;else try{const e=this.generatedThemes[this.editingThemeIndex],t=JSON.parse(JSON.stringify(this.editingThemeData));t.meta&&t.meta.name&&(e.name=t.meta.name),t.meta&&"string"===typeof t.meta.description&&(e.description=t.meta.description),e.themeData=t;const a=await this.generateCover(t);a&&(e.coverDataUrl=a),this.$message.success("已应用主题设计器中的修改")}catch(e){console.error("应用设计器修改失败:",e),this.$message.error("应用设计器修改失败")}finally{this.themeDesignerVisible=!1,this.editingThemeIndex=null,this.editingThemeData=null}}}},u=g,f=(a("25fc"),a("2877")),v=Object(f["a"])(u,i,n,!1,null,"38ddfa3e",null);t["default"]=v.exports},efd9:function(e,t,a){var i=a("2ca4");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var n=a("499e").default;n("294438e0",i,!0,{sourceMap:!1,shadowMode:!1})}}]);