shared-ritm 1.3.71 → 1.3.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,38 @@
1
- export const saveBlobAsFile = (blob: Blob, name: string) => {
2
- try {
3
- const a = document.createElement('a')
4
- const url = window.URL.createObjectURL(blob)
5
-
6
- a.href = url
7
- a.download = name
8
-
9
- document.body.appendChild(a)
10
- a.click()
11
-
12
- setTimeout(function () {
13
- document.body.removeChild(a)
14
- window.URL.revokeObjectURL(url)
15
- }, 0)
16
- } catch (error) {
17
- console.error('Ошибка при загрузке файла:', error)
18
- }
19
- }
1
+ export function getFileFullPath(path: string): string {
2
+ if (!path) return ''
3
+ const middlePart = path.startsWith('/uploads') ? '' : '/uploads'
4
+ return process.env.VUE_APP_BACKEND_BASE + middlePart + path
5
+ }
6
+
7
+ export async function openFile(url: string) {
8
+ if (!url) return
9
+
10
+ try {
11
+ const tempLink = document.createElement('a')
12
+ tempLink.href = url
13
+ tempLink.setAttribute('target', '_blank')
14
+ tempLink.click()
15
+ } catch (err) {
16
+ console.error(err)
17
+ }
18
+ }
19
+
20
+ export const saveBlobAsFile = (blob: Blob, name: string) => {
21
+ try {
22
+ const a = document.createElement('a')
23
+ const url = window.URL.createObjectURL(blob)
24
+
25
+ a.href = url
26
+ a.download = name
27
+
28
+ document.body.appendChild(a)
29
+ a.click()
30
+
31
+ setTimeout(function () {
32
+ document.body.removeChild(a)
33
+ window.URL.revokeObjectURL(url)
34
+ }, 0)
35
+ } catch (error) {
36
+ console.error('Ошибка при загрузке файла:', error)
37
+ }
38
+ }