{
+ const pos = choose.saveFileContent.findIndex((item: any) => {
return item.componentID == browserWindow.windowInfo.componentID
})
if (pos == -1) return
@@ -239,7 +239,11 @@
position: relative;
}
}
-
+ .saveFileMain {
+ :deep(.main) {
+ height: calc(100% - 60px);
+ }
+ }
.topwin {
// border: 1px solid #0078d7;
// box-shadow: var(--window-top-box-shadow);
diff --git a/frontend/src/stores/choose.ts b/frontend/src/stores/choose.ts
index b19a9e5..49a9da1 100644
--- a/frontend/src/stores/choose.ts
+++ b/frontend/src/stores/choose.ts
@@ -1,14 +1,27 @@
import { defineStore } from "pinia"
import { BrowserWindow } from "@/system";
import { ref } from 'vue';
+type ExtMap = {
+ [key: string]: string | string[]
+}
export const useChooseStore = defineStore('chooseStore', () => {
const win:any = ref()
const path:any = ref([])
const ifShow = ref(false)
- let savePath = ref({
- path: '',
- name: ''
- })
+ const extArr: ExtMap = {
+ 'Documents/Word': 'docx',
+ 'Documents/PPT': 'pptx',
+ 'Documents/Markdown': 'md',
+ 'Documents/Excel': 'xlsx',
+ 'Documents/Mind': 'mind',
+ 'Documents/Kanban': 'kb',
+ 'Documents/Baiban': 'bb',
+ 'Documents/Screenshot': 'screenshot',
+ 'Documents/ScreenRecoding': 'screentRecording',
+ 'Pictures': ['png','jpg','webp','gif','bmp','tiff'],
+ 'Music': 'mp3',
+ 'Videos': 'mp4'
+ }
const saveFileContent = ref
([])
const select = (title = '选择文件', fileExt:any) => {
@@ -31,8 +44,11 @@ export const useChooseStore = defineStore('chooseStore', () => {
win.value.show()
ifShow.value = true
}
- const saveFile = (title: string, fileExt: any, componentID: string, eventData: any) => {
+ const saveFile = (title: string, fileExt: any, componentID: string, eventData: any, ext: string) => {
// console.log('保存文件');
+ // 判断是否已经存在
+ if (isExist(componentID)) return
+ // 打开弹窗
win.value = new BrowserWindow({
title,
content: "Computer",
@@ -52,29 +68,58 @@ export const useChooseStore = defineStore('chooseStore', () => {
componentID
});
win.value.show()
+ // 默认路径
+ let defaultPath = ''
+ Object.keys(extArr).forEach( (item: string) => {
+ if (extArr[item] &&
+ ((Array.isArray(extArr[item]) && extArr[item].includes(ext)) || extArr[item] == ext)
+ ) {
+ defaultPath = item
+ }
+ })
+ defaultPath == '' ? defaultPath = '/D' : defaultPath = '/C/Users/' + defaultPath
+ // console.log('1111111:', defaultPath);
saveFileContent.value.push({
componentID,
eventData,
+ defaultPath,
filePath: '',
fileName: ''
})
- return savePath
// ifShow.value = true
}
const close = () => {
- ifShow.value = false
- win.value.close()
+ ifShow.value = false
+ win.value.close()
+ }
+ // 清除缓存
+ const closeSaveFile = (componentID: string) => {
+ saveFileContent.value.forEach((item, index) => {
+ if (item.componentID == componentID) {
+ saveFileContent.value.splice(index, 1)
+ }
+ })
+ win.value.close()
+ }
+ // 判断弹窗是否存在
+ const isExist = (componentID: string) => {
+ saveFileContent.value.forEach(item => {
+ if (item.componentID == componentID) {
+ return true
+ }
+ })
+ return false
}
-
return {
win,
path,
ifShow,
- savePath,
saveFileContent,
select,
close,
- saveFile
+ saveFile,
+ closeSaveFile,
+ isExist
}
})
\ No newline at end of file
diff --git a/frontend/src/system/window/Dialog.ts b/frontend/src/system/window/Dialog.ts
index e63c047..001536c 100644
--- a/frontend/src/system/window/Dialog.ts
+++ b/frontend/src/system/window/Dialog.ts
@@ -79,12 +79,18 @@ class Dialog {
}>((resolve) => {
promres = resolve;
});
+ let confirmText = 'OK'
+ let cancleText = 'Cancel'
+ if (option.buttons && option.buttons.length == 2) {
+ confirmText = option.buttons[0]
+ cancleText = option.buttons[1]
+ }
ElMessageBox.confirm(
opt.message,
opt.title,
{
- confirmButtonText: 'OK',
- cancelButtonText: 'Cancel',
+ confirmButtonText: confirmText,
+ cancelButtonText: cancleText,
type: opt.type,
}
)