rmqtt-http-api 0.23.0

This plugin provides HTTP APIs for integration with external systems, enabling operations like querying client information and publishing messages.
/* ============================================================
   RMQTT Dashboard — 插件管理页
   ============================================================ */
window.PluginsPage = Vue.defineComponent({
  name: 'PluginsPage',
  template: `

    <div>

      <div class="table-wrap">

        <table>

          <thead>

            <tr>

              <th></th>

              <th></th>

              <th></th>

              <th></th>

            </tr>

          </thead>

          <tbody>

            <tr v-for="p in plugins" :key="p.name || p.Name">

              <td>{{ p.name || p.Name }}</td>

              <td>{{ p.version || p.Version || '-' }}</td>

              <td>

                <span :class="p.running || p.Running ? 'status-online' : 'status-offline'">

                  {{ p.running || p.Running ? ' ' : ' ' }}

                </span>

              </td>

              <td>

                <button class="btn-icon" style="width:auto;padding:4px 12px;font-size:12px;"

                        @click="viewConfig(p)" :title="$t('plugins.config')">

                  {{ $t('plugins.config') }}

                </button>

              </td>

            </tr>

            <tr v-if="plugins.length === 0">

              <td colspan="4" style="text-align:center;color:var(--text-muted);padding:40px;"></td>

            </tr>

          </tbody>

        </table>

      </div>



      <!--  -->

      <div v-if="showConfig" style="position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:100;">

        <div style="background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:24px;width:600px;max-height:80vh;overflow-y:auto;">

          <h3 style="margin-bottom:12px;">{{ configPluginName }} </h3>

          <pre style="background:var(--bg);padding:12px;border-radius:var(--radius);font-size:12px;overflow-x:auto;white-space:pre-wrap;">{{ configContent }}</pre>

          <div style="margin-top:12px;text-align:right;">

            <button class="btn btn-primary" @click="showConfig = false"></button>

          </div>

        </div>

      </div>

    </div>

  `,
  setup() {
    const plugins = Vue.ref([]);
    const showConfig = Vue.ref(false);
    const configPluginName = Vue.ref('');
    const configContent = Vue.ref('');

    async function loadPlugins() {
      try {
        const data = await http.get('/plugins');
        plugins.value = Array.isArray(data) ? data : [];
      } catch (e) {
        console.error(e);
      }
    }

    async function viewConfig(p) {
      const name = p.name || p.Name;
      configPluginName.value = name;
      showConfig.value = true;
      configContent.value = '加载中...';
      try {
        const data = await http.get('/plugins/' + encodeURIComponent(name) + '/config');
        configContent.value = JSON.stringify(data, null, 2);
      } catch (e) {
        configContent.value = '获取失败: ' + e.message;
      }
    }

    Vue.onMounted(loadPlugins);

    return { plugins, showConfig, configPluginName, configContent, viewConfig };
  },
});