|
1 |
| -import { imagedb, dataURLtoBlob } from '@/lib/imagedb' |
2 |
| -import { saveAs } from 'file-saver' |
3 |
| -import TensorFlow from '@/lib/tensorflow' |
4 |
| -import JSZip from 'jszip' |
5 |
| -import lodash from 'lodash' |
6 |
| -import { defineStore } from 'pinia' |
7 |
| -import type { _GettersTree } from 'pinia' |
8 |
| -import { log } from '@/lib/logging' |
9 |
| -import PQueue from 'p-queue' |
10 | 1 | import { DrawCanvas } from '@/lib/draw'
|
11 |
| -import { resizeImage } from '@/lib/util' |
| 2 | +import { dataURLtoBlob, imagedb } from '@/lib/imagedb' |
| 3 | +import { log } from '@/lib/logging' |
12 | 4 | import {
|
13 |
| - Display, |
14 |
| - Progress, |
| 5 | + BaseImage, |
15 | 6 | Capacity,
|
16 |
| - Summary, |
| 7 | + Display, |
17 | 8 | PAGE_SIZE,
|
18 |
| - StorageCapacity, |
19 |
| - BaseImage, |
| 9 | + Progress, |
20 | 10 | SaveData,
|
| 11 | + StorageCapacity, |
| 12 | + Summary, |
21 | 13 | TrashObject,
|
22 | 14 | } from '@/lib/models'
|
| 15 | +import TensorFlow from '@/lib/tensorflow' |
| 16 | +import { getStaticFiles, resizeImage } from '@/lib/util' |
| 17 | +import { saveAs } from 'file-saver' |
| 18 | +import JSZip from 'jszip' |
| 19 | +import lodash from 'lodash' |
| 20 | +import PQueue from 'p-queue' |
| 21 | +import type { _GettersTree } from 'pinia' |
| 22 | +import { defineStore } from 'pinia' |
23 | 23 |
|
24 | 24 | let initialized = false
|
25 | 25 |
|
@@ -133,30 +133,21 @@ export const useImageStore = defineStore<
|
133 | 133 | this.capacity = await StorageCapacity.getCapacity()
|
134 | 134 | },
|
135 | 135 | async do_sampleupload() {
|
136 |
| - const sample_files = async () => { |
137 |
| - const files = [ |
138 |
| - 'sample01.jpg', |
139 |
| - 'sample02.jpg', |
140 |
| - 'sample03.jpg', |
141 |
| - 'sample05.jpg', |
142 |
| - 'sample06.jpg', |
143 |
| - 'sample07.jpg', |
144 |
| - 'sample08.jpg', |
145 |
| - ] |
146 |
| - const retval = [] |
147 |
| - for (let i = 0; i < files.length; i++) { |
148 |
| - const file = files[i] |
149 |
| - const url = `/samples/${file}` |
150 |
| - const blob = await fetch(url).then((r) => r.blob()) |
151 |
| - retval.push( |
152 |
| - new File([blob], file, { |
153 |
| - type: blob.type, |
154 |
| - }), |
155 |
| - ) |
156 |
| - } |
157 |
| - return retval |
158 |
| - } |
159 |
| - const files = await sample_files() |
| 136 | + const blobs = await getStaticFiles([ |
| 137 | + '/samples/sample01.jpg', |
| 138 | + '/samples/sample02.jpg', |
| 139 | + '/samples/sample03.jpg', |
| 140 | + '/samples/sample05.jpg', |
| 141 | + '/samples/sample06.jpg', |
| 142 | + '/samples/sample07.jpg', |
| 143 | + '/samples/sample08.jpg', |
| 144 | + ]) |
| 145 | + const files = blobs.map( |
| 146 | + (f) => |
| 147 | + new File([f.blob], f.filePath.substring(9), { |
| 148 | + type: f.blob.type, |
| 149 | + }), |
| 150 | + ) |
160 | 151 | await this.doupload(files)
|
161 | 152 | },
|
162 | 153 |
|
@@ -325,7 +316,21 @@ export const useImageStore = defineStore<
|
325 | 316 | const zp = this.zip
|
326 | 317 |
|
327 | 318 | return new Promise(async (resolve) => {
|
328 |
| - zp.total = await imagedb.savedata.count() |
| 319 | + const schemaFilePaths = [ |
| 320 | + '/schema/image_schema.json', |
| 321 | + '/schema/image_schema.md', |
| 322 | + '/schema/summary_schema.json', |
| 323 | + '/schema/summary_schema.md', |
| 324 | + ] |
| 325 | + |
| 326 | + zp.total = |
| 327 | + (await imagedb.savedata.count()) + schemaFilePaths.length |
| 328 | + |
| 329 | + const schemaFiles = await getStaticFiles(schemaFilePaths) |
| 330 | + schemaFiles.map((r) => |
| 331 | + folder!.file(r.filePath.substring(1), r.blob), |
| 332 | + ) |
| 333 | + |
329 | 334 | await imagedb.savedata.each((image: SaveData) => {
|
330 | 335 | zp.current = image.filename ?? ''
|
331 | 336 | const blob = dataURLtoBlob(image!.processeddataUrl!)
|
|
0 commit comments