|
|
@ -1,22 +1,27 @@ |
|
|
|
<template> |
|
|
|
<iframe class="setiframe" allow="fullscreen" ref="storeRef" :src="src"></iframe> |
|
|
|
<iframe |
|
|
|
class="setiframe" |
|
|
|
allow="fullscreen" |
|
|
|
ref="storeRef" |
|
|
|
:src="src" |
|
|
|
></iframe> |
|
|
|
</template> |
|
|
|
<script lang="ts" setup name="IframeFile"> |
|
|
|
//@ts-ignore |
|
|
|
import { BrowserWindow, Dialog, Notify, System } from "@/system"; |
|
|
|
import { getSplit, getSystemConfig, setSystemKey } from "@/system/config"; |
|
|
|
import { base64ToBuffer, isBase64 } from "@/util/file"; |
|
|
|
import { isShareFile } from "@/util/sharePath.ts"; |
|
|
|
import { inject, onMounted, onUnmounted, ref, toRaw } from "vue"; |
|
|
|
import { askAi } from "@/hook/useAi"; |
|
|
|
import { useChooseStore } from "@/stores/choose"; |
|
|
|
import { nanoid } from "nanoid"; |
|
|
|
import eventBus from "@/system/event/eventBus"; |
|
|
|
const SP = getSplit(); |
|
|
|
//@ts-ignore |
|
|
|
import { askAi } from "@/hook/useAi"; |
|
|
|
import { useChooseStore } from "@/stores/choose"; |
|
|
|
import { BrowserWindow, Dialog, Notify, System } from "@/system"; |
|
|
|
import { getSplit, getSystemConfig, setSystemKey } from "@/system/config"; |
|
|
|
import eventBus from "@/system/event/eventBus"; |
|
|
|
import { base64ToBuffer, isBase64 } from "@/util/file"; |
|
|
|
import { isShareFile } from "@/util/sharePath.ts"; |
|
|
|
import { nanoid } from "nanoid"; |
|
|
|
import { inject, onMounted, onUnmounted, ref, toRaw } from "vue"; |
|
|
|
const SP = getSplit(); |
|
|
|
|
|
|
|
const sys: any = inject<System>("system"); |
|
|
|
const win: any = inject<BrowserWindow>("browserWindow"); |
|
|
|
const props = defineProps({ |
|
|
|
const sys: any = inject<System>("system"); |
|
|
|
const win: any = inject<BrowserWindow>("browserWindow"); |
|
|
|
const props = defineProps({ |
|
|
|
src: { |
|
|
|
type: String, |
|
|
|
default: "", |
|
|
@ -29,14 +34,14 @@ const props = defineProps({ |
|
|
|
type: String, |
|
|
|
default: "md", |
|
|
|
}, |
|
|
|
}); |
|
|
|
const storeRef = ref<HTMLIFrameElement | null>(null); |
|
|
|
let hasInit = false; |
|
|
|
}); |
|
|
|
const storeRef = ref<HTMLIFrameElement | null>(null); |
|
|
|
let hasInit = false; |
|
|
|
|
|
|
|
const choose = useChooseStore(); |
|
|
|
const componentID = nanoid(); |
|
|
|
// console.log("唯一ID:", componentID); |
|
|
|
const saveFile = async (e: any) => { |
|
|
|
const choose = useChooseStore(); |
|
|
|
const componentID = nanoid(); |
|
|
|
// console.log("唯一ID:", componentID); |
|
|
|
const saveFile = async (e: any) => { |
|
|
|
if (e.componentID !== componentID) return; |
|
|
|
let data = JSON.parse(e.eventData.data); |
|
|
|
let ext: any = props.ext; |
|
|
@ -46,15 +51,15 @@ const saveFile = async (e: any) => { |
|
|
|
if (data.ext) { |
|
|
|
ext = data.ext; |
|
|
|
} |
|
|
|
let path:string |
|
|
|
let path: string; |
|
|
|
e.filePath !== "" |
|
|
|
? (path = `${e.filePath}/${e.fileName}.${ext}`) |
|
|
|
: (path = `${SP}C${SP}Users${SP}Desktop${SP}${e.fileName}.${ext}`); |
|
|
|
// console.log('路径:',path); |
|
|
|
await writeFile(path, data, e.fileName); |
|
|
|
}; |
|
|
|
eventBus.on("saveFile", saveFile); |
|
|
|
const writeFile = async (path: string, data: any, title: string) => { |
|
|
|
}; |
|
|
|
eventBus.on("saveFile", saveFile); |
|
|
|
const writeFile = async (path: string, data: any, title: string) => { |
|
|
|
const isShare = ref(false); |
|
|
|
const isWrite = ref(0); |
|
|
|
if (isShareFile(path)) { |
|
|
@ -107,8 +112,8 @@ const writeFile = async (path: string, data: any, title: string) => { |
|
|
|
// content: res.code === 0 ? "文件已保存" : res.message, |
|
|
|
}); |
|
|
|
sys.refershAppList(); |
|
|
|
}; |
|
|
|
const eventHandler = async (e: MessageEvent) => { |
|
|
|
}; |
|
|
|
const eventHandler = async (e: MessageEvent) => { |
|
|
|
const eventData = e.data; |
|
|
|
// console.log('是否同一个:', componentID == eventData.componentID); |
|
|
|
if (eventData.type == props.eventType) { |
|
|
@ -241,29 +246,29 @@ const eventHandler = async (e: MessageEvent) => { |
|
|
|
"*" |
|
|
|
); |
|
|
|
} |
|
|
|
}; |
|
|
|
//删除本地暂存的文件密码 |
|
|
|
const delFileInputPwd = async () => { |
|
|
|
}; |
|
|
|
//删除本地暂存的文件密码 |
|
|
|
const delFileInputPwd = async () => { |
|
|
|
let fileInputPwd = getSystemConfig().fileInputPwd; |
|
|
|
const currentPath = win.config.path; |
|
|
|
const temp = fileInputPwd.filter( |
|
|
|
(item: any) => item.path !== currentPath |
|
|
|
); |
|
|
|
setSystemKey("fileInputPwd", temp); |
|
|
|
}; |
|
|
|
onMounted(() => { |
|
|
|
}; |
|
|
|
onMounted(() => { |
|
|
|
window.addEventListener("message", eventHandler); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
onUnmounted(async () => { |
|
|
|
onUnmounted(async () => { |
|
|
|
await delFileInputPwd(); |
|
|
|
window.removeEventListener("message", eventHandler); |
|
|
|
}); |
|
|
|
}); |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
|
.setiframe { |
|
|
|
.setiframe { |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
border: none; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|