sbd-npm 1.4.59 → 1.4.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/status.js +3 -3
  3. package/util.js +116 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.59",
3
+ "version": "1.4.60",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -772,7 +772,7 @@ $(function () {
772
772
  let pid = $(this).parent().parent().children('td').eq(0).text();
773
773
  if (confirm("是否确定要终止进程 [" + pid + "] ?")) {
774
774
  Util.show_loading();
775
- let action_content = "kill_" + pid;
775
+ let action_content = "kill_pid_" + pid;
776
776
  Util.post(location.pathname, {active_div: "machine_action_add", "machine_id": $("#machines").val(), "content": action_content, action_type: 2}, function (j) {
777
777
  Util.hide_tips();
778
778
  if (j["code"] === 1) {
@@ -853,9 +853,9 @@ $(function () {
853
853
  voices.forEach(voice => {
854
854
  data.push(`Name: ${voice.name}, Lang: ${voice.lang}, Default: ${voice.default}`);
855
855
  });
856
- alert(data.join("\n"));
856
+ Util.showAlert(data.join("\n"));
857
857
  } else {
858
- alert("空列表: []");
858
+ Util.showAlert("空列表: []");
859
859
  }
860
860
  Util.is_load = false;
861
861
  },
package/util.js CHANGED
@@ -4650,6 +4650,122 @@ const Util = {
4650
4650
  ]
4651
4651
  });
4652
4652
  return chart_instance;
4653
+ },
4654
+
4655
+ /**
4656
+ * 显示自定义弹窗
4657
+ * @param {string} message - 要显示的消息内容
4658
+ * @returns {void}
4659
+ */
4660
+ showAlert: function(message) {
4661
+ // 创建模态框容器
4662
+ const modal = document.createElement('div');
4663
+ modal.style.cssText = `
4664
+ position: fixed;
4665
+ top: 0;
4666
+ left: 0;
4667
+ width: 100%;
4668
+ height: 100%;
4669
+ background-color: rgba(0, 0, 0, 0.5);
4670
+ display: flex;
4671
+ justify-content: center;
4672
+ align-items: center;
4673
+ z-index: 9999;
4674
+ `;
4675
+ // 创建模态框内容
4676
+ const modalContent = document.createElement('div');
4677
+ modalContent.style.cssText = `
4678
+ background-color: white;
4679
+ padding: 20px;
4680
+ border-radius: 5px;
4681
+ max-width: 80%;
4682
+ max-height: 80%;
4683
+ overflow: auto;
4684
+ position: relative;
4685
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
4686
+ display: flex;
4687
+ flex-direction: column;
4688
+ align-items: center;
4689
+ `;
4690
+ // 创建消息内容
4691
+ const messageElement = document.createElement('div');
4692
+ messageElement.style.cssText = `
4693
+ margin-bottom: 20px;
4694
+ word-break: break-all;
4695
+ padding: 10px;
4696
+ border: 1px solid #ddd;
4697
+ background-color: #f9f9f9;
4698
+ width: 100%;
4699
+ box-sizing: border-box;
4700
+ `;
4701
+ messageElement.innerHTML = message.replace(/\n/g, '<br>');
4702
+ // 创建按钮容器
4703
+ const buttonContainer = document.createElement('div');
4704
+ buttonContainer.style.cssText = `
4705
+ display: flex;
4706
+ gap: 10px;
4707
+ margin-top: 10px;
4708
+ `;
4709
+ // 创建复制按钮
4710
+ const copyButton = document.createElement('button');
4711
+ copyButton.textContent = '复制';
4712
+ copyButton.style.cssText = `
4713
+ padding: 8px 20px;
4714
+ background-color: #4CAF50;
4715
+ color: white;
4716
+ border: none;
4717
+ border-radius: 3px;
4718
+ cursor: pointer;
4719
+ font-size: 14px;
4720
+ `;
4721
+ copyButton.addEventListener('click', function() {
4722
+ navigator.clipboard.writeText(message).then(
4723
+ function() {
4724
+ // 复制成功,临时改变按钮文字
4725
+ const originalText = copyButton.textContent;
4726
+ copyButton.textContent = '已复制';
4727
+ copyButton.style.backgroundColor = '#45a049';
4728
+ setTimeout(function() {
4729
+ copyButton.textContent = originalText;
4730
+ copyButton.style.backgroundColor = '#4CAF50';
4731
+ }, 2000);
4732
+ },
4733
+ function() {
4734
+ // 复制失败
4735
+ alert('复制失败,请重试');
4736
+ }
4737
+ );
4738
+ });
4739
+ // 创建关闭按钮
4740
+ const closeButton = document.createElement('button');
4741
+ closeButton.textContent = '关闭';
4742
+ closeButton.style.cssText = `
4743
+ padding: 8px 20px;
4744
+ background-color: #f44336;
4745
+ color: white;
4746
+ border: none;
4747
+ border-radius: 3px;
4748
+ cursor: pointer;
4749
+ font-size: 14px;
4750
+ `;
4751
+ closeButton.addEventListener('click', function() {
4752
+ document.body.removeChild(modal);
4753
+ });
4754
+ // 组装按钮容器
4755
+ buttonContainer.appendChild(copyButton);
4756
+ buttonContainer.appendChild(closeButton);
4757
+ // 组装模态框
4758
+ modalContent.appendChild(messageElement);
4759
+ modalContent.appendChild(buttonContainer);
4760
+ modal.appendChild(modalContent);
4761
+ // 添加到页面
4762
+ document.body.appendChild(modal);
4763
+ // 点击模态框背景也可以关闭
4764
+ modal.addEventListener('click', function(event) {
4765
+ if (event.target === modal) {
4766
+ document.body.removeChild(modal);
4767
+ }
4768
+ });
4653
4769
  }
4654
4770
 
4655
4771
  };