fix:bbug
This commit is contained in:
7
build.js
7
build.js
@@ -2,7 +2,6 @@
|
|||||||
/**
|
/**
|
||||||
* 将静态资源复制到 dist/,便于直接部署到任意静态主机。
|
* 将静态资源复制到 dist/,便于直接部署到任意静态主机。
|
||||||
* 产出: dist/index.html, dist/config.json, dist/lib/, dist/image/
|
* 产出: dist/index.html, dist/config.json, dist/lib/, dist/image/
|
||||||
* 构建时注入 __CACHE_VERSION__ 为时间戳,用于防微信/浏览器强缓存,保证发版后页面可更新。
|
|
||||||
*/
|
*/
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
@@ -57,11 +56,7 @@ function main() {
|
|||||||
}
|
}
|
||||||
fs.mkdirSync(DIST, { recursive: true });
|
fs.mkdirSync(DIST, { recursive: true });
|
||||||
|
|
||||||
const cacheVersion = String(Date.now());
|
copyFile(path.join(ROOT, 'index.html'), path.join(DIST, 'index.html'));
|
||||||
let indexHtml = fs.readFileSync(path.join(ROOT, 'index.html'), 'utf8');
|
|
||||||
indexHtml = indexHtml.replace(/__CACHE_VERSION__/g, cacheVersion);
|
|
||||||
fs.writeFileSync(path.join(DIST, 'index.html'), indexHtml, 'utf8');
|
|
||||||
|
|
||||||
copyFile(path.join(ROOT, 'config.json'), path.join(DIST, 'config.json'));
|
copyFile(path.join(ROOT, 'config.json'), path.join(DIST, 'config.json'));
|
||||||
copyFile(path.join(ROOT, 'api.config.json'), path.join(DIST, 'api.config.json'));
|
copyFile(path.join(ROOT, 'api.config.json'), path.join(DIST, 'api.config.json'));
|
||||||
copyDir(path.join(ROOT, 'lib'), path.join(DIST, 'lib'));
|
copyDir(path.join(ROOT, 'lib'), path.join(DIST, 'lib'));
|
||||||
|
|||||||
10
index.html
10
index.html
@@ -4,12 +4,8 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
||||||
<meta http-equiv="Pragma" content="no-cache">
|
|
||||||
<meta http-equiv="Expires" content="0">
|
|
||||||
<title>全景查看</title>
|
<title>全景查看</title>
|
||||||
<script>window.__CACHE_VERSION__='__CACHE_VERSION__';</script>
|
<link rel="stylesheet" href="lib/pannellum.css">
|
||||||
<link rel="stylesheet" href="lib/pannellum.css?v=__CACHE_VERSION__">
|
|
||||||
<style>
|
<style>
|
||||||
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
|
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
|
||||||
.pano-root { flex: 1 1 0%; position: relative; width: 100%; height: 100%; }
|
.pano-root { flex: 1 1 0%; position: relative; width: 100%; height: 100%; }
|
||||||
@@ -211,7 +207,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="lib/pannellum.js?v=__CACHE_VERSION__"></script>
|
<script src="lib/pannellum.js"></script>
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
var API = '/api';
|
var API = '/api';
|
||||||
@@ -483,7 +479,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('api.config.json?v=' + (window.__CACHE_VERSION__ || ''))
|
fetch('api.config.json')
|
||||||
.then(function(r) {
|
.then(function(r) {
|
||||||
if (!r.ok) return Promise.resolve({ apiBase: '' });
|
if (!r.ok) return Promise.resolve({ apiBase: '' });
|
||||||
return typeof r.json === 'function' ? r.json().catch(function() { return { apiBase: '' }; }) : Promise.resolve({ apiBase: '' });
|
return typeof r.json === 'function' ? r.json().catch(function() { return { apiBase: '' }; }) : Promise.resolve({ apiBase: '' });
|
||||||
|
|||||||
Reference in New Issue
Block a user