Skip to content

Commit

Permalink
fix: show pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhx committed Aug 11, 2024
1 parent 98b76b1 commit f5653c5
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 30 deletions.
5 changes: 3 additions & 2 deletions src/main/config/StaticPath.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 这里定义了静态文件路径的位置
import path from 'path'
import { NO_CACHE_FILE_PROTOCOL } from '@/constants'

/**
* Set `__static` path to static files in production
Expand All @@ -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`
17 changes: 10 additions & 7 deletions src/renderer/components/effect-preview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,18 @@
<el-slider :min="0" :max="15" v-model="blur" show-input></el-slider>
</el-col>
</el-row>
<!-- <el-row :gutter="10" flex="cross:center">
<el-row v-show="isCanvas" :gutter="10" flex="cross:center">
<el-col :span="6">
<span class="text-style">{{ $t('imagePreview.gamma') }}</span>
</el-col>
<el-col :span="18">
<el-slider :min="0.01" :max="10" :step="0.01" v-model="gammaData" show-input @input="updateGama"></el-slider>
</el-col>
</el-row>
<el-divider>
<el-divider v-show="isCanvas">
<span class="title-style">{{ $t('imagePreview.colorLevel.title') }}</span>
</el-divider>
<el-row :gutter="2" flex="cross:center">
<el-row v-show="isCanvas" :gutter="2" flex="cross:center">
<el-col :span="4">
<span class="text-style">{{ $t('imagePreview.channel') }}</span>
</el-col>
Expand All @@ -162,7 +162,7 @@
</el-radio-group>
</el-col>
</el-row>
<el-row :gutter="2" flex="cross:center">
<el-row v-show="isCanvas" :gutter="2" flex="cross:center">
<el-col :span="6">
<span class="text-style">{{ $t('imagePreview.colorLevel.input') }}</span>
</el-col>
Expand All @@ -188,7 +188,7 @@
</div>
</el-col>
</el-row>
<el-row :gutter="10" flex="cross:center">
<el-row v-show="isCanvas" :gutter="10" flex="cross:center">
<el-col :span="6">
<span class="text-style">{{ $t('imagePreview.colorLevel.inputMidtones') }}</span>
</el-col>
Expand All @@ -203,7 +203,7 @@
></el-slider>
</el-col>
</el-row>
<el-row :gutter="2" flex="cross:center">
<el-row v-show="isCanvas" :gutter="2" flex="cross:center">
<el-col :span="6">
<span class="text-style">{{ $t('imagePreview.colorLevel.input') }}</span>
</el-col>
Expand All @@ -228,7 +228,7 @@
/>
</div>
</el-col>
</el-row> -->
</el-row>
<div flex="main:justify">
<el-switch v-model="enableXray" active-text="Xray"></el-switch>
<el-button @click="resetImageStyle">{{ $t('imagePreview.resetAll') }}</el-button>
Expand Down Expand Up @@ -298,6 +298,9 @@ export default {
})
return filter
},
isCanvas() {
return this.mode === 'canvas'
},
inputShadow: {
get() {
return this.inputLevels[0]
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/lib/index.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/utils/worker.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/image/ImageCompare.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
},
methods: {
async initFiltersMap() {
// await useWorker('all', 'initFiltersMap')
await useWorker('all', 'initFiltersMap')
},
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/renderer/views/image/components/ImageCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -541,27 +541,27 @@ 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)
})
},
applyFilters(type, params) {
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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions static/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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})
Expand Down

0 comments on commit f5653c5

Please sign in to comment.