wgt-node-utils 1.1.2 → 1.1.5

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": "wgt-node-utils",
3
- "version": "1.1.2",
3
+ "version": "1.1.5",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -694,38 +694,33 @@ class wgtNodeUtils {
694
694
  * @param {string} hostname 网站域名
695
695
  * @returns
696
696
  */
697
- getPolicyAndContact = (url, hostname) => {
698
- return new Promise((resolve) => {
699
- axios.get(url).then(res => {
700
- let policyAndContact = res.data.data.properties;
701
- if (!policyAndContact) {
702
- policyAndContact = {
703
- contact: '',
704
- txt: setPolicyText(hostname, 'This Privacy Policy is effective [ Jan 5,], 2021 for all users.')
705
- }
706
- } else {
707
- const { txt, title } = policyAndContact;
708
- if (title) {
709
- policyAndContact.txt = `<h2>${title}</h2>${txt}`
710
- }
711
- }
712
- let data;
713
- if (hostname) {
714
- data = {
715
- txt: policyAndContact.txt
716
- }
717
- } else {
718
- if (policyAndContact.contact) {
719
- data = {
720
- contact: `<a href="mailto:${policyAndContact.contact}">${policyAndContact.contact}</a>`
721
- }
722
- } else {
723
- data = { contact: '' }
724
- }
725
- }
726
- resolve(data);
727
- })
728
- })
729
- }
697
+ getPolicyAndContact = async (url, hostname) => {
698
+ let self = this
699
+ try {
700
+ const res = await axios.get(url);
701
+ const properties = res.data?.data?.properties || {};
702
+
703
+ // 默认值
704
+ const contactEmail = properties.contact || "gamebridgenoreply@gmail.com";
705
+ const title = properties.title || "";
706
+ const txt = properties.txt || self.setPolicyText(hostname, "This Privacy Policy is effective [ Jan 5,], 2021 for all users.");
707
+
708
+ // 构建结果
709
+ const data = {
710
+ contact: `<a href="mailto:${contactEmail}" target="">${contactEmail}</a>`,
711
+ title: title ? title : '',
712
+ txt: title ? `<h2>${title}</h2>${txt}` : txt,
713
+ };
714
+
715
+ return data;
716
+ } catch (error) {
717
+ console.error("Error fetching policy and contact data:", error);
718
+ return {
719
+ contact: `<a href="mailto:gamebridgenoreply@gmail.com" target="">gamebridgenoreply@gmail.com</a>`,
720
+ title: '',
721
+ txt: self.setPolicyText(hostname, "This Privacy Policy is effective [ Jan 5,], 2021 for all users."),
722
+ };
723
+ }
724
+ };
730
725
  }
731
726
  module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');