mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
✨ Feature: pictures uploaded using webdav and local path can be previewed in gallery now
ISSUES CLOSED: #64
This commit is contained in:
parent
da623bcd6d
commit
6a94503172
@ -66,7 +66,7 @@
|
|||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"mitt": "^3.0.0",
|
"mitt": "^3.0.0",
|
||||||
"nodejs-file-downloader": "^4.12.1",
|
"nodejs-file-downloader": "^4.12.1",
|
||||||
"piclist": "^0.7.4",
|
"piclist": "^0.7.6",
|
||||||
"pinia": "^2.1.4",
|
"pinia": "^2.1.4",
|
||||||
"pinia-plugin-persistedstate": "^3.1.0",
|
"pinia-plugin-persistedstate": "^3.1.0",
|
||||||
"qiniu": "^7.8.0",
|
"qiniu": "^7.8.0",
|
||||||
|
32
src/main/fileServer/index.ts
Normal file
32
src/main/fileServer/index.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import http from 'http'
|
||||||
|
import fs from 'fs-extra'
|
||||||
|
import path from 'path'
|
||||||
|
import picgo from '@core/picgo'
|
||||||
|
import logger from '../apis/core/picgo/logger'
|
||||||
|
|
||||||
|
export const imgFilePath = path.join(picgo.baseDir, 'imgTemp')
|
||||||
|
fs.ensureDirSync(imgFilePath)
|
||||||
|
|
||||||
|
const serverPort = 36699
|
||||||
|
|
||||||
|
export function startFileServer () {
|
||||||
|
const server = http.createServer((req, res) => {
|
||||||
|
const requestPath = req.url?.split('?')[0]
|
||||||
|
const filePath = path.join(imgFilePath, requestPath!)
|
||||||
|
|
||||||
|
fs.readFile(filePath, (err, data) => {
|
||||||
|
if (err) {
|
||||||
|
res.writeHead(404)
|
||||||
|
res.end('404 Not Found')
|
||||||
|
} else {
|
||||||
|
res.end(data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
server.listen(serverPort, () => {
|
||||||
|
logger.info(`File server is running, http://localhost:${serverPort}`)
|
||||||
|
}).on('error', (err) => {
|
||||||
|
logger.error(err)
|
||||||
|
})
|
||||||
|
}
|
@ -47,6 +47,7 @@ import clipboardPoll from '../utils/clipboardPoll'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static'
|
import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
|
import { startFileServer } from '../fileServer'
|
||||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
const handleStartUpFiles = (argv: string[], cwd: string) => {
|
const handleStartUpFiles = (argv: string[], cwd: string) => {
|
||||||
@ -158,6 +159,7 @@ class LifeCycle {
|
|||||||
shortKeyHandler.init()
|
shortKeyHandler.init()
|
||||||
})
|
})
|
||||||
server.startup()
|
server.startup()
|
||||||
|
startFileServer()
|
||||||
if (process.env.NODE_ENV !== 'development') {
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
handleStartUpFiles(process.argv, process.cwd())
|
handleStartUpFiles(process.argv, process.cwd())
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@
|
|||||||
@click="zoomImage(index)"
|
@click="zoomImage(index)"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
v-lazy="item.imgUrl"
|
v-lazy="item.galleryPath || item.imgUrl"
|
||||||
class="gallery-list__item-img"
|
class="gallery-list__item-img"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11054,10 +11054,10 @@ performance-now@^2.1.0:
|
|||||||
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||||
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
|
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
|
||||||
|
|
||||||
piclist@^0.7.4:
|
piclist@^0.7.6:
|
||||||
version "0.7.4"
|
version "0.7.6"
|
||||||
resolved "https://registry.npmjs.org/piclist/-/piclist-0.7.4.tgz#125c9f337e2d7375ae0c5c17fafaf924134fd65f"
|
resolved "https://registry.npmjs.org/piclist/-/piclist-0.7.6.tgz#93ac36f2f3fa067d014b4ff1e808bd6304fa29e3"
|
||||||
integrity sha512-PxE6S93uWP7sQNyMi6R7ZEs57oOXgm/nD14Moi0k0dbAlvtm1kWdrc4CboW/6e7hPVgeqT7pGi0+y0SF8iTxOA==
|
integrity sha512-aLoVhvl8A/Ez2I3T3rmqQ5MCBw6txTQ+5H0zGvgybEpHGpuTHct9MBplfJVj2eIyqwbbcWT24t5bkvaByma2gw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@picgo/i18n" "^1.0.0"
|
"@picgo/i18n" "^1.0.0"
|
||||||
"@picgo/store" "^2.0.4"
|
"@picgo/store" "^2.0.4"
|
||||||
|
Loading…
Reference in New Issue
Block a user