zz-shopify-components 0.0.3 → 0.0.4

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.
@@ -44,7 +44,9 @@ var bindSiteJump = bindSiteJump
44
44
  const country = countryElement.innerText.trim();
45
45
  const targetUrl = siteMap[country] || siteMap['default'] || '/';
46
46
  // window.location.href = targetUrl; // 跳转到匹配的站点
47
- toSubSiteBP(targetUrl);
47
+ if (toSubSiteBP) {
48
+ toSubSiteBP(targetUrl);
49
+ }
48
50
  } else {
49
51
  console.error('SiteJump: Country element not found');
50
52
  }
@@ -5,31 +5,32 @@
5
5
  var bindSiteJump = bindSiteJump
6
6
  ? bindSiteJump
7
7
  : function bindSiteJump(el, links) {
8
- if (!links) {
9
- console.log('SiteJump: links are required');
10
- return;
11
- }
12
-
13
- const SITE_JUMP_MAP = links;
14
- console.log(SITE_JUMP_MAP, 'SITE_JUMP_MAP');
15
- const arr = SITE_JUMP_MAP.split('\n'); // 按换行符拆分为数组
16
- const siteMap = {};
17
- // 将站点地图解析成对象
18
- arr.forEach((item) => {
19
- const [key, value] = item.split(': ');
20
- if (key && value) {
21
- siteMap[key.trim()] = value.trim();
8
+ if (!links) {
9
+ console.log('SiteJump: links are required');
10
+ return;
22
11
  }
23
- });
24
12
 
25
- const countryElement =
26
- document.getElementsByClassName('countryWord')[0];
27
- if (countryElement) {
28
- const country = countryElement.innerText.trim();
29
- const targetUrl = siteMap[country] || siteMap['default'] || '/';
30
- // 加跟踪参数并跳转到匹配的站点
31
- toSubSiteBP(targetUrl);
32
- } else {
33
- console.error('SiteJump: Country element not found');
34
- }
35
- };
13
+ const SITE_JUMP_MAP = links;
14
+ console.log(SITE_JUMP_MAP, 'SITE_JUMP_MAP');
15
+ const arr = SITE_JUMP_MAP.split('\n'); // 按换行符拆分为数组
16
+ const siteMap = {};
17
+ // 将站点地图解析成对象
18
+ arr.forEach((item) => {
19
+ const [key, value] = item.split(': ');
20
+ if (key && value) {
21
+ siteMap[key.trim()] = value.trim();
22
+ }
23
+ });
24
+
25
+ const countryElement = document.getElementsByClassName('countryWord')[0];
26
+ if (countryElement) {
27
+ const country = countryElement.innerText.trim();
28
+ const targetUrl = siteMap[country] || siteMap['default'] || '/';
29
+ // 加跟踪参数并跳转到匹配的站点
30
+ if (toSubSiteBP) {
31
+ toSubSiteBP(targetUrl);
32
+ }
33
+ } else {
34
+ console.error('SiteJump: Country element not found');
35
+ }
36
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": ["shopify", "theme", "components"],
6
6
  "license": "CC BY-NC-ND",