修改:文件服务器由nginx改为springboot
This commit is contained in:
parent
f55e614902
commit
2028603ad2
@ -2,10 +2,7 @@
|
||||
ENV = 'development'
|
||||
|
||||
# base api
|
||||
VUE_APP_WEBSOCKET = 'http://localhost:8088'
|
||||
VUE_APP_BASE_API = '/api'
|
||||
VUE_APP_BASE_FILE_API = '/file'
|
||||
VUE_APP_BASE_PRIVIEW_API = '/priview'
|
||||
|
||||
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
|
||||
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
|
||||
|
||||
@ -2,7 +2,4 @@
|
||||
ENV = 'production'
|
||||
|
||||
# base api
|
||||
VUE_APP_WEBSOCKET = 'http://www.jmal.cloud:8088'
|
||||
VUE_APP_BASE_API = '/api'
|
||||
VUE_APP_BASE_FILE_API = '/file'
|
||||
VUE_APP_BASE_PRIVIEW_API = '/priview'
|
||||
VUE_APP_BASE_API = '/'
|
||||
|
||||
@ -4,7 +4,4 @@ NODE_ENV = production
|
||||
ENV = 'staging'
|
||||
|
||||
# base api
|
||||
VUE_APP_WEBSOCKET = 'http://localhost:8088'
|
||||
VUE_APP_BASE_API = '/api'
|
||||
VUE_APP_BASE_FILE_API = '/file'
|
||||
VUE_APP_BASE_PRIVIEW_API = '/priview'
|
||||
VUE_APP_BASE_API = '/'
|
||||
|
||||
@ -536,6 +536,7 @@ import 'pl-table/themes/index.css';
|
||||
import {PlTable, PlTableColumn} from 'pl-table';
|
||||
|
||||
import ws from '@/websocket/websocket_config';
|
||||
import fileConfig from '@/utils/file-config'
|
||||
|
||||
var rowStyleExecuting = false
|
||||
export default {
|
||||
@ -2622,17 +2623,11 @@ export default {
|
||||
} else {
|
||||
fileIds.push(this.rowContextData.id)
|
||||
}
|
||||
let host = window.location.host
|
||||
if (window.location.port.length > 0) {
|
||||
host = window.location.host.substring(0, window.location.host.length - window.location.port.length - 1)
|
||||
if (fileIds.length > 1 || this.rowContextData.isFolder){
|
||||
fileConfig.packageDownload(fileIds, this.$store.state.user.token)
|
||||
return
|
||||
}
|
||||
let api = '/api/file/packageDownload'
|
||||
if (fileIds.length === 1 && !this.rowContextData.isFolder) {
|
||||
api = '/api/file/download'
|
||||
}
|
||||
// this.downloadFile1("haha", `${document.location.protocol}//${host}${api}?fileIds=${fileIds}`, this.$store.state.user.token)
|
||||
// window.open(`${document.location.protocol}//${host}${api}?jmal-token=${this.$store.state.user.token}&fileIds=${fileIds}`, '_self')
|
||||
window.open(`${document.location.protocol}//${host}${api}/${fileIds}`, '_self')
|
||||
fileConfig.download(this.$store.state.user.name, this.rowContextData)
|
||||
} else {
|
||||
this.$message({
|
||||
message: '所选文件为空',
|
||||
@ -2640,34 +2635,6 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
downloadFile1(filename, fileUrl, token) {
|
||||
const xhr = new XMLHttpRequest()
|
||||
const url = fileUrl
|
||||
xhr.open('get', url, true)
|
||||
xhr.setRequestHeader('Authorization', `Bearer ${token}`) // 给后端发送请求头
|
||||
xhr.setRequestHeader('Access-Control-Allow-Origin', `http://localhost:9528`)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.onload = function(e) {
|
||||
if (this.status === 200) {
|
||||
const blob = this.response
|
||||
// URL对象是硬盘(SD卡等)指向文件的一个路径,
|
||||
//如果我们做文件上传的时候,想在没有上传服务器端的情况下看到上传图片的效果图
|
||||
//就可是以通过var url=window.URL.createObjectURL(obj.files[0]);获得一个http格式的url路径
|
||||
//这个时候就可以设置到<img>中显示了
|
||||
//window.webkitURL和window.URL是一样的,window.URL标准定义
|
||||
//window.webkitURL是webkit内核的实现(一般手机上就是使用这个),还有火狐等浏览器的实现。
|
||||
const urlObject = window.URL || window.webkitURL || window
|
||||
const export_blob = new Blob([blob])
|
||||
const a = document.createElementNS('http://www.w3.org/1999/xhtml', 'a') // 利用a标签特性下载
|
||||
const url = urlObject.createObjectURL(export_blob)
|
||||
a.href = url
|
||||
a.download = filename
|
||||
a.click()
|
||||
}
|
||||
}
|
||||
// 发送请求
|
||||
xhr.send()
|
||||
},
|
||||
// 收藏/取消收藏
|
||||
favoriteOperating(isFavorite) {
|
||||
const fileIds = this.getSelectIdList()
|
||||
@ -2869,8 +2836,7 @@ export default {
|
||||
if (window.location.port.length > 0) {
|
||||
host = window.location.host.substring(0, window.location.host.length - window.location.port.length - 1)
|
||||
}
|
||||
window.open(`${document.location.protocol}//${host}/api/file/download/${row.id}`, '_self')
|
||||
// window.open(`${process.env.VUE_APP_BASE_FILE_API}/preview/${row.name}?jmal-token=${this.$store.state.user.token}&fileIds=${row.id}`, '_blank')
|
||||
fileConfig.preview(this.$store.state.user.name, row)
|
||||
return
|
||||
}
|
||||
if (suffix.compressedFile.includes(row.suffix)) {
|
||||
@ -2897,7 +2863,7 @@ export default {
|
||||
this.notPreviewDialogVisible = false
|
||||
},
|
||||
downLaod(file) {
|
||||
window.open(`${process.env.VUE_APP_BASE_FILE_API}/preview/${file.name}?jmal-token=${this.$store.state.user.token}&fileIds=${file.id}`, '_self')
|
||||
fileConfig.download(this.$store.state.user.name, file)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
<script>
|
||||
import '@/utils/directives.js'
|
||||
import Bus from '@/assets/js/bus'
|
||||
import fileConfig from '@/utils/file-config'
|
||||
export default {
|
||||
name: 'AudioPreview',
|
||||
components: {
|
||||
@ -46,13 +47,13 @@ export default {
|
||||
this.onPicClick = this.onPicClick.bind(this);
|
||||
let pic = document.querySelector('.aplayer-pic')
|
||||
pic.addEventListener('click', this.onPicClick);
|
||||
Bus.$on('onAddAudio',(newFile,audioCoverUrl) => {
|
||||
Bus.$on('onAddAudio',(newFile, audioCoverUrl) => {
|
||||
this.show = true
|
||||
let url = `${process.env.VUE_APP_BASE_FILE_API}preview/${newFile.name}?jmal-token=${this.$store.state.user.token}&fileIds=${newFile.id}`
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, newFile)
|
||||
console.log(url)
|
||||
if(!this.$store.state.user.token){
|
||||
url = `${process.env.VUE_APP_BASE_FILE_API}/public/s/preview/${newFile.name}?fileIds=${newFile.id}`
|
||||
url = fileConfig.publicPreviewUrl(newFile.id);
|
||||
}
|
||||
// let url = process.env.VUE_APP_BASE_FILE_API + 'preview/' + newFile.name + '?jmal-token=' + this.$store.state.user.token + '&fileIds=' + newFile.id
|
||||
let music = newFile.music
|
||||
let fileName = newFile.name.substring(0,newFile.name.length - newFile.suffix.length-1)
|
||||
let musicOperation = {
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import fileConfig from '@/utils/file-config'
|
||||
import 'viewerjs/dist/viewer.css';
|
||||
import Bus from '@/assets/js/bus'
|
||||
export default {
|
||||
@ -86,9 +87,9 @@
|
||||
let viewIndex = 0
|
||||
this.fileList.forEach(element => {
|
||||
if(!element.isFolder && element.contentType.indexOf('image') > -1){
|
||||
let url = `${process.env.VUE_APP_BASE_FILE_API}preview/${element.name}?jmal-token=${this.$store.state.user.token}&fileIds=${element.id}`
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, element)
|
||||
if(this.shareId){
|
||||
url = `${process.env.VUE_APP_BASE_FILE_API}/public/s/preview/${element.name}?fileIds=${element.id}`
|
||||
url = fileConfig.publicPreviewUrl(element.id);
|
||||
}
|
||||
this.images.push(url)
|
||||
if(this.file.id === element.id){
|
||||
|
||||
@ -26,6 +26,8 @@ import 'vant/lib/overlay/style';
|
||||
import 'vue-video-player/src/custom-theme.css'
|
||||
import 'video.js/dist/video-js.css'
|
||||
import { videoPlayer } from 'vue-video-player'
|
||||
import fileConfig from '@/utils/file-config'
|
||||
|
||||
export default {
|
||||
name: 'VideoPreview',
|
||||
components: {
|
||||
@ -91,11 +93,10 @@ export default {
|
||||
watch: {
|
||||
status: function(visible){
|
||||
if(visible){
|
||||
let url = `${process.env.VUE_APP_BASE_FILE_API}preview/${this.file.name}?jmal-token=${this.$store.state.user.token}&fileIds=${this.file.id}`
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, this.file)
|
||||
if(this.shareId){
|
||||
url = `${process.env.VUE_APP_BASE_FILE_API}/public/s/preview/${this.file.name}?fileIds=${this.file.id}`
|
||||
url = fileConfig.publicPreviewUrl(this.file.id);
|
||||
}
|
||||
// let url = process.env.VUE_APP_BASE_FILE_API + 'preview/' + this.file.name + '?jmal-token=' + this.$store.state.user.token + '&fileIds=' + this.file.id
|
||||
this.playerOptions.sources = [{
|
||||
//类型
|
||||
type: this.file.contentType,
|
||||
|
||||
33
src/utils/file-config.js
Normal file
33
src/utils/file-config.js
Normal file
@ -0,0 +1,33 @@
|
||||
export default {
|
||||
|
||||
baseUrl: '/api',
|
||||
previewUrl: function(username, file) {
|
||||
return `${this.baseUrl}/file/${username}${file.path}${file.name}`
|
||||
},
|
||||
publicPreviewUrl: function(fileIds) {
|
||||
return `${this.baseUrl}/public/preview/${fileIds}`
|
||||
},
|
||||
preview: function(username, file) {
|
||||
const url = this.previewUrl(username, file)
|
||||
console.log(url)
|
||||
window.open(url, '_blank')
|
||||
},
|
||||
publicPreview: function(fileIds) {
|
||||
const url = this.publicPreviewUrl(fileIds)
|
||||
window.open(url, '_blank')
|
||||
},
|
||||
download: function(username, file) {
|
||||
let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?o=download`
|
||||
window.open(url, '_self')
|
||||
},
|
||||
publicDownload: function(shareId, file) {
|
||||
let url = `${this.baseUrl}/public/s/download/${file.id}/${shareId}ff`
|
||||
window.open(url, '_self')
|
||||
},
|
||||
packageDownload: function(fileIds, token) {
|
||||
window.open(`${this.baseUrl}/packageDownload?fileIds=${fileIds}&jmal-token=${token}`, '_self')
|
||||
},
|
||||
publicPackageDownload: function(shareId, fileIds) {
|
||||
window.open(`${this.baseUrl}/public/s/packageDownload?shareId=${shareId}&fileIds=${fileIds}`, '_self')
|
||||
},
|
||||
}
|
||||
@ -266,7 +266,7 @@
|
||||
import Bus from '@/assets/js/bus'
|
||||
import {Dialog, Notify, Toast} from 'vant';
|
||||
import {getPath, getPathList, removePath, setPath} from '@/utils/path'
|
||||
|
||||
import fileConfig from "@/utils/file-config";
|
||||
let pinyin = require("pinyin");
|
||||
|
||||
export default {
|
||||
@ -556,15 +556,11 @@
|
||||
} else {
|
||||
fileIds.push(this.rowContextData.id)
|
||||
}
|
||||
let host = window.location.host
|
||||
if (window.location.port.length > 0) {
|
||||
host = window.location.host.substring(0, window.location.host.length - window.location.port.length - 1)
|
||||
if (fileIds.length > 1 || this.rowContextData.isFolder){
|
||||
fileConfig.packageDownload(fileIds, this.$store.state.user.token)
|
||||
return
|
||||
}
|
||||
let api = '/api/file/packageDownload'
|
||||
if (fileIds.length === 1 && !this.rowContextData.isFolder) {
|
||||
api = '/api/file/download'
|
||||
}
|
||||
window.open(`${document.location.protocol}//${host}${api}?jmal-token=${this.$store.state.user.token}&fileIds=${fileIds}`, '_self')
|
||||
fileConfig.publicDownload(this.rowContextData)
|
||||
} else {
|
||||
this.$message({
|
||||
message: '所选文件夹为空',
|
||||
@ -987,14 +983,10 @@
|
||||
this.getFileList()
|
||||
} else {
|
||||
if(row.contentType.includes('text')){
|
||||
// let routeData = this.$router.resolve({path: '/public/p',query: {mark: row.id}})
|
||||
// window.open(routeData.href, '_blank');
|
||||
this.$router.push(`/public/articles/article?mark=${row.id}`)
|
||||
}else{
|
||||
// 打开文件
|
||||
const fileIds = [row.id]
|
||||
const url = process.env.VUE_APP_BASE_FILE_API + 'preview/' + row.name + '?jmal-token=' + this.$store.state.user.token + '&fileIds=' + fileIds
|
||||
window.open(url, '_blank')
|
||||
fileConfig.preview(this.$store.state.user.token, row)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
import markdownApi from '@/api/markdown-api'
|
||||
import uploadApi from '@/api/file-api'
|
||||
import DirTree from"@/components/FileTree/DirTree"
|
||||
import fileConfig from '@/utils/file-config'
|
||||
export default {
|
||||
components: {
|
||||
DirTree
|
||||
@ -93,7 +94,9 @@
|
||||
* 1. 通过引入对象获取: `import {mavonEditor} from ...` 等方式引入后,`$vm`为`mavonEditor`
|
||||
* 2. 通过$refs获取: html声明ref : `<mavon-editor ref=md ></mavon-editor>,`$vm`为 `this.$refs.md`
|
||||
*/
|
||||
const url = process.env.VUE_APP_BASE_FILE_API + '/public/image/' + res.data
|
||||
// const url = process.env.VUE_APP_BASE_FILE_API + '/public/image/' + res.data
|
||||
const url = fileConfig.publicPreviewUrl(res.data);
|
||||
console.log(url)
|
||||
this.$refs.md.$img2Url(pos, url);
|
||||
})
|
||||
},
|
||||
|
||||
@ -260,6 +260,7 @@
|
||||
import ImageViewer from "@/components/preview/ImageViewer";
|
||||
import VideoPreview from "@/components/preview/VideoPreview";
|
||||
import AudioPreview from "@/components/preview/AudioPreview";
|
||||
import fileConfig from "@/utils/file-config";
|
||||
|
||||
export default {
|
||||
components: { IconFile, BreadcrumbFilePath,AlLoading,
|
||||
@ -867,15 +868,11 @@
|
||||
} else {
|
||||
fileIds.push(this.rowContextData.id)
|
||||
}
|
||||
let host = window.location.host
|
||||
if (window.location.port.length > 0) {
|
||||
host = window.location.host.substring(0, window.location.host.length - window.location.port.length - 1)
|
||||
if (fileIds.length > 1 || this.rowContextData.isFolder){
|
||||
fileConfig.publicPackageDownload(this.shareId, fileIds, this.$store.state.user.token)
|
||||
return
|
||||
}
|
||||
let api = '/api/file/packageDownload'
|
||||
if (fileIds.length === 1 && !this.rowContextData.isFolder) {
|
||||
api = '/api/file/download'
|
||||
}
|
||||
window.open(`${document.location.protocol}//${host}${api}?jmal-token=${this.$store.state.user.token}&fileIds=${fileIds}`, '_self')
|
||||
fileConfig.publicDownload( this.shareId, this.rowContextData)
|
||||
} else {
|
||||
this.$message({
|
||||
message: '所选文件为空',
|
||||
@ -921,11 +918,8 @@
|
||||
Bus.$emit('onAddAudio',row, this.audioCoverUrl)
|
||||
return
|
||||
}
|
||||
|
||||
// 打开文件
|
||||
const fileIds = [row.id]
|
||||
const url = process.env.VUE_APP_BASE_FILE_API + '/public/s/preview/' + row.name + '?fileIds=' + fileIds
|
||||
window.open(url, '_blank')
|
||||
fileConfig.preview(this.$store.state.user.token, row)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +212,7 @@
|
||||
import ImageViewer from "@/components/preview/ImageViewer";
|
||||
import VideoPreview from "@/components/preview/VideoPreview";
|
||||
import AudioPreview from "@/components/preview/AudioPreview";
|
||||
import fileConfig from "@/utils/file-config";
|
||||
|
||||
export default {
|
||||
components: { IconFile, BreadcrumbFilePath,AlLoading,
|
||||
@ -818,15 +819,11 @@
|
||||
} else {
|
||||
fileIds.push(this.rowContextData.id)
|
||||
}
|
||||
let host = window.location.host
|
||||
if (window.location.port.length > 0) {
|
||||
host = window.location.host.substring(0, window.location.host.length - window.location.port.length - 1)
|
||||
if (fileIds.length > 1 || this.rowContextData.isFolder){
|
||||
fileConfig.publicPackageDownload(this.shareId, fileIds, this.$store.state.user.token)
|
||||
return
|
||||
}
|
||||
let api = '/api/file/packageDownload'
|
||||
if (fileIds.length === 1 && !this.rowContextData.isFolder) {
|
||||
api = '/api/file/download'
|
||||
}
|
||||
window.open(`${document.location.protocol}//${host}${api}?jmal-token=${this.$store.state.user.token}&fileIds=${fileIds}`, '_self')
|
||||
fileConfig.publicDownload(this.shareId, this.rowContextData)
|
||||
} else {
|
||||
this.$message({
|
||||
message: '所选文件为空',
|
||||
@ -872,11 +869,8 @@
|
||||
Bus.$emit('onAddAudio',row, this.audioCoverUrl)
|
||||
return
|
||||
}
|
||||
|
||||
// 打开文件
|
||||
const fileIds = [row.id]
|
||||
const url = process.env.VUE_APP_BASE_FILE_API + '/public/s/preview/' + row.name + '?fileIds=' + fileIds
|
||||
window.open(url, '_blank')
|
||||
fileConfig.preview(this.$store.state.user.token, row)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,20 +59,6 @@ module.exports = {
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: ''
|
||||
}
|
||||
},
|
||||
[process.env.VUE_APP_BASE_FILE_API]: {
|
||||
target: 'http://localhost:10010/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_FILE_API]: ''
|
||||
}
|
||||
},
|
||||
[process.env.VUE_APP_BASE_PRIVIEW_API]: {
|
||||
target: 'http://localhost:8012/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_PRIVIEW_API]: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user