diff --git a/src/main/config/StaticPath.js b/src/main/config/StaticPath.js
index af221a8..7825edf 100644
--- a/src/main/config/StaticPath.js
+++ b/src/main/config/StaticPath.js
@@ -1,5 +1,6 @@
// 这里定义了静态文件路径的位置
import path from 'path'
+import { NO_CACHE_FILE_PROTOCOL } from '@/constants'
/**
* Set `__static` path to static files in production
@@ -11,8 +12,8 @@ if (process.env.NODE_ENV !== 'development') {
}
export const winURL =
- process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}` : `file://${__dirname}/index.html`
+ process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}` : `${NO_CACHE_FILE_PROTOCOL}://${__dirname}/index.html`
export const loadingURL =
process.env.NODE_ENV === 'development'
? `http://localhost:${process.env.PORT}/static/loader.html`
- : `file://${__static}/loader.html`
+ : `${NO_CACHE_FILE_PROTOCOL}://${__static}/loader.html`
diff --git a/src/renderer/components/effect-preview/index.vue b/src/renderer/components/effect-preview/index.vue
index 743d8dc..4a3da6c 100644
--- a/src/renderer/components/effect-preview/index.vue
+++ b/src/renderer/components/effect-preview/index.vue
@@ -134,7 +134,7 @@
-
+
{{ $t('imagePreview.resetAll') }}
@@ -298,6 +298,9 @@ export default {
})
return filter
},
+ isCanvas() {
+ return this.mode === 'canvas'
+ },
inputShadow: {
get() {
return this.inputLevels[0]
diff --git a/src/renderer/lib/index.js b/src/renderer/lib/index.js
index 9df8e68..a3ded29 100644
--- a/src/renderer/lib/index.js
+++ b/src/renderer/lib/index.js
@@ -1,4 +1,6 @@
import path from 'path'
+import { NO_CACHE_FILE_PROTOCOL } from '@/constants'
+
const loadLib = function (cb) {
if (window.cv) {
cb(window.cv)
@@ -16,7 +18,7 @@ const loadLib = function (cb) {
script.addEventListener('error', () => {
console.error('Failed to load ' + OPENCV_URL)
})
- script.src = 'file:///' + OPENCV_URL
+ script.src = `${NO_CACHE_FILE_PROTOCOL}:///` + OPENCV_URL
let node = document.getElementsByTagName('script')[0]
node.parentNode.insertBefore(script, node)
}
diff --git a/src/renderer/utils/image.js b/src/renderer/utils/image.js
index 32497f6..1cfbebf 100644
--- a/src/renderer/utils/image.js
+++ b/src/renderer/utils/image.js
@@ -6,7 +6,7 @@ import { decode, decodeImage, toRGBA8 } from 'utif2'
export const getImageUrlSync = (path) => {
const uri = path.split(/[/\\]/)
const name = uri.pop()
- return 'file://' + [...uri, encodeURIComponent(name)].join('/')
+ return `${NO_CACHE_FILE_PROTOCOL}://` + [...uri, encodeURIComponent(name)].join('/')
}
export const getImageUrlSyncNoCache = (path) => {
return encodeURI(`${NO_CACHE_FILE_PROTOCOL}://${path}`)
diff --git a/src/renderer/utils/worker.js b/src/renderer/utils/worker.js
index 1e066a6..45f70d5 100644
--- a/src/renderer/utils/worker.js
+++ b/src/renderer/utils/worker.js
@@ -1,6 +1,7 @@
import path from 'path'
+import { NO_CACHE_FILE_PROTOCOL } from '@/constants'
-const workerPath = 'file:///' + path.join(__static, '/sw.js')
+const workerPath = `${NO_CACHE_FILE_PROTOCOL}:///` + path.join(__static, '/sw.js')
export const useWorker = (id, type, imageData, params) => {
return new Promise(async (resolve, reject) => {
diff --git a/src/renderer/views/image/ImageCompare.vue b/src/renderer/views/image/ImageCompare.vue
index 89b7485..45fa61d 100644
--- a/src/renderer/views/image/ImageCompare.vue
+++ b/src/renderer/views/image/ImageCompare.vue
@@ -47,7 +47,7 @@ export default {
},
methods: {
async initFiltersMap() {
- // await useWorker('all', 'initFiltersMap')
+ await useWorker('all', 'initFiltersMap')
},
}
}
diff --git a/src/renderer/views/image/components/ImageCanvas.vue b/src/renderer/views/image/components/ImageCanvas.vue
index 10e8518..46b6598 100644
--- a/src/renderer/views/image/components/ImageCanvas.vue
+++ b/src/renderer/views/image/components/ImageCanvas.vue
@@ -541,14 +541,14 @@ export default {
})
: this.getImageData()
this.bitMap = await createImageBitmap(imageData)
- // useWorker(this.getName(false), 'all', imageData, this.$refs['effect-settings'].generateFilterParams({})).then(
- // (res) => {
- // this.bitMap && this.bitMap?.close()
- // this.bitMap = null
- // this.bitMap = res
- // this.drawImage()
- // }
- // )
+ useWorker(this.getName(false), 'all', imageData, this.$refs['effect-settings'].generateFilterParams({})).then(
+ (res) => {
+ this.bitMap && this.bitMap?.close()
+ this.bitMap = null
+ this.bitMap = res
+ this.drawImage()
+ }
+ )
resolve(this.bitMap)
})
},
@@ -556,12 +556,12 @@ export default {
if (!this.ready) {
return
}
- // const imageData = this.getImageData()
- // useWorker(this.getName(false), type, imageData, params).then((res) => {
- // this.bitMap && this.bitMap?.close()
- // this.bitMap = res
- // this.drawImage()
- // })
+ const imageData = this.getImageData()
+ useWorker(this.getName(false), type, imageData, params).then((res) => {
+ this.bitMap && this.bitMap?.close()
+ this.bitMap = res
+ this.drawImage()
+ })
},
async adjustGamma({ parentId, ...params }) {
const { gamma } = params
@@ -614,7 +614,7 @@ export default {
})
},
async initFilters() {
- // await useWorker(this.getName(false), 'initFilters')
+ await useWorker(this.getName(false), 'initFilters')
},
getImageData(_img) {
const img = _img ?? this.image
diff --git a/static/sw.js b/static/sw.js
index f9368b9..ac94619 100644
--- a/static/sw.js
+++ b/static/sw.js
@@ -77,7 +77,7 @@ onmessage = async (e) => {
initFilters(resetFilters, resetFiltersExcluedResetIndex)
- console.log(`【${id.length > 13 ? "..." + id.slice(-10) : id}】 process filters: ${filters.map(i => i.name).concat(resetFilters.map(i => i.name)).join("->")},`, `params: ${JSON.stringify(params)}`)
+ // console.log(`【${id.length > 13 ? "..." + id.slice(-10) : id}】 process filters: ${filters.map(i => i.name).concat(resetFilters.map(i => i.name)).join("->")},`, `params: ${JSON.stringify(params)}`)
for (let i = 0; i < len; i++) {
const filter = resetFilters[i];
@@ -95,7 +95,7 @@ onmessage = async (e) => {
}
filters = filters.concat(resetFilters)
} else {
- console.log(`${id} skip filter`)
+ // console.log(`${id} skip filter`)
}
filtersMap.set(id, {filters, params})