-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
107 lines (96 loc) · 3.81 KB
/
index.html
File metadata and controls
107 lines (96 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Best-effort: avoid browsers caching this HTML (so users get latest deploy without Ctrl+R) -->
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, max-age=0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<!-- GitHub Pages cache-buster: if a newer deploy exists, reload this HTML with ?v=... -->
<script>
(() => {
const LOCAL_VERSION = '%APP_VERSION%'
const IS_PROD_BUILD = '%IS_PROD_BUILD%' === 'true'
const parseSemver = (v) => {
const s = String(v || '').trim().replace(/^v/i, '')
const core = s.split('-')[0]
const [a, b, c] = core.split('.')
return [Number(a) || 0, Number(b) || 0, Number(c) || 0]
}
const isNewer = (remote, local) => {
const r = parseSemver(remote)
const l = parseSemver(local)
for (let i = 0; i < 3; i++) {
if (r[i] > l[i]) return true
if (r[i] < l[i]) return false
}
return false
}
const removeCacheBustParamIfCurrent = () => {
try {
const params = new URLSearchParams(location.search)
const v = params.get('v') || ''
if (v && v === LOCAL_VERSION) {
params.delete('v')
const next = new URL(location.href)
next.search = params.toString() ? `?${params.toString()}` : ''
history.replaceState(null, '', next.toString())
}
} catch {}
}
// Exposed so App.vue can re-check on "Refresh data" without duplicating logic.
window.__glvCheckForUpdate = async () => {
try {
const host = String(location.hostname || '').toLowerCase()
const isGitHubPages = host.endsWith('github.io')
if (!IS_PROD_BUILD || !isGitHubPages) return false
removeCacheBustParamIfCurrent()
const u = new URL('current_version.json', location.href)
u.search = ''
const res = await fetch(u.toString(), { cache: 'no-store' })
if (!res.ok) return false
const remote = await res.json()
const remoteVersion = remote && remote.version ? String(remote.version) : ''
if (!remoteVersion || !LOCAL_VERSION) return false
const currentV = new URLSearchParams(location.search).get('v') || ''
if (currentV === remoteVersion) return false
if (!isNewer(remoteVersion, LOCAL_VERSION)) return false
const next = new URL(location.href)
next.searchParams.set('v', remoteVersion)
location.replace(next.toString())
return true
} catch {
return false
}
}
// Initial check on page load.
try { window.__glvCheckForUpdate() } catch {}
})()
</script>
<!-- Electron renderer security: avoid "no CSP / unsafe-eval" warnings -->
<meta
http-equiv="Content-Security-Policy"
content="
default-src 'self';
base-uri 'self';
form-action 'self';
object-src 'none';
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';
img-src 'self' data: blob:;
font-src 'self' data:;
connect-src 'self' http: https: ws: wss:;
"
/>
<link rel="icon" href="./favicon.ico" />
<title>GitLab Viz</title>
<style>
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>