Fix web template
This commit is contained in:
parent
9e3d215ca8
commit
eb7aa690c7
|
|
@ -1,21 +1,26 @@
|
||||||
{{ '{{flutter_js}}' }}
|
{{ '{{flutter_js}}' }}
|
||||||
{{ '{{flutter_build_config}}' }}
|
{{ '{{flutter_build_config}}' }}
|
||||||
|
|
||||||
var config = {};
|
var flutterConfig = {
|
||||||
if (globalThis.webRenderer != "auto") {
|
multiViewEnabled: flet.multiView,
|
||||||
config.renderer = globalThis.webRenderer;
|
assetBase: flet.assetBase
|
||||||
|
};
|
||||||
|
if (flet.webRenderer != "auto") {
|
||||||
|
flutterConfig.renderer = flet.webRenderer;
|
||||||
}
|
}
|
||||||
if (globalThis.canvasKitBaseUrl) {
|
if (flet.noCdn) {
|
||||||
config.canvasKitBaseUrl = globalThis.canvasKitBaseUrl;
|
flutterConfig.canvasKitBaseUrl = flet.canvasKitBaseUrl;
|
||||||
|
flutterConfig.fontFallbackBaseUrl = flet.fontFallbackBaseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
_flutter.loader.load({
|
_flutter.loader.load({
|
||||||
config: config,
|
config: flutterConfig,
|
||||||
serviceWorkerSettings: {
|
serviceWorkerSettings: {
|
||||||
serviceWorkerVersion: {{ '{{flutter_service_worker_version}}' }},
|
serviceWorkerVersion: {{flutter_service_worker_version}},
|
||||||
},
|
},
|
||||||
onEntrypointLoaded: async function (engineInitializer) {
|
onEntrypointLoaded: async function (engineInitializer) {
|
||||||
const appRunner = await engineInitializer.initializeEngine({useColorEmoji: useColorEmoji});
|
const engine = await engineInitializer.initializeEngine(flutterConfig);
|
||||||
await appRunner.runApp();
|
flet.flutterApp = await engine.runApp();
|
||||||
|
flet.flutterAppResolve(flet.flutterApp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -11,33 +11,38 @@
|
||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
<meta name="apple-mobile-web-app-title" content="{{ cookiecutter.product_name }}">
|
<meta name="apple-mobile-web-app-title" content="{{ cookiecutter.product_name }}">
|
||||||
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
<link rel="apple-touch-icon" href="icons/apple-touch-icon-192.png">
|
||||||
|
|
||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
<link rel="icon" type="image/png" href="favicon.png" />
|
<link rel="icon" type="image/png" href="favicon.png" />
|
||||||
|
|
||||||
<!-- Flet specific -->
|
|
||||||
<meta name="flet-route-url-strategy" content="{{ cookiecutter.route_url_strategy }}">
|
|
||||||
<meta name="flet-web-pyodide" content="true">
|
|
||||||
|
|
||||||
<title>{{ cookiecutter.product_name }}</title>
|
<title>{{ cookiecutter.product_name }}</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var webRenderer = "{{ cookiecutter.web_renderer }}";
|
var flet = {
|
||||||
var useColorEmoji = "{{ cookiecutter.use_color_emoji }}".toLowerCase() == "true";
|
pyodide: true,
|
||||||
var appPackageUrl = "assets/app/app.zip";
|
multiView: false,
|
||||||
var pythonModuleName = "{{ cookiecutter.python_module_name }}";
|
noCdn: "{{ cookiecutter.no_cdn }}".toLowerCase() == "true",
|
||||||
var noCdn = "{{ cookiecutter.no_cdn }}".toLowerCase() == "true";
|
webSocketEndpoint: "/ws",
|
||||||
</script>
|
assetBase: "/",
|
||||||
|
routeUrlStrategy: "{{ cookiecutter.route_url_strategy }}",
|
||||||
<script>
|
canvasKitBaseUrl: "/canvaskit/",
|
||||||
if (noCdn) {
|
pyodideUrl: "/pyodide/pyodide.js",
|
||||||
var canvasKitBaseUrl = "/canvaskit/";
|
pythonModuleName: "{{ cookiecutter.python_module_name }}",
|
||||||
var pyodideUrl = "/pyodide/pyodide.js";
|
webRenderer: "{{ cookiecutter.web_renderer }}",
|
||||||
|
fontFallbackBaseUrl: "assets/fonts/", // for Noto Emoji, use Google CDN
|
||||||
|
appPackageUrl: "assets/app/app.zip"
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
|
|
||||||
|
flet.flutterAppLoaded = new Promise((resolve) => {
|
||||||
|
flet.flutterAppResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
flet.flutterAppLoaded.then((flutterApp) => {
|
||||||
|
console.log("Flutter app loaded");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<script src="python.js"></script>
|
<script src="python.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const defaultPyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.27.5/full/pyodide.js";
|
const defaultPyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.27.7/full/pyodide.js";
|
||||||
|
|
||||||
let _apps = {};
|
let _apps = {};
|
||||||
let _documentUrl = document.URL;
|
let _documentUrl = document.URL;
|
||||||
|
|
@ -30,12 +30,12 @@ globalThis.jsConnect = async function(appId, args, dartOnMessage) {
|
||||||
|
|
||||||
// initialize worker
|
// initialize worker
|
||||||
app.worker.postMessage({
|
app.worker.postMessage({
|
||||||
pyodideUrl: globalThis.pyodideUrl ?? defaultPyodideUrl,
|
pyodideUrl: flet.noCdn ? flet.pyodideUrl : defaultPyodideUrl,
|
||||||
args: args,
|
args: args,
|
||||||
documentUrl: _documentUrl,
|
documentUrl: _documentUrl,
|
||||||
appPackageUrl: globalThis.appPackageUrl,
|
appPackageUrl: flet.appPackageUrl,
|
||||||
micropipIncludePre: globalThis.micropipIncludePre,
|
micropipIncludePre: flet.micropipIncludePre,
|
||||||
pythonModuleName: globalThis.pythonModuleName
|
pythonModuleName: flet.pythonModuleName
|
||||||
});
|
});
|
||||||
|
|
||||||
await pythonInitialized;
|
await pythonInitialized;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue