mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 23:28:39 +08:00
Only load from source in dev environment
This commit is contained in:
parent
5d81ff4cbe
commit
a973f66092
@ -296,6 +296,8 @@ router.all('*', async function(req, res, next) {
|
|||||||
const APP_ORIGIN = config.origin;
|
const APP_ORIGIN = config.origin;
|
||||||
const API_ORIGIN = config.api_base_url;
|
const API_ORIGIN = config.api_base_url;
|
||||||
return res.send(generate_puter_page_html({
|
return res.send(generate_puter_page_html({
|
||||||
|
env: config.env,
|
||||||
|
|
||||||
app_origin: APP_ORIGIN,
|
app_origin: APP_ORIGIN,
|
||||||
api_origin: API_ORIGIN,
|
api_origin: API_ORIGIN,
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ const path_ = require('path');
|
|||||||
const fs_ = require('fs');
|
const fs_ = require('fs');
|
||||||
|
|
||||||
const generate_puter_page_html = ({
|
const generate_puter_page_html = ({
|
||||||
|
env,
|
||||||
|
|
||||||
manifest,
|
manifest,
|
||||||
gui_path,
|
gui_path,
|
||||||
|
|
||||||
@ -98,7 +100,7 @@ const generate_puter_page_html = ({
|
|||||||
|
|
||||||
<!-- Files from JSON (may be empty) -->
|
<!-- Files from JSON (may be empty) -->
|
||||||
${
|
${
|
||||||
(manifest?.css_paths
|
((env == 'dev' && manifest?.css_paths)
|
||||||
? manifest.css_paths.map(path => `<link rel="stylesheet" href="${path}">\n`)
|
? manifest.css_paths.map(path => `<link rel="stylesheet" href="${path}">\n`)
|
||||||
: []).join('')
|
: []).join('')
|
||||||
}
|
}
|
||||||
@ -108,7 +110,7 @@ const generate_puter_page_html = ({
|
|||||||
<body>
|
<body>
|
||||||
<script>window.puter_gui_enabled = true;</script>
|
<script>window.puter_gui_enabled = true;</script>
|
||||||
${
|
${
|
||||||
(manifest?.lib_paths
|
((env == 'dev' && manifest?.lib_paths)
|
||||||
? manifest.lib_paths.map(path => `<script type="text/javascript" src="${path}"></script>\n`)
|
? manifest.lib_paths.map(path => `<script type="text/javascript" src="${path}"></script>\n`)
|
||||||
: []).join('')
|
: []).join('')
|
||||||
}
|
}
|
||||||
@ -117,7 +119,7 @@ const generate_puter_page_html = ({
|
|||||||
window.icons = {};
|
window.icons = {};
|
||||||
|
|
||||||
${(() => {
|
${(() => {
|
||||||
if ( ! manifest ) return '';
|
if ( !(env == 'dev' && manifest) ) return '';
|
||||||
const html = [];
|
const html = [];
|
||||||
fs_.readdirSync(path_.join(gui_path, 'src/icons')).forEach(file => {
|
fs_.readdirSync(path_.join(gui_path, 'src/icons')).forEach(file => {
|
||||||
// skip dotfiles
|
// skip dotfiles
|
||||||
@ -138,12 +140,12 @@ const generate_puter_page_html = ({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
${
|
${
|
||||||
(manifest?.js_paths
|
((env == 'dev' && manifest?.js_paths)
|
||||||
? manifest.js_paths.map(path => `<script type="module" src="${path}"></script>\n`)
|
? manifest.js_paths.map(path => `<script type="module" src="${path}"></script>\n`)
|
||||||
: []).join('')
|
: []).join('')
|
||||||
}
|
}
|
||||||
<!-- Load the GUI script -->
|
<!-- Load the GUI script -->
|
||||||
<script ${ manifest.index ? ' type="module"' : ''} src="${manifest?.index ?? '/dist/gui.js'}"></script>
|
<script ${ env == 'dev' ? ' type="module"' : ''} src="${(env == 'dev' && manifest?.index) || '/dist/gui.js'}"></script>
|
||||||
<!-- Initialize GUI when document is loaded -->
|
<!-- Initialize GUI when document is loaded -->
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user