Browse Source

test:文件分享

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

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

@ -24,7 +24,7 @@
import { ref, inject } from 'vue'; import { ref, inject } from 'vue';
import { useSystem, BrowserWindow } from '@/system'; import { useSystem, BrowserWindow } from '@/system';
import { getSystemConfig, fetchPost } from "@/system/config"; import { getSystemConfig, fetchPost } from "@/system/config";
import { notifySuccess, notifyError } from "@/util/msg";
const window: BrowserWindow | undefined = inject("browserWindow"); const window: BrowserWindow | undefined = inject("browserWindow");
const sys = useSystem() const sys = useSystem()
const userInfo: any = sys.getConfig('userInfo') const userInfo: any = sys.getConfig('userInfo')
@ -61,7 +61,12 @@ const onSubmit = async () => {
const temp = {...form.value} const temp = {...form.value}
temp.senderid = temp.senderid.toString() temp.senderid = temp.senderid.toString()
temp.receverid = temp.receverid.map((item:any) => item.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> </script>
<style scoped> <style scoped>

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

@ -1,21 +1,46 @@
<template> <template>
<div class="file-pwd-box"> <div class="file-pwd-box">
<div class="setting-item" > <div v-if="setPwd">
<label>文件密码</label> <div class="setting-item" >
<el-input v-model="filePwd" placeholder="请输入文件加密密码" /> <label>文件密码</label>
<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>
<div class="setting-item"> <div v-else class="setting-item">
<label></label> <label></label>
<el-button @click="toSetFilePwd" type="primary">{{ t("setFilePwd") }}</el-button> <el-button @click="setPwd = true" type="primary">设置文件密码</el-button>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { md5 } from "js-md5";
import { ref } from "vue"; import { ref } from "vue";
import { t } from "@/system"; import { t } from "@/system";
import { fetchGet, getSystemConfig } from "@/system/config";
import { notifySuccess } from "@/util/msg";
const filePwd = ref('') 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> </script>
<style scoped> <style scoped>

13
frontend/src/system/index.ts

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

Loading…
Cancel
Save