mirror of
https://github.com/krille-chan/fluffychat
synced 2024-10-05 17:12:46 +00:00
refactor: Update html build files
This commit is contained in:
parent
e20f7f7576
commit
82e38ad38f
2 changed files with 32 additions and 72 deletions
6
.github/workflows/main_deploy.yaml
vendored
6
.github/workflows/main_deploy.yaml
vendored
|
@ -22,11 +22,9 @@ jobs:
|
||||||
run: sudo apt-get update && sudo apt-get install nodejs -y
|
run: sudo apt-get update && sudo apt-get install nodejs -y
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- name: Prepare web
|
- name: Prepare web
|
||||||
run: |
|
run: ./scripts/prepare-web.sh
|
||||||
./scripts/prepare-web.sh
|
|
||||||
sed -i 's/href="\/"/href="\/web\/"/' web/index.html
|
|
||||||
- name: Build Release Web
|
- name: Build Release Web
|
||||||
run: flutter build web --release --verbose --source-maps
|
run: flutter build web --release --verbose --source-maps --base-href "/web/"
|
||||||
- name: Build Website
|
- name: Build Website
|
||||||
run: |
|
run: |
|
||||||
cd docs && npx tailwindcss -o ./tailwind.css --minify && cd ..
|
cd docs && npx tailwindcss -o ./tailwind.css --minify && cd ..
|
||||||
|
|
|
@ -11,8 +11,11 @@
|
||||||
|
|
||||||
For more details:
|
For more details:
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
||||||
|
|
||||||
|
This is a placeholder for base href that will be replaced by the value of
|
||||||
|
the `--base-href` argument provided to `flutter build`.
|
||||||
-->
|
-->
|
||||||
<base href="/">
|
<base href="$FLUTTER_BASE_HREF">
|
||||||
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||||
|
@ -30,80 +33,39 @@
|
||||||
<title>FluffyChat</title>
|
<title>FluffyChat</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
<link rel="stylesheet" type="text/css" href="splash/style.css">
|
<link rel="stylesheet" type="text/css" href="splash/style.css">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// The value below is injected by flutter build, do not touch.
|
||||||
|
const serviceWorkerVersion = null;
|
||||||
|
</script>
|
||||||
|
<!-- This script adds the flutter initialization JS code -->
|
||||||
|
<script src="flutter.js" defer></script>
|
||||||
|
<script src="assets/assets/js/package/olm.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body style="position: fixed; inset: 0px; overflow: hidden; padding: 0px; margin: 0px; user-select: none; touch-action: none; font: 14px sans-serif; color: red;">
|
<body>
|
||||||
<!-- This script installs service_worker.js to provide PWA functionality to
|
|
||||||
application. For more information, see:
|
|
||||||
https://developers.google.com/web/fundamentals/primers/service-workers -->
|
|
||||||
<script>
|
<script>
|
||||||
var serviceWorkerVersion = null;
|
window.addEventListener('load', function (ev) {
|
||||||
var scriptLoaded = false;
|
// Download main.dart.js
|
||||||
function loadMainDartJs() {
|
_flutter.loader.loadEntrypoint({
|
||||||
if (scriptLoaded) {
|
serviceWorker: {
|
||||||
return;
|
serviceWorkerVersion: serviceWorkerVersion,
|
||||||
}
|
},
|
||||||
scriptLoaded = true;
|
onEntrypointLoaded: function (engineInitializer) {
|
||||||
var scriptTag = document.createElement('script');
|
engineInitializer.initializeEngine().then(function (appRunner) {
|
||||||
scriptTag.src = 'main.dart.js';
|
appRunner.runApp();
|
||||||
scriptTag.type = 'application/javascript';
|
|
||||||
document.body.append(scriptTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
|
||||||
// Service workers are supported. Use them.
|
|
||||||
window.addEventListener('load', function () {
|
|
||||||
// Wait for registration to finish before dropping the <script> tag.
|
|
||||||
// Otherwise, the browser will load the script multiple times,
|
|
||||||
// potentially different versions.
|
|
||||||
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
|
|
||||||
navigator.serviceWorker.register(serviceWorkerUrl)
|
|
||||||
.then((reg) => {
|
|
||||||
function waitForActivation(serviceWorker) {
|
|
||||||
serviceWorker.addEventListener('statechange', () => {
|
|
||||||
if (serviceWorker.state == 'activated') {
|
|
||||||
console.log('Installed new service worker.');
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!reg.active && (reg.installing || reg.waiting)) {
|
|
||||||
// No active web worker and we have installed or are installing
|
|
||||||
// one for the first time. Simply wait for it to activate.
|
|
||||||
waitForActivation(reg.installing ?? reg.waiting);
|
|
||||||
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
|
|
||||||
// When the app updates the serviceWorkerVersion changes, so we
|
|
||||||
// need to ask the service worker to update.
|
|
||||||
console.log('New service worker available.');
|
|
||||||
reg.update();
|
|
||||||
waitForActivation(reg.installing);
|
|
||||||
} else {
|
|
||||||
// Existing service worker is still good.
|
|
||||||
console.log('Loading app from service worker.');
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// If service worker doesn't succeed in a reasonable amount of time,
|
|
||||||
// fallback to plaint <script> tag.
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!scriptLoaded) {
|
|
||||||
console.warn(
|
|
||||||
'Failed to load app from service worker. Falling back to plain <script> tag.',
|
|
||||||
);
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
}, 4000);
|
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
// Service workers not supported. Just drop the <script> tag.
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script src="assets/assets/js/package/olm.js"></script>
|
|
||||||
<picture id="splash">
|
<picture id="splash">
|
||||||
<source srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x" media="(prefers-color-scheme: light) or (prefers-color-scheme: no-preference)">
|
<source
|
||||||
<source srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x" media="(prefers-color-scheme: dark)">
|
srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x"
|
||||||
|
media="(prefers-color-scheme: light) or (prefers-color-scheme: no-preference)">
|
||||||
|
<source
|
||||||
|
srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x"
|
||||||
|
media="(prefers-color-scheme: dark)">
|
||||||
<img class="center" src="splash/img/light-1x.png" />
|
<img class="center" src="splash/img/light-1x.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue