mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Allow services to register additional js files for gui
This commit is contained in:
parent
5042d49935
commit
a1cfe7aef2
@ -10,6 +10,10 @@ class PuterHomepageService extends BaseService {
|
||||
fs: require('node:fs'),
|
||||
}
|
||||
|
||||
_construct () {
|
||||
this.service_scripts = [];
|
||||
}
|
||||
|
||||
async _init () {
|
||||
// Load manifest
|
||||
const config = this.global_config;
|
||||
@ -24,9 +28,12 @@ class PuterHomepageService extends BaseService {
|
||||
this.manifest = manifest_data[config.assets.gui_profile];
|
||||
}
|
||||
|
||||
register_script (url) {
|
||||
this.service_scripts.push(url);
|
||||
}
|
||||
|
||||
async send (res, meta) {
|
||||
const config = this.global_config;
|
||||
|
||||
return res.send(this.generate_puter_page_html({
|
||||
env: config.env,
|
||||
|
||||
@ -205,6 +212,11 @@ class PuterHomepageService extends BaseService {
|
||||
? manifest.js_paths.map(path => `<script type="module" src="${path}"></script>\n`)
|
||||
: []).join('')
|
||||
}
|
||||
${
|
||||
this.service_scripts
|
||||
.map(path => `<script type="module" src="${path}"></script>\n`)
|
||||
.join('')
|
||||
}
|
||||
<!-- Load the GUI script -->
|
||||
<script ${ !bundled ? ' type="module"' : ''} src="${(!bundled && manifest?.index) || '/dist/gui.js'}"></script>
|
||||
<!-- Initialize GUI when document is loaded -->
|
||||
|
Loading…
Reference in New Issue
Block a user