PDF插件上线
This commit is contained in:
parent
7a978ddf55
commit
9d18bb2cdf
|
@ -6,6 +6,7 @@
|
|||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { getAppInstallUrl } from '@/utils/tool'
|
||||
const props = defineProps({
|
||||
url: {
|
||||
type: String,
|
||||
|
@ -16,7 +17,7 @@ const props = defineProps({
|
|||
/**pdf文件地址 */
|
||||
const pdfUrl = ref('');
|
||||
/**pdfjs文件地址 */
|
||||
const fileUrl = '/pdfjs-dist/web/viewer.html?file=';
|
||||
const fileUrl = getAppInstallUrl('pdfjs-dist/web/viewer.html', 'user', '\\out\\renderer', true) + "?file=" //本地
|
||||
onMounted(() => {
|
||||
/** 将传入的pdf地址进行编码,防止中文识别错误 */
|
||||
pdfUrl.value = fileUrl + encodeURIComponent(props.url)
|
||||
|
|
|
@ -49,6 +49,18 @@ export const getStaticUrl = (url = '', type = 'app', exitPath = '', isFile = fal
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const getAppInstallUrl = (url = '', type = 'app', exitPath = '', isFile = false) => {
|
||||
if (isDev) return url
|
||||
else { // 生产环境获取-url
|
||||
switch(type) {
|
||||
case 'app': return path.join(__dirname, url) // 应用目录
|
||||
case 'user': return (isFile?'file://':'')+path.join(Remote.app.getAppPath(),exitPath, url) // 用户目录
|
||||
// case 'user': return (isFile?'file://':'')+path.join(Remote.app.getPath('userData'),exitPath, url) // 用户目录
|
||||
default: return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description 消息发送-nodejs 消息发送
|
||||
* @form src/main/tool.js 来源
|
||||
|
|
Loading…
Reference in New Issue