mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-11 11:41:35 +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",
|
"environmentSource": "environments/environment.ts",
|
||||||
"environments": {
|
"environments": {
|
||||||
"dev": "environments/environment.ts",
|
"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",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e",
|
||||||
"electrondev": "concurrently -k \"ng serve\" \"electron .\"",
|
"electrondev": "concurrently -k \"ng serve -e electronDev\" \"electron .\"",
|
||||||
"distlinux": "ng build --prod && electron-builder --linux"
|
"distlinux": "ng build -e electronProd && electron-builder --linux"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"directories": {
|
"directories": {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { environment } from "../environments/environment";
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
@ -6,6 +8,7 @@ import { ServersComponent } from "./servers/servers.component";
|
|||||||
import { ProjectsComponent } from "./projects/projects.component";
|
import { ProjectsComponent } from "./projects/projects.component";
|
||||||
import { DefaultLayoutComponent } from "./default-layout/default-layout.component";
|
import { DefaultLayoutComponent } from "./default-layout/default-layout.component";
|
||||||
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: DefaultLayoutComponent,
|
{ path: '', component: DefaultLayoutComponent,
|
||||||
children: [
|
children: [
|
||||||
@ -17,8 +20,17 @@ const routes: Routes = [
|
|||||||
{ path: 'server/:server_id/project/:project_id', component: ProjectMapComponent },
|
{ 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({
|
@NgModule({
|
||||||
imports: [ RouterModule.forRoot(routes, {useHash: true}) ],
|
imports: [ routerModule ],
|
||||||
exports: [ RouterModule ]
|
exports: [ RouterModule ]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule {}
|
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`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false
|
production: false,
|
||||||
|
electron: false
|
||||||
};
|
};
|
||||||
|
@ -3,9 +3,17 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>GNS3 Web UI Demo</title>
|
<title>GNS3 Web UI Demo</title>
|
||||||
<!-- <base href="./"> //-->
|
<script>
|
||||||
|
var userAgent = navigator.userAgent.toLowerCase();
|
||||||
<script>document.write('<base href="' + document.location + '" />');</script>
|
// 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">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="assets/favicon.ico">
|
<link rel="icon" type="image/x-icon" href="assets/favicon.ico">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user