-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Optimizing the startup command
- Loading branch information
Showing
5 changed files
with
19,531 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
// import GarfishInstance, { interfaces } from 'garfish'; | ||
// import './monitoring'; | ||
import GarfishInstance, { interfaces } from 'garfish'; | ||
import './monitoring'; | ||
|
||
// (window as any).__GARFISH_PARENT__ = true; | ||
(window as any).__GARFISH_PARENT__ = true; | ||
|
||
// // let asyncTime = function () { | ||
// // return new Promise((resolve) => { | ||
// // setTimeout(() => { | ||
// // resolve(true); | ||
// // }, 3000); | ||
// // }); | ||
// // }; | ||
// let defaultConfig: interfaces.Options = { | ||
// basename: '/garfish_master', | ||
// domGetter: () => { | ||
// // await asyncTime(); | ||
// return document.querySelector('#submoduleByRouter'); | ||
// }, | ||
// apps: [ | ||
// { | ||
// name: 'react', | ||
// activeWhen: '/react', | ||
// // cache: true, | ||
// entry: 'http://localhost:2444', | ||
// }, | ||
// { | ||
// name: 'vue', | ||
// activeWhen: '/vue', | ||
// // cache: true, | ||
// entry: 'http://localhost:2666', | ||
// }, | ||
// { | ||
// name: 'vue2', | ||
// activeWhen: '/vue2', | ||
// // cache: true, | ||
// entry: 'http://localhost:2777', | ||
// }, | ||
// ], | ||
// autoRefreshApp: true, | ||
// disablePreloadApp: true, | ||
// protectVariable: ['MonitoringInstance', 'Garfish'], | ||
// // sandbox: { | ||
// // snapshot: false | ||
// // }, | ||
// let asyncTime = function () { | ||
// return new Promise((resolve) => { | ||
// setTimeout(() => { | ||
// resolve(true); | ||
// }, 3000); | ||
// }); | ||
// }; | ||
let defaultConfig: interfaces.Options = { | ||
basename: '/garfish_master', | ||
domGetter: () => { | ||
// await asyncTime(); | ||
return document.querySelector('#submoduleByRouter'); | ||
}, | ||
apps: [ | ||
{ | ||
name: 'react', | ||
activeWhen: '/react', | ||
// cache: true, | ||
entry: 'http://localhost:2444', | ||
}, | ||
{ | ||
name: 'vue', | ||
activeWhen: '/vue', | ||
// cache: true, | ||
entry: 'http://localhost:2666', | ||
}, | ||
{ | ||
name: 'vue2', | ||
activeWhen: '/vue2', | ||
// cache: true, | ||
entry: 'http://localhost:2777', | ||
}, | ||
], | ||
autoRefreshApp: true, | ||
disablePreloadApp: true, | ||
protectVariable: ['MonitoringInstance', 'Garfish'], | ||
// sandbox: { | ||
// snapshot: false | ||
// }, | ||
}; | ||
|
||
// // The test environment into | ||
// if (typeof Cypress !== 'undefined') { | ||
// defaultConfig = { | ||
// ...defaultConfig, | ||
// ...Cypress.env().garfishRunConfig, | ||
// }; | ||
// } | ||
// The test environment into | ||
if (typeof Cypress !== 'undefined') { | ||
defaultConfig = { | ||
...defaultConfig, | ||
...Cypress.env().garfishRunConfig, | ||
}; | ||
} | ||
|
||
// export const Config = defaultConfig; | ||
export const Config = defaultConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
// /// <reference types="cypress" /> | ||
// import GarfishInstance from 'garfish'; | ||
// import { Config } from './config'; | ||
/// <reference types="cypress" /> | ||
import GarfishInstance from 'garfish'; | ||
import { Config } from './config'; | ||
|
||
// GarfishInstance.run(Config); | ||
GarfishInstance.run(Config); | ||
|
||
// const useRouterMode = true; | ||
const useRouterMode = true; | ||
|
||
// document.getElementById('vueBtn').onclick = async () => { | ||
// if (useRouterMode) { | ||
// history.pushState({}, 'vue', '/garfish_master/vue'); // use router to load app | ||
// } else { | ||
// let prevApp = await GarfishInstance.loadApp('vue', { | ||
// entry: 'http://localhost:9090', | ||
// domGetter: '#submoduleByCunstom', | ||
// }); | ||
// console.log(prevApp); | ||
// await prevApp.mount(); | ||
// } | ||
// }; | ||
document.getElementById('vueBtn').onclick = async () => { | ||
if (useRouterMode) { | ||
history.pushState({}, 'vue', '/garfish_master/vue'); // use router to load app | ||
} else { | ||
let prevApp = await GarfishInstance.loadApp('vue', { | ||
entry: 'http://localhost:9090', | ||
domGetter: '#submoduleByCunstom', | ||
}); | ||
console.log(prevApp); | ||
await prevApp.mount(); | ||
} | ||
}; | ||
|
||
// document.getElementById('reactBtn').onclick = async () => { | ||
// if (useRouterMode) { | ||
// history.pushState({}, 'react', '/garfish_master/react'); | ||
// } else { | ||
// let prevApp = await GarfishInstance.loadApp('react', { | ||
// entry: 'http://localhost:3000', | ||
// domGetter: '#submoduleByCunstom', | ||
// }); | ||
// console.log(prevApp); | ||
// await prevApp.mount(); | ||
// } | ||
// }; | ||
document.getElementById('reactBtn').onclick = async () => { | ||
if (useRouterMode) { | ||
history.pushState({}, 'react', '/garfish_master/react'); | ||
} else { | ||
let prevApp = await GarfishInstance.loadApp('react', { | ||
entry: 'http://localhost:3000', | ||
domGetter: '#submoduleByCunstom', | ||
}); | ||
console.log(prevApp); | ||
await prevApp.mount(); | ||
} | ||
}; | ||
|
||
console.log(111); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
// import ConfigCommon from '../../config.json'; | ||
|
||
// declare global { | ||
// interface Window { | ||
// fetchM: Function; | ||
// unhandledrejectionError: Function; | ||
// normalError: Function; | ||
// DynamicResource: Function; | ||
// resourceError: Function; | ||
// } | ||
// } | ||
|
||
// window.fetchM = function fetchM() { | ||
// const xhr = new XMLHttpRequest(); | ||
// xhr.open('get', `http://localhost:${ConfigCommon.mainPort}/mainApp`, true); | ||
// xhr.onreadystatechange = function () { | ||
// if (xhr.readyState !== 4) { | ||
// return; | ||
// } | ||
// if (xhr.status >= 200 && xhr.status < 300) { | ||
// // console.log('mainApp xhr'); | ||
// } | ||
// }; | ||
// xhr.send(null); | ||
|
||
// fetch( | ||
// `http://localhost:${ConfigCommon.mainPort}/fetch/mainApp`, | ||
// ).then((res) => {}); | ||
// }; | ||
|
||
// window.unhandledrejectionError = function unhandledrejectionError() { | ||
// setTimeout(() => { | ||
// throw Error('mainApp: unhandledrejection error'); | ||
// }, 500); | ||
// }; | ||
|
||
// window.normalError = function normalError() { | ||
// throw Error('mainApp: normal error'); | ||
// }; | ||
|
||
// window.DynamicResource = function DynamicResource() { | ||
// const sc = document.createElement('script'); | ||
// sc.src = `http://localhost:${ConfigCommon.mainPort}/monitoring/dynamicScript.js`; | ||
// document.body.appendChild(sc); | ||
|
||
// const link = document.createElement('link'); | ||
// link.href = `http://localhost:${ConfigCommon.mainPort}/monitoring/dynamicLink.css`; | ||
// document.body.appendChild(link); | ||
// }; | ||
|
||
// window.resourceError = function resourceError() { | ||
// // resource error | ||
// const sc = document.createElement('script'); | ||
// sc.src = `http://localhost:1111/monitoring/xxxxx.js`; | ||
// document.body.appendChild(sc); | ||
// }; | ||
import ConfigCommon from '../../config.json'; | ||
|
||
declare global { | ||
interface Window { | ||
fetchM: Function; | ||
unhandledrejectionError: Function; | ||
normalError: Function; | ||
DynamicResource: Function; | ||
resourceError: Function; | ||
} | ||
} | ||
|
||
window.fetchM = function fetchM() { | ||
const xhr = new XMLHttpRequest(); | ||
xhr.open('get', `http://localhost:${ConfigCommon.mainPort}/mainApp`, true); | ||
xhr.onreadystatechange = function () { | ||
if (xhr.readyState !== 4) { | ||
return; | ||
} | ||
if (xhr.status >= 200 && xhr.status < 300) { | ||
// console.log('mainApp xhr'); | ||
} | ||
}; | ||
xhr.send(null); | ||
|
||
fetch( | ||
`http://localhost:${ConfigCommon.mainPort}/fetch/mainApp`, | ||
).then((res) => {}); | ||
}; | ||
|
||
window.unhandledrejectionError = function unhandledrejectionError() { | ||
setTimeout(() => { | ||
throw Error('mainApp: unhandledrejection error'); | ||
}, 500); | ||
}; | ||
|
||
window.normalError = function normalError() { | ||
throw Error('mainApp: normal error'); | ||
}; | ||
|
||
window.DynamicResource = function DynamicResource() { | ||
const sc = document.createElement('script'); | ||
sc.src = `http://localhost:${ConfigCommon.mainPort}/monitoring/dynamicScript.js`; | ||
document.body.appendChild(sc); | ||
|
||
const link = document.createElement('link'); | ||
link.href = `http://localhost:${ConfigCommon.mainPort}/monitoring/dynamicLink.css`; | ||
document.body.appendChild(link); | ||
}; | ||
|
||
window.resourceError = function resourceError() { | ||
// resource error | ||
const sc = document.createElement('script'); | ||
sc.src = `http://localhost:1111/monitoring/xxxxx.js`; | ||
document.body.appendChild(sc); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.