fix: sharex DestinationType
This commit is contained in:
parent
59b3e5bb24
commit
4e27efb6a1
1 changed files with 22 additions and 35 deletions
|
@ -1,11 +1,12 @@
|
|||
import { useState } from 'react';
|
||||
import { useReducer, useState } from 'react';
|
||||
import { GeneratorModal } from './GeneratorModal';
|
||||
|
||||
export default function ShareX({ user, open, setOpen }) {
|
||||
const [config, setConfig] = useState({
|
||||
const onSubmit = (values) => {
|
||||
const config = {
|
||||
Version: '14.1.0',
|
||||
Name: 'Zipline',
|
||||
DestinationType: 'ImageUploader, TextUploader',
|
||||
DestinationType: 'ImageUploader, TextUploader, FileUploader',
|
||||
RequestMethod: 'POST',
|
||||
RequestURL: `${
|
||||
window.location.protocol +
|
||||
|
@ -20,9 +21,8 @@ export default function ShareX({ user, open, setOpen }) {
|
|||
Body: 'MultipartFormData',
|
||||
FileFormName: 'file',
|
||||
Data: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = (values) => {
|
||||
if (values.type === 'shorten-url') {
|
||||
config.RequestURL = `${
|
||||
window.location.protocol +
|
||||
|
@ -32,62 +32,49 @@ export default function ShareX({ user, open, setOpen }) {
|
|||
}/api/shorten`;
|
||||
config.URL = '$json:url$';
|
||||
config.Body = 'JSON';
|
||||
config.DestinationType = 'URLShortener';
|
||||
delete config.FileFormName;
|
||||
config.Data = JSON.stringify({ url: '{input}' });
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Data;
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
if (values.format !== 'RANDOM' && values.type === 'upload-file') {
|
||||
config.Headers['Format'] = values.format;
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Headers['Format'];
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
if (values.imageCompression !== 0 && values.type === 'upload-file') {
|
||||
config.Headers['Image-Compression-Percent'] = values.imageCompression;
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Headers['Image-Compression-Percent'];
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
if (values.zeroWidthSpace) {
|
||||
config.Headers['Zws'] = 'true';
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Headers['Zws'];
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
if (values.embed && values.type === 'upload-file') {
|
||||
config.Headers['Embed'] = 'true';
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Headers['Embed'];
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
if (values.noJSON) {
|
||||
config.URL = '{response}';
|
||||
config.Headers['No-JSON'] = 'true';
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Headers['No-JSON'];
|
||||
config.URL = values.type === 'upload-file' ? '$json:files[0]$' : '$json:url$';
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
if (values.originalName && values.type === 'upload-file') {
|
||||
config.Headers['Original-Name'] = 'true';
|
||||
setConfig(config);
|
||||
} else {
|
||||
delete config.Headers['Original-Name'];
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
const pseudoElement = document.createElement('a');
|
||||
|
|
Loading…
Reference in a new issue