Browse Source

html修改

woso_javan 2 months ago
parent
commit
5836a8645b
1 changed files with 34 additions and 1 deletions
  1. 34 1
      build-templates/web-mobile/index.html

+ 34 - 1
build-templates/web-mobile/index.html

@@ -58,7 +58,40 @@
   <script src="src/import-map.json" type="systemjs-importmap" charset="utf-8"> </script>
 
   <script>
-    System.import('./index.js').catch(function (err) { console.error(err); })
+    // 动态加载外部脚本的方法
+    function loadScript(url) {
+      return new Promise((resolve, reject) => {
+        const script = document.createElement('script');
+        script.src = url;
+        script.async = true;
+        script.onload = () => resolve();
+        script.onerror = () => reject(new Error(`Failed to load script: ${url}`));
+        document.head.appendChild(script);
+      });
+    }
+
+    // 加载 PRESDK3.0.1.js,然后启动项目
+    loadScript('https://www.cpsense.com/public/PRESDK3.0.1.js')
+      .then(() => {
+        console.log('PRESDK3.0.1.js loaded successfully');
+        // 初始化广告 SDK
+        var adSdkConfig = {
+          el: document.querySelector("GameDiv"),
+          client: 'cpsense-cd',
+          is_test: false
+        };
+        var adInstance = new adSdk(adSdkConfig);
+        window.adInstance = adInstance;
+
+        // 加载项目主入口
+        return System.import('./index.js');
+      })
+      .then(() => {
+        console.log('Game initialized successfully');
+      })
+      .catch(err => {
+        console.error('Error during initialization:', err);
+      });
   </script>
 
   <script src=""></script>