|
|
@ -20,27 +20,44 @@ |
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
import { md5 } from "js-md5"; |
|
|
|
import { ref } from "vue"; |
|
|
|
import { ref, onMounted } from "vue"; |
|
|
|
import { t } from "@/system"; |
|
|
|
import { fetchGet, getSystemConfig } from "@/system/config"; |
|
|
|
import { notifySuccess } from "@/util/msg"; |
|
|
|
import { fetchGet, getApiUrl, setSystemKey, getSystemConfig } from "@/system/config"; |
|
|
|
import { notifySuccess, notifyError } from "@/util/msg"; |
|
|
|
const filePwd = ref('') |
|
|
|
const setPwd = ref(false) |
|
|
|
const params = { |
|
|
|
ispwd: true, |
|
|
|
pwd: md5(filePwd.value), |
|
|
|
salt: getSystemConfig().file.salt |
|
|
|
} |
|
|
|
async function toSetFilePwd() { |
|
|
|
console.log('pwd:', filePwd); |
|
|
|
const url = getSystemConfig().userInfo.url + '/file/setfilepwd' |
|
|
|
// console.log('密码:',filePwd.value, md5(filePwd.value)); |
|
|
|
params.ispwd = filePwd.value === '' ? false : true |
|
|
|
const url = getApiUrl() + '/file/setfilepwd' |
|
|
|
const header = { |
|
|
|
'Salt': 'vIf_wIUedciAd0nTm6qjJA==', |
|
|
|
'FilePwd': md5(filePwd.value) |
|
|
|
'Salt': params.salt, |
|
|
|
'FilePwd': params.pwd |
|
|
|
} |
|
|
|
await fetchGet(`${getApiUrl()}/file/ispwd?ispwd=${params.ispwd}`) |
|
|
|
const res = await fetchGet(url, header) |
|
|
|
if (res.ok){ |
|
|
|
notifySuccess("保存成功111"); |
|
|
|
notifySuccess("设置文件密码成功"); |
|
|
|
} else { |
|
|
|
params.ispwd = false |
|
|
|
params.pwd = '' |
|
|
|
notifyError("设置文件密码失败") |
|
|
|
} |
|
|
|
setSystemKey('file',params) |
|
|
|
} |
|
|
|
function clearPwd() { |
|
|
|
setPwd.value = false |
|
|
|
filePwd.value = '' |
|
|
|
toSetFilePwd() |
|
|
|
} |
|
|
|
onMounted(()=>{ |
|
|
|
setPwd.value = params.ispwd |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|