操作优化

This commit is contained in:
yj 2024-09-09 13:38:47 +08:00
parent 953749867b
commit b07ff2e2f1
2 changed files with 29 additions and 36 deletions

View File

@ -65,7 +65,7 @@
height: 0; height: 0;
.userVideoContentListItem { .userVideoContentListItem {
height: 13%; height: 24%;
width: calc(100% / 3 - 8px); width: calc(100% / 3 - 8px);
padding: 4px; padding: 4px;

View File

@ -79,43 +79,36 @@ const User: React.FC = () => {
} }
const fileUpLoad = async (data: { url: string, content: string, fileName: string }): Promise<void> => { const fileUpLoad = async (data: { url: string, content: string, fileName: string }): Promise<void> => {
const setting = await JSON.parse(storage.getItem('setting') as string) const setting = await JSON.parse(storage.getItem('setting') as string)
if (setting.isShareSavePath) { try {
window.electron.selectFilePath({ const response = await fetch(data.url);
fileName: data.fileName, const arrayBuffer = await response.arrayBuffer();
filePath: data.url const buffer = Buffer.from(arrayBuffer);
}) await fs.writeFile(`${setting.shareFilesPath}\\${data.fileName}`, buffer, {});
} else { setChangeImportModal(false)
try { confirm({
const response = await fetch(data.url); title: '提示',
const arrayBuffer = await response.arrayBuffer(); icon: <ExclamationCircleFilled />,
const buffer = Buffer.from(arrayBuffer); content: data.content,
await fs.writeFile(`${setting.shareFilesPath}\\${data.fileName}`, buffer, {}); centered: true,
setChangeImportModal(false) okText: '打开文件夹',
confirm({ cancelText: '关闭',
title: '提示', async onOk() {
icon: <ExclamationCircleFilled />, await fs.access(setting.shareFilesPath, fs.constants.F_OK);
content: data.content, if (process.platform === 'win32') {
centered: true, exec(`explorer "${setting.shareFilesPath}"`);
okText: '打开文件夹', } else if (process.platform === 'darwin') {
cancelText: '关闭', exec(`open "${setting.shareFilesPath}"`);
async onOk() {
await fs.access(setting.shareFilesPath, fs.constants.F_OK);
if (process.platform === 'win32') {
exec(`explorer "${setting.shareFilesPath}"`);
} else if (process.platform === 'darwin') {
exec(`open "${setting.shareFilesPath}"`);
}
},
onCancel() {
} }
}) },
} catch (error: any) { onCancel() {
if (error.code === 'ENOENT') {
message.error('文件夹不存在!')
return
} else {
message.error(error)
} }
})
} catch (error: any) {
if (error.code === 'ENOENT') {
message.error('文件夹不存在!')
return
} else {
message.error(error)
} }
} }
} }