Move assets to vite public folder (#152)

Closes: #151

Models and samples are now properly structured in the vite public folder so they are properly automatically incorporated into the the builds and work with both builds and dev tests.

Reviewed-on: #152
This commit is contained in:
2024-03-26 20:23:33 -07:00
parent 42faae18eb
commit 596c28a880
41 changed files with 21 additions and 23 deletions

View File

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

Before

Width:  |  Height:  |  Size: 714 KiB

After

Width:  |  Height:  |  Size: 714 KiB

View File

@@ -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],
@@ -168,7 +167,7 @@ import App from 'framework7-vue/components/app'
created () {
let loadOtherSettings = localStorage.getItem('otherSettings')
if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings)
let modelRoot = this.isCordova ? 'https://localhost' : (import.meta.env.PROD ? '.' : '..')
let modelRoot = this.isCordova ? 'https://localhost' : '.'
switch (this.f7route.params.region) {
case 'thorax':
this.activeRegion = 0
@@ -188,10 +187,12 @@ 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`
import(`../models/${this.detectorName}/classes.json`).then((mod) => {
this.classesList = mod.default
this.detectorLabels = this.classesList.map( l => { return {'name': l, 'detect': true} } )
})
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/${this.detectorName}/classes.json`)
.then((mod) => { return mod.json() })
.then((classes) => {
this.classesList = classes
this.detectorLabels = this.classesList.map( l => { return {'name': l, 'detect': true} } )
})
var loadServerSettings = localStorage.getItem('serverSettings')
if (loadServerSettings) this.serverSettings = JSON.parse(loadServerSettings)
},
@@ -385,7 +386,7 @@ import App from 'framework7-vue/components/app'
resolve(reader.result)
})
if (this.imageLoadMode == 'sample') {
fetch(`${this.isCordova ? 'https://localhost' : '..'}/samples/${this.detectorName}-${searchImage}.jpeg`).then( resp => {
fetch(`${this.isCordova ? 'https://localhost' : '.'}/samples/${this.detectorName}-${searchImage}.jpeg`).then( resp => {
return resp.blob()
}).then(respBlob => {
reader.readAsDataURL(respBlob)

View File

@@ -45,6 +45,7 @@
limbsDetails: { "version": "N/A" },
headneckDetails: { "version": "N/A" },
alvinnVersion: store().getVersion,
isCordova: !!window.cordova,
otherSettings: {}
}
},
@@ -54,22 +55,18 @@
created () {
var loadOtherSettings = localStorage.getItem('otherSettings')
if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings)
import('../models/thorax/descript.json')
.then((mod) => {
this.thoraxDetails = mod.default
})
import('../models/thorax-mini/descript.json')
.then((mod) => {
this.miniThoraxDetails = mod.default
})
import('../models/abdomen/descript.json')
.then((mod) => {
this.abdomenDetails = mod.default
})
import('../models/abdomen-mini/descript.json')
.then((mod) => {
this.miniAbdomenDetails = mod.default
})
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/thorax/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.thoraxDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/thorax-mini/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.miniThoraxDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.abdomenDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen-mini/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.miniAbdomenDetails = desc })
},
methods: {
}