Skip to content

Commit

Permalink
feat: add judge about fetchUrl is required in DeployReload
Browse files Browse the repository at this point in the history
  • Loading branch information
flingyp committed Jan 16, 2024
1 parent eeb61b9 commit a8a132b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/RouterContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const isOpenDialog = ref(true);
const { isOpenDeployReload } = storeToRefs(useVAdmireConfigStore());
const deployReload = new DeployReload({
fetchUrl: 'http://localhost:4173/config.json',
// TIP: Config interface url to get 'fetchKey' value
fetchUrl: '',
fetchKey: 'buildTime',
isListening: false,
checkTimeout: 60 * 5,
Expand Down
6 changes: 5 additions & 1 deletion src/utils/reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class DeployReload {

constructor(options: DeployReloadOptions) {
this.fetchUrl = options.fetchUrl;
if (!this.fetchUrl) {
console.error('fetchUrl is required in DeployReload');
}

this.fetchKey = options.fetchKey;
this.isListening = options.isListening || true;
this.checkTimeout = options.checkTimeout || 5;
Expand Down Expand Up @@ -65,7 +69,7 @@ export class DeployReload {
}

private async checkBuildTime() {
if (this.isListening) {
if (this.isListening && this.fetchUrl) {
const currentBuildTime = await this.getBuildTimeValue();
if (currentBuildTime > this.stashBuildTime) {
this.reloadCallback();
Expand Down

0 comments on commit a8a132b

Please sign in to comment.