Browse Source

test:文件分享

master
prr 7 months ago
parent
commit
bff023cfcb
  1. 9
      frontend/src/components/oa/ShareFiles.vue
  2. 29
      frontend/src/components/setting/SetFilePwd.vue
  3. 5
      frontend/src/system/index.ts

9
frontend/src/components/oa/ShareFiles.vue

@ -24,7 +24,7 @@
import { ref, inject } from 'vue';
import { useSystem, BrowserWindow } from '@/system';
import { getSystemConfig, fetchPost } from "@/system/config";
import { notifySuccess, notifyError } from "@/util/msg";
const window: BrowserWindow | undefined = inject("browserWindow");
const sys = useSystem()
const userInfo: any = sys.getConfig('userInfo')
@ -61,7 +61,12 @@ const onSubmit = async () => {
const temp = {...form.value}
temp.senderid = temp.senderid.toString()
temp.receverid = temp.receverid.map((item:any) => item.toString())
await fetchPost(apiUrl, new URLSearchParams(temp))
const res = await fetchPost(apiUrl, new URLSearchParams(temp))
if (res.ok) {
notifySuccess("分享文件成功")
} else {
notifyError("分享文件失败")
}
}
</script>
<style scoped>

29
frontend/src/components/setting/SetFilePwd.vue

@ -1,21 +1,46 @@
<template>
<div class="file-pwd-box">
<div v-if="setPwd">
<div class="setting-item" >
<label>文件密码</label>
<el-input v-model="filePwd" placeholder="请输入文件加密密码" />
<el-input v-model="filePwd" placeholder="请输入文件加密密码" type="password"/>
</div>
<div class="setting-item">
<label></label>
<el-button @click="toSetFilePwd" type="primary">{{ t("setFilePwd") }}</el-button>
<el-button @click="clearPwd" type="primary">取消文件加密</el-button>
</div>
</div>
<div v-else class="setting-item">
<label></label>
<el-button @click="setPwd = true" type="primary">设置文件密码</el-button>
</div>
</div>
</template>
<script lang="ts" setup>
import { md5 } from "js-md5";
import { ref } from "vue";
import { t } from "@/system";
import { fetchGet, getSystemConfig } from "@/system/config";
import { notifySuccess } from "@/util/msg";
const filePwd = ref('')
const toSetFilePwd = ()=> {}
const setPwd = ref(false)
async function toSetFilePwd() {
console.log('pwd:', filePwd);
const url = getSystemConfig().userInfo.url + '/file/setfilepwd'
const header = {
'Salt': 'vIf_wIUedciAd0nTm6qjJA==',
'FilePwd': md5(filePwd.value)
}
const res = await fetchGet(url, header)
if (res.ok){
notifySuccess("保存成功111");
}
}
function clearPwd() {
setPwd.value = false
}
</script>
<style scoped>

5
frontend/src/system/index.ts

@ -431,10 +431,13 @@ export class System {
if (isShareFile(path)) {
const arr = path.split('/')
const fileContent = await this.fs.readShareFile(path)
// console.log('阅读:', fileContent);
if (fileContent !== false) {
const fileName = extname(arr[arr.length-1] || '') || 'link'
this._flieOpenerMap
.get(fileName)
?.func.call(this, path, fileContent || '');
}
} else {
const fileStat = await this.fs.stat(path)
if (!fileStat) {
@ -448,6 +451,8 @@ export class System {
} else {
// 读取文件内容
const fileContent = await this.fs.readFile(path);
console.log('文件内容:', fileContent);
// 从_fileOpenerMap中获取文件扩展名对应的函数并调用
const fileName = extname(fileStat?.name || '') || 'link'
//console.log(fileName)

Loading…
Cancel
Save