@jx3box/jx3box-common-ui 9.3.0 → 9.3.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-common-ui",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <div class="c-header-search" id="c-header-search">
3
3
  <div class="c-search">
4
- <form class="u-form" :action="url" :target="isPhone ? '_self' : '_blank'">
5
- <input class="u-text" type="text" autocomplete="off" name="q" placeholder="搜索.." />
4
+ <form class="u-form" @submit.prevent="handleSubmit">
5
+ <input class="u-text" type="text" autocomplete="off" name="q" placeholder="搜索.." ref="searchInput" />
6
6
  <input type="hidden" name="client" :value="client" />
7
- <i class="u-btn">
7
+ <i class="u-btn" @click="handleSubmit">
8
8
  <img svg-inline src="../../assets/img/header/search-key-slash.svg" />
9
9
  </i>
10
10
  </form>
@@ -24,7 +24,47 @@ export default {
24
24
  };
25
25
  },
26
26
  computed: {},
27
- methods: {},
27
+ methods: {
28
+ handleSubmit(e) {
29
+ // 获取输入框的值
30
+ const searchValue = this.$refs.searchInput.value;
31
+ if (!searchValue) return;
32
+
33
+ // 检查输入是否为纯数字
34
+ if (/^\d+$/.test(searchValue)) {
35
+ // 如果是纯数字,直接跳转到 /{id}
36
+ const target = this.isPhone ? "_self" : "_blank";
37
+ const url = __Root + `post/${searchValue}`;
38
+ if (target === "_blank") {
39
+ window.open(url, "_blank");
40
+ } else {
41
+ window.location.href = url;
42
+ }
43
+ } else {
44
+ // 如果不是纯数字,使用原有搜索功能
45
+ const form = document.createElement("form");
46
+ form.method = "GET";
47
+ form.action = this.url;
48
+ form.target = this.isPhone ? "_self" : "_blank";
49
+
50
+ const searchInput = document.createElement("input");
51
+ searchInput.type = "hidden";
52
+ searchInput.name = "q";
53
+ searchInput.value = searchValue;
54
+
55
+ const clientInput = document.createElement("input");
56
+ clientInput.type = "hidden";
57
+ clientInput.name = "client";
58
+ clientInput.value = this.client;
59
+
60
+ form.appendChild(searchInput);
61
+ form.appendChild(clientInput);
62
+ document.body.appendChild(form);
63
+ form.submit();
64
+ document.body.removeChild(form);
65
+ }
66
+ },
67
+ },
28
68
  created: function () {},
29
69
  components: {},
30
70
  };
@@ -15,8 +15,8 @@
15
15
  >
16
16
  </li>
17
17
  </ul>
18
- <el-pagination small layout="prev, pager, next" :total="total" :current-page.sync="index" hide-on-single-page>
19
- </el-pagination>
18
+ <!-- <el-pagination small layout="prev, pager, next" :total="total" :current-page.sync="index" hide-on-single-page>
19
+ </el-pagination> -->
20
20
  <version-dialog
21
21
  v-if="visible"
22
22
  v-model="visible"