CVNSS commited on
Commit
12c1c4c
·
verified ·
1 Parent(s): f3276fc

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +107 -18
index.html CHANGED
@@ -1,26 +1,115 @@
1
  <!doctype html>
2
  <html lang="vi">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1" />
6
- <meta name="description" content="CAD2MAP - Công cụ chuyển đổi file CAD sang bản đồ địa lý" />
7
- <meta name="author" content="CMB-AI" />
8
 
9
- <base href="./" />
10
- <link rel="icon" type="image/svg+xml" href="./cad2map-favicon.svg" />
11
- <title>CAD2MAP - CMB AI Tools</title>
12
 
13
- <!-- CSS ROOT -->
14
- <link rel="stylesheet" href="./index-nLRMG7XC.css" />
15
- </head>
 
16
 
17
- <body>
18
- <div id="app"></div>
 
19
 
20
- <!-- Fix provinces chạy TRƯỚC bundle -->
21
- <script src="./hf-fix.js"></script>
 
 
 
 
 
 
 
22
 
23
- <!-- Bundle JS ROOT -->
24
- <script type="module" crossorigin src="./index-Cm1h4vpW.js"></script>
25
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  </html>
 
1
  <!doctype html>
2
  <html lang="vi">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <base href="./" />
 
7
 
8
+ <title>CAD2MAP</title>
9
+ <meta name="description" content="CAD2MAP - Công cụ chuyển đổi CAD/DXF/DWG sang bản đồ" />
 
10
 
11
+ <!-- Tất cả file nằm cùng cấp (ROOT) -->
12
+ <link rel="icon" type="image/svg+xml" href="./cad2map-favicon.svg" />
13
+ <link rel="stylesheet" href="./index-nLRMG7XC.css" />
14
+ </head>
15
 
16
+ <body>
17
+ <div id="app"></div>
18
+ <noscript>Ứng dụng cần bật JavaScript để chạy.</noscript>
19
 
20
+ <!--
21
+ HF/ROOT FIX (không thư mục con):
22
+ 1) Ép provinces về local ./provinces.json (hoặc fallback Firebase)
23
+ 2) Chặn mọi Worker URL trỏ /assets/... -> ./... (vì bạn không có folder assets)
24
+ -->
25
+ <script>
26
+ (function () {
27
+ const LOG = "[CAD2MAP-FIX]";
28
+ const nativeFetch = window.fetch ? window.fetch.bind(window) : null;
29
 
30
+ // ---------- 1) Fix provinces: không gọi server cloud (tránh CORS "No response") ----------
31
+ function isProvinces(url) {
32
+ try {
33
+ const u = new URL(url, location.href);
34
+ const p = u.pathname || "";
35
+ return (
36
+ p.endsWith("/provinces") ||
37
+ p.endsWith("/api/provinces") ||
38
+ p.includes("/provinces?")
39
+ );
40
+ } catch {
41
+ return String(url || "").includes("provinces");
42
+ }
43
+ }
44
+
45
+ async function fetchProvincesFallback() {
46
+ // Ưu tiên local file cùng cấp
47
+ try {
48
+ const r = await nativeFetch("./provinces.json", { cache: "no-store" });
49
+ if (r.ok) {
50
+ console.info(LOG, "provinces -> ./provinces.json");
51
+ return r;
52
+ }
53
+ } catch (_) {}
54
+
55
+ // Fallback cuối (nếu bạn có publish file này trên Firebase)
56
+ try {
57
+ const r2 = await nativeFetch("https://cad2map.web.app/provinces.json", { cache: "no-store" });
58
+ if (r2.ok) {
59
+ console.info(LOG, "provinces -> https://cad2map.web.app/provinces.json");
60
+ return r2;
61
+ }
62
+ } catch (_) {}
63
+
64
+ // Nếu cả 2 fail -> trả lỗi chuẩn
65
+ throw new Error("Không tải được provinces (local provinces.json và fallback đều lỗi).");
66
+ }
67
+
68
+ if (nativeFetch) {
69
+ window.fetch = function (input, init) {
70
+ const url = typeof input === "string" ? input : (input && input.url) || "";
71
+ if (isProvinces(url)) return fetchProvincesFallback();
72
+ return nativeFetch(input, init);
73
+ };
74
+ }
75
+
76
+ // ---------- 2) Fix Worker URL: /assets/... => ./... (vì không có thư mục con) ----------
77
+ const NativeWorker = window.Worker;
78
+
79
+ function rewriteToRoot(spec) {
80
+ let s = spec;
81
+
82
+ // URL object -> string href
83
+ if (spec && typeof spec === "object" && "href" in spec) s = spec.href;
84
+
85
+ s = String(s || "");
86
+
87
+ // Chỉ rewrite các path có /assets/ hoặc ./assets/ hoặc assets/
88
+ // Ví dụ:
89
+ // https://xxx.hf.space/assets/dxf-parser-worker.js -> ./dxf-parser-worker.js
90
+ // /assets/libredwg-parser-worker.js -> ./libredwg-parser-worker.js
91
+ // ./assets/mtext-renderer-worker.js -> ./mtext-renderer-worker.js
92
+ s = s.replace(/^https?:\/\/[^/]+\/assets\//i, "./");
93
+ s = s.replace(/^\/assets\//i, "./");
94
+ s = s.replace(/^\.\/*assets\//i, "./");
95
+ s = s.replace(/^assets\//i, "./");
96
+
97
+ return s;
98
+ }
99
+
100
+ if (NativeWorker) {
101
+ window.Worker = function (spec, options) {
102
+ const rewritten = rewriteToRoot(spec);
103
+ return new NativeWorker(rewritten, options);
104
+ };
105
+ window.Worker.prototype = NativeWorker.prototype;
106
+ }
107
+
108
+ console.info(LOG, "installed (root-only, no subfolders).");
109
+ })();
110
+ </script>
111
+
112
+ <!-- Bundle chạy sau khi đã patch fetch/Worker -->
113
+ <script type="module" crossorigin src="./index-Cm1h4vpW.js"></script>
114
+ </body>
115
  </html>