mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-29 15:43:58 +00:00
Support electron env and build for linux
This commit is contained in:
parent
6dfa755c50
commit
da01ac99fe
@ -28,7 +28,9 @@
|
||||
"environmentSource": "environments/environment.ts",
|
||||
"environments": {
|
||||
"dev": "environments/environment.ts",
|
||||
"prod": "environments/environment.prod.ts"
|
||||
"prod": "environments/environment.prod.ts",
|
||||
"electronProd": "environments/environment.electron.prod.ts",
|
||||
"electronDev": "environments/environment.electron.ts"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -10,8 +10,8 @@
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e",
|
||||
"electrondev": "concurrently -k \"ng serve\" \"electron .\"",
|
||||
"distlinux": "ng build --prod && electron-builder --linux"
|
||||
"electrondev": "concurrently -k \"ng serve -e electronDev\" \"electron .\"",
|
||||
"distlinux": "ng build -e electronProd && electron-builder --linux"
|
||||
},
|
||||
"build": {
|
||||
"directories": {
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { environment } from "../environments/environment";
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
@ -6,6 +8,7 @@ import { ServersComponent } from "./servers/servers.component";
|
||||
import { ProjectsComponent } from "./projects/projects.component";
|
||||
import { DefaultLayoutComponent } from "./default-layout/default-layout.component";
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: DefaultLayoutComponent,
|
||||
children: [
|
||||
@ -17,8 +20,17 @@ const routes: Routes = [
|
||||
{ path: 'server/:server_id/project/:project_id', component: ProjectMapComponent },
|
||||
];
|
||||
|
||||
let routerModule;
|
||||
if (environment.electron) {
|
||||
// angular in electron has problem with base-href and links separated by slashes, because of that
|
||||
// we use simply hashes
|
||||
routerModule = RouterModule.forRoot(routes, {useHash: true});
|
||||
} else {
|
||||
routerModule = RouterModule.forRoot(routes);
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [ RouterModule.forRoot(routes, {useHash: true}) ],
|
||||
imports: [ routerModule ],
|
||||
exports: [ RouterModule ]
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
|
4
src/environments/environment.electron.prod.ts
Normal file
4
src/environments/environment.electron.prod.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
electron: true
|
||||
};
|
4
src/environments/environment.electron.ts
Normal file
4
src/environments/environment.electron.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
electron: true
|
||||
};
|
@ -4,5 +4,6 @@
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
production: false,
|
||||
electron: false
|
||||
};
|
||||
|
@ -3,9 +3,17 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>GNS3 Web UI Demo</title>
|
||||
<!-- <base href="./"> //-->
|
||||
|
||||
<script>document.write('<base href="' + document.location + '" />');</script>
|
||||
<script>
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
// in case we're running in electron because we need it for resources
|
||||
if (userAgent.indexOf(' electron/') > -1) {
|
||||
document.write('<base href="' + document.location + '" />');
|
||||
}
|
||||
// in case base href is not set, when not defined during the build time (for instance github.io pages)
|
||||
else if (document.getElementsByTagName('base').length == 0) {
|
||||
document.write('<base href="/" />');
|
||||
}
|
||||
</script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="assets/favicon.ico">
|
||||
|
Loading…
x
Reference in New Issue
Block a user