sbd-npm 1.4.34 → 1.4.35

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 (2) hide show
  1. package/package.json +1 -1
  2. package/util.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.34",
3
+ "version": "1.4.35",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/util.js CHANGED
@@ -62,7 +62,7 @@ const Util = {
62
62
  $("#search-stock").click(function () {
63
63
  let code = $("#stock").val();
64
64
  if (code) {
65
- if (Util.is_alpha(code) && window.location.pathname === "/status" && $("#word").hasClass('active')) {
65
+ if (window.location.pathname === "/status" && $("#word").hasClass('active') && (Util.is_alpha(code) || Util.is_chinese(code))) {
66
66
  Util.fetch_word_data(0, "", code);
67
67
  } else {
68
68
  window.open("/stock/" + code, "_blank");
@@ -2547,7 +2547,7 @@ const Util = {
2547
2547
  * @returns {boolean}
2548
2548
  */
2549
2549
  is_alpha: function (str) {
2550
- return /^[A-Za-z]*$/.test(str);
2550
+ return /^[A-Za-z]+$/.test(str);
2551
2551
  },
2552
2552
 
2553
2553
  /**
@@ -2559,6 +2559,15 @@ const Util = {
2559
2559
  return /^\d+$/.test(str);
2560
2560
  },
2561
2561
 
2562
+ /**
2563
+ * 是否都是中文
2564
+ * @param str
2565
+ * @returns {boolean}
2566
+ */
2567
+ is_chinese: function (str) {
2568
+ return /^[\u4e00-\u9fa5]+$/.test(str);
2569
+ },
2570
+
2562
2571
  /**
2563
2572
  * 判断一个字符串是否有中文
2564
2573
  * @param str