diff options
author | 2021-07-09 22:50:20 +0200 | |
---|---|---|
committer | 2021-07-16 05:31:37 +0530 | |
commit | bfab760a279291a12b756f5b8624b2196d9ab1bb (patch) | |
tree | ae2a69d5e2d8c183152bedb828489b3fc4dc9c5b /src/components | |
parent | Minor perf tweaks to evaluate capturing of env-specific values only once in t... (diff) | |
download | ferdium-app-bfab760a279291a12b756f5b8624b2196d9ab1bb.tar.gz ferdium-app-bfab760a279291a12b756f5b8624b2196d9ab1bb.tar.zst ferdium-app-bfab760a279291a12b756f5b8624b2196d9ab1bb.zip |
Fix on the path format + function to recognize the OS
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/ui/ImageUpload.js | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/components/ui/ImageUpload.js b/src/components/ui/ImageUpload.js index 6a8c7645f..4151d871b 100644 --- a/src/components/ui/ImageUpload.js +++ b/src/components/ui/ImageUpload.js | |||
@@ -25,12 +25,24 @@ export default @observer class ImageUpload extends Component { | |||
25 | 25 | ||
26 | dropzoneRef = null; | 26 | dropzoneRef = null; |
27 | 27 | ||
28 | imgPath = null; | ||
29 | |||
28 | onDrop(acceptedFiles) { | 30 | onDrop(acceptedFiles) { |
29 | const { field } = this.props; | 31 | const { field } = this.props; |
30 | 32 | ||
31 | acceptedFiles.forEach((file) => { | 33 | acceptedFiles.forEach((file) => { |
34 | console.log(this.getOS()); | ||
35 | |||
36 | if(this.getOS() === "Windows"){ | ||
37 | this.imgPath = file.path.replace(/\\/g,"/"); | ||
38 | }else{ | ||
39 | this.imgPath = file.path; | ||
40 | } | ||
41 | |||
42 | console.log(this.imgPath); | ||
43 | |||
32 | this.setState({ | 44 | this.setState({ |
33 | path: file.path, | 45 | path: this.imgPath, |
34 | }); | 46 | }); |
35 | this.props.field.onDrop(file); | 47 | this.props.field.onDrop(file); |
36 | }); | 48 | }); |
@@ -38,6 +50,23 @@ export default @observer class ImageUpload extends Component { | |||
38 | field.set(''); | 50 | field.set(''); |
39 | } | 51 | } |
40 | 52 | ||
53 | getOS() { | ||
54 | var platform = window.navigator.platform, | ||
55 | macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], | ||
56 | windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'], | ||
57 | os = null; | ||
58 | |||
59 | if (macosPlatforms.indexOf(platform) !== -1) { | ||
60 | os = 'Mac OS'; | ||
61 | } else if (windowsPlatforms.indexOf(platform) !== -1) { | ||
62 | os = 'Windows'; | ||
63 | } else if (!os && /Linux/.test(platform)) { | ||
64 | os = 'Linux'; | ||
65 | } | ||
66 | |||
67 | return os; | ||
68 | } | ||
69 | |||
41 | render() { | 70 | render() { |
42 | const { | 71 | const { |
43 | field, className, multiple, textDelete, textUpload, | 72 | field, className, multiple, textDelete, textUpload, |