From afabd5eb389b84fde69e7df7d48eb99a6d3676f6 Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Tue, 26 Mar 2024 20:18:48 -0700 Subject: [PATCH] Make fetch cordova compatible Signed-off-by: Justin Georgi --- src/pages/detect.vue | 3 +-- src/pages/specs.vue | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/detect.vue b/src/pages/detect.vue index 0c98b8a..7c25af9 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -120,7 +120,6 @@ import submitMixin from './submit-mixin' import detectionMixin from './detection-mixin' import cameraMixin from './camera-mixin' -import App from 'framework7-vue/components/app' export default { mixins: [submitMixin, detectionMixin, cameraMixin], @@ -188,7 +187,7 @@ import App from 'framework7-vue/components/app' } this.modelLocation = `${modelRoot}/models/${this.detectorName}${this.otherSettings.mini ? '-mini' : ''}/model.json` this.miniLocation = `${modelRoot}/models/${this.detectorName}-mini/model.json` - fetch(`./models/${this.detectorName}/classes.json`) + fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/${this.detectorName}/classes.json`) .then((mod) => { return mod.json() }) .then((classes) => { this.classesList = classes diff --git a/src/pages/specs.vue b/src/pages/specs.vue index 272378b..2cb9d37 100644 --- a/src/pages/specs.vue +++ b/src/pages/specs.vue @@ -45,6 +45,7 @@ limbsDetails: { "version": "N/A" }, headneckDetails: { "version": "N/A" }, alvinnVersion: store().getVersion, + isCordova: !!window.cordova, otherSettings: {} } }, @@ -54,16 +55,16 @@ created () { var loadOtherSettings = localStorage.getItem('otherSettings') if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings) - fetch('./models/thorax/descript.json') + fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/thorax/descript.json`) .then((mod) => { return mod.json() }) .then((desc) => { this.thoraxDetails = desc }) - fetch('./models/thorax-mini/descript.json') + fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/thorax-mini/descript.json`) .then((mod) => { return mod.json() }) .then((desc) => { this.miniThoraxDetails = desc }) - fetch('./models/abdomen/descript.json') + fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen/descript.json`) .then((mod) => { return mod.json() }) .then((desc) => { this.abdomenDetails = desc }) - fetch('./models/abdomen-mini/descript.json') + fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen-mini/descript.json`) .then((mod) => { return mod.json() }) .then((desc) => { this.miniAbdomenDetails = desc }) },