"use strict";(self["webpackChunkblivechat"]=self["webpackChunkblivechat"]||[]).push([[456],{8456:function(t,i,e){e.r(i),e.d(i,{default:function(){return h}});var n=function(){var t=this,i=t._self._c;return i("div",[i("div",{staticStyle:{display:"flex","align-items":"center"}},[i("h1",{staticStyle:{display:"inline"}},[t._v(t._s(t.$t("plugins.plugins")))]),i("el-button",{staticClass:"push-inline-end",attrs:{round:"",icon:"el-icon-question"},on:{click:function(i){t.isHelpVisible=!0}}},[t._v(t._s(t.$t("plugins.help")))]),i("el-dialog",{attrs:{title:t.$t("plugins.help"),visible:t.isHelpVisible},on:{"update:visible":function(i){t.isHelpVisible=i}}},[i("div",{staticStyle:{"word-break":"initial"},domProps:{innerHTML:t._s(t.$t("plugins.helpContent"))}})])],1),0===t.plugins.length?i("el-empty",{attrs:{description:""}}):i("el-row",{attrs:{gutter:16}},t._l(t.plugins,(function(e){return i("el-col",{key:e.id,attrs:{sm:24,md:12}},[i("el-card",{staticClass:"card"},[i("div",{staticClass:"card-body"},[i("div",{staticClass:"title-line"},[i("h3",{staticClass:"name"},[t._v(t._s(e.name))]),i("span",{staticClass:"version"},[t._v(t._s(e.version))]),i("span",{staticClass:"author push-inline-end"},[t._v(t._s(t.$t("plugins.author"))+t._s(e.author))])]),i("div",{staticClass:"description"},[t._v(t._s(e.description))]),i("div",{staticClass:"operations"},[i("el-tooltip",{attrs:{content:t.$t("plugins.disabledByServer"),disabled:t.serverConfig.enableAdminPlugins}},[i("el-button",{attrs:{type:"primary",disabled:!t.serverConfig.enableAdminPlugins||!e.isConnected,loading:t.getPluginCtx(e.id).isOperating},on:{click:function(i){return t.adminPlugin(e)}}},[t._v(t._s(t.$t("plugins.admin")))])],1),e.isConnected?i("el-tag",{staticClass:"status push-inline-end",attrs:{type:"success"}},[t._v(t._s(t.$t("plugins.connected")))]):i("el-tag",{staticClass:"status push-inline-end",attrs:{type:"danger"}},[t._v(t._s(t.$t("plugins.unconnected")))]),i("el-switch",{attrs:{value:e.enabled,disabled:!t.serverConfig.enableAdminPlugins||t.getPluginCtx(e.id).isOperating},on:{change:i=>t.setPluginEnabled(e,i)}})],1)])])],1)})),1)],1)},s=[],a=e(9196),l=e(7389);async function r(){return(await l.x1.get("/api/plugin/plugins")).data}async function u(t,i){return(await l.x1.post("/api/plugin/enable_plugin",{pluginId:t,enabled:i})).data}async function o(t){return(await l.x1.post("/api/plugin/open_admin_ui",{pluginId:t})).data}var c={name:"Plugins",data(){return{serverConfig:{enableAdminPlugins:!0},isHelpVisible:!1,plugins:[],pluginCtxMap:{}}},mounted(){this.updateServerConfig(),this.updatePlugins()},methods:{getPluginCtx(t){let i=this.pluginCtxMap[t];return void 0===i&&(i={isOperating:!1},this.$set(this.pluginCtxMap,t,i)),i},async updateServerConfig(){try{this.serverConfig=(await a.L6()).config}catch(t){throw this.$message.error(`Failed to fetch server information: ${t}`),t}},async updatePlugins(){try{this.plugins=(await r()).plugins}catch(t){throw this.$message.error(`Failed to fetch plugins: ${t}`),t}},async adminPlugin(t){let i=this.getPluginCtx(t.id);i.isOperating=!0;try{await o(t.id)}catch(e){throw this.$message.error(`Request failed: ${e}`),e}finally{i.isOperating=!1}},async setPluginEnabled(t,i){let e=this.getPluginCtx(t.id);e.isOperating=!0;try{let e;try{e=await u(t.id,i)}catch(n){throw this.$message.error(`Request failed: ${n}`),n}t.enabled=e.enabled,e.isSwitchSuccess||this.$message.error(`Failed to switch the plugin: ${e.msg}`),await new Promise((t=>window.setTimeout(t,3e3))),this.updatePlugins()}finally{e.isOperating=!1}}}},d=c,p=e(1001),g=(0,p.Z)(d,n,s,!1,null,"29781127",null),h=g.exports},9196:function(t,i,e){e.d(i,{L6:function(){return s},mO:function(){return a},uR:function(){return l}});var n=e(7389);async function s(){return(await n.x1.get("/api/server_info")).data}async function a(t){let i=new FormData;return i.set("file",t),(await n.x1.post("/api/emoticon",i)).data}async function l(){return(await n.x1.get("/api/templates")).data}}}]);
//# sourceMappingURL=456.99576718.js.map