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 来源
|
||||
|
@ -137,7 +149,7 @@ export const createWindow = async (type, data) => {
|
|||
winPdf.focus();
|
||||
// toolState.isPdfWin=true
|
||||
}
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
const option = data.option||{}
|
||||
|
@ -272,7 +284,7 @@ const eventHandles = (type, win) => {
|
|||
winPdf=null
|
||||
win&&win.destroy()
|
||||
})
|
||||
|
||||
|
||||
// 监听窗口的激活事件
|
||||
win.on('focus', async () => {
|
||||
console.log('激活窗口')
|
||||
|
@ -299,8 +311,8 @@ const eventHandles = (type, win) => {
|
|||
|
||||
/**
|
||||
* @description 外部跳转-web网页
|
||||
* @param {*} path
|
||||
* @param {*} params
|
||||
* @param {*} path
|
||||
* @param {*} params
|
||||
*/
|
||||
export const toLinkWeb = (path) => {
|
||||
const config = baseConfig()
|
||||
|
|
Loading…
Reference in New Issue