mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 05:59:34 +02:00
chore: result file name
This commit is contained in:
@@ -49,7 +49,8 @@ export default function ToolFileResult({
|
||||
|
||||
const handleDownload = () => {
|
||||
if (value) {
|
||||
const filename = 'output-omni-tools.' + extension;
|
||||
const hasExtension = value.name.includes('.');
|
||||
const filename = hasExtension ? value.name : `${value.name}.${extension}`;
|
||||
|
||||
const blob = new Blob([value], { type: value.type });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
|
@@ -1,16 +1,19 @@
|
||||
import { Box, TextField } from '@mui/material';
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
|
||||
import InputHeader from '../InputHeader';
|
||||
import ResultFooter from './ResultFooter';
|
||||
import { replaceSpecialCharacters } from '../../utils/string';
|
||||
import { replaceSpecialCharacters } from '@utils/string';
|
||||
import mime from 'mime';
|
||||
|
||||
export default function ToolTextResult({
|
||||
title = 'Result',
|
||||
value
|
||||
value,
|
||||
extension = 'txt'
|
||||
}: {
|
||||
title?: string;
|
||||
value: string;
|
||||
extension?: string;
|
||||
}) {
|
||||
const { showSnackBar } = useContext(CustomSnackBarContext);
|
||||
const handleCopy = () => {
|
||||
@@ -22,9 +25,13 @@ export default function ToolTextResult({
|
||||
});
|
||||
};
|
||||
const handleDownload = () => {
|
||||
const filename = 'output-omni-tools.txt';
|
||||
const filename = `output-omni-tools.${extension}`;
|
||||
|
||||
const blob = new Blob([value], { type: 'text/plain' });
|
||||
const mimeType = mime.getType(extension) || 'text/plain';
|
||||
|
||||
const blob = new Blob([value], {
|
||||
type: mimeType
|
||||
});
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
|
Reference in New Issue
Block a user