#
Junjie
13 小时以前 6f78dd91ffd0544b5fd3993d5f7d316ee08264d4
#
3个文件已修改
145 ■■■■■ 已修改文件
src/main/webapp/static/js/dashboard/dashboard.js 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/dashboard/dashboard.html 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/index.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/dashboard/dashboard.js
@@ -14,6 +14,7 @@
        rawPayload: null,
        loading: true,
        refreshing: false,
        switchingSystem: false,
        countdown: REFRESH_SECONDS,
        countdownTimer: null,
        resizeHandler: null,
@@ -631,6 +632,16 @@
      displayText: function (value, fallback) {
        return value == null || value === "" ? (fallback || "") : value;
      },
      showMessage: function (message, type) {
        if (this.$message && typeof this.$message === "function") {
          this.$message({
            message: message,
            type: type || "info"
          });
          return;
        }
        console[type === "error" ? "error" : "log"](message);
      },
      networkSamplingText: function () {
        var config = this.network && this.network.samplingConfig ? this.network.samplingConfig : {};
        return this.i18n("dashboard.networkSampling", "采样 {0} ms / 超时 {1} ms / 每样本 {2} 次 / 包大小 {3}", [
@@ -771,6 +782,129 @@
          this.translateLegacyText("监控系统")
        );
      },
      syncParentSystemRunning: function (status) {
        try {
          if (window.parent && window.parent !== window) {
            window.parent.systemRunning = !!status;
          }
        } catch (e) {
        }
      },
      requestSystemSwitch: function (operatorType, password) {
        var self = this;
        this.switchingSystem = true;
        $.ajax({
          url: baseUrl + "/console/system/switch",
          headers: {
            token: localStorage.getItem("token")
          },
          data: {
            operatorType: operatorType,
            password: password || ""
          },
          method: "POST",
          success: function (res) {
            var status;
            if (res && res.code === 200) {
              status = !!(res.data && res.data.status);
              self.overview = Object.assign({}, self.overview, {
                systemRunning: status
              });
              self.syncParentSystemRunning(status);
              self.showMessage(
                status
                  ? self.i18n("dashboard.systemStarted", "系统已启动")
                  : self.i18n("dashboard.systemStopped", "系统已停止"),
                "success"
              );
              self.loadDashboard(false);
              return;
            }
            if (res && res.code === 403) {
              window.location.href = baseUrl + "/login";
              return;
            }
            self.showMessage(
              (res && res.msg) || self.i18n("dashboard.systemSwitchFailed", "系统状态切换失败"),
              "error"
            );
          },
          error: function () {
            self.showMessage(
              self.i18n("dashboard.systemSwitchFailedDetail", "系统状态切换失败,请检查接口状态"),
              "error"
            );
          },
          complete: function () {
            self.switchingSystem = false;
          }
        });
      },
      startSystem: function () {
        if (this.overview.systemRunning || this.switchingSystem) {
          return;
        }
        this.requestSystemSwitch(1);
      },
      maskStopSystemPromptInput: function () {
        setTimeout(function () {
          var input = document.querySelector(".el-message-box__wrapper .el-message-box__input input");
          if (!input) {
            return;
          }
          input.setAttribute("type", "text");
          input.setAttribute("name", "dashboard-stop-code");
          input.setAttribute("autocomplete", "new-password");
          input.setAttribute("autocapitalize", "off");
          input.setAttribute("autocorrect", "off");
          input.setAttribute("spellcheck", "false");
          input.setAttribute("data-form-type", "other");
          input.style.webkitTextSecurity = "disc";
        }, 30);
      },
      stopSystem: function () {
        var self = this;
        var proceed = function (password) {
          var cleanPassword = String(password == null ? "" : password).trim();
          if (!cleanPassword) {
            self.showMessage(self.i18n("dashboard.stopSystemPasswordRequired", "请输入停止系统口令"), "warning");
            return;
          }
          self.requestSystemSwitch(0, cleanPassword);
        };
        if (!this.overview.systemRunning || this.switchingSystem) {
          return;
        }
        if (typeof this.$prompt === "function") {
          this.$prompt(
            this.i18n("dashboard.stopSystemPrompt", "请输入口令,并停止 WCS 系统"),
            this.i18n("dashboard.stopSystemTitle", "停止系统"),
            {
              confirmButtonText: this.i18n("common.confirm", "确定"),
              cancelButtonText: this.i18n("common.cancel", "取消"),
              inputType: "text",
              inputPattern: /\S+/,
              inputErrorMessage: this.i18n("dashboard.stopSystemPasswordRequired", "请输入停止系统口令")
            }
          ).then(function (result) {
            proceed(result && result.value);
          }).catch(function () {
          });
          this.maskStopSystemPromptInput();
          return;
        }
        proceed(window.prompt(this.i18n("dashboard.stopSystemPrompt", "请输入口令,并停止 WCS 系统"), ""));
      },
      toggleSystem: function () {
        if (this.overview.systemRunning) {
          this.stopSystem();
          return;
        }
        this.startSystem();
      },
      openDevicePingAnalysis: function () {
        this.openParentMenuView(
          "/views/devicePingLog/devicePingLog.html",
src/main/webapp/views/dashboard/dashboard.html
@@ -717,6 +717,13 @@
      </div>
      <div class="hero-actions">
        <el-button size="small" plain @click="openMonitor">{{ i18n('dashboard.openMonitor', '打开监控画面') }}</el-button>
        <el-button
            size="small"
            :type="overview.systemRunning ? 'danger' : 'success'"
            plain
            :disabled="switchingSystem"
            :loading="switchingSystem"
            @click="toggleSystem">{{ overview.systemRunning ? i18n('dashboard.stopSystem', '停止系统') : i18n('dashboard.startSystem', '启动系统') }}</el-button>
        <el-button size="small" type="primary" :loading="refreshing" @click="loadDashboard(true)">{{ i18n('dashboard.refreshNow', '立即刷新') }}</el-button>
      </div>
    </div>
@@ -1054,6 +1061,6 @@
<script type="text/javascript" src="../../static/vue/js/vue.min.js"></script>
<script type="text/javascript" src="../../static/vue/element/element.js"></script>
<script type="text/javascript" src="../../static/js/echarts/echarts.min.js"></script>
<script type="text/javascript" src="../../static/js/dashboard/dashboard.js?v=20260317-dashboard-network-i18n"></script>
<script type="text/javascript" src="../../static/js/dashboard/dashboard.js?v=20260317-dashboard-stop-password-mask"></script>
</body>
</html>
src/main/webapp/views/index.html
@@ -862,7 +862,7 @@
<script type="text/javascript" src="../static/vue/js/vue.min.js"></script>
<script type="text/javascript" src="../static/vue/element/element.js"></script>
<script>
  var DASHBOARD_VIEW_VERSION = "20260317-dashboard-network-balanced-columns";
  var DASHBOARD_VIEW_VERSION = "20260317-dashboard-stop-password-mask";
  var HOME_TAB_CONFIG = {
    title: "系统仪表盘",
    url: baseUrl + "/views/dashboard/dashboard.html?layoutVersion=" + encodeURIComponent(DASHBOARD_VIEW_VERSION),