| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { getToken } from './token-util';
- import { TOKEN_HEADER_NAME } from '@/config/setting';
- // 获取图片反显url
- export function getImageUrl(path) {
- return `${sessionStorage.filePath}${path}`;
- // if (process.env.NODE_ENV === 'development') {
- // return `http://192.168.3.51:18086/main/file/getFile?${TOKEN_HEADER_NAME}=${getToken()}&objectName=${path}`;
- // } else {
- // return `${
- // sessionStorage.filePath
- // }${path}`;
- // }
- }
- // 从反显url上获取接口需要path
- export function getImagePath(url) {
- if(!url)return;
- let fileNames = url.split('/');
-
- return window.location.origin +
- '/api/main/file/getFile?objectName=' +
- url +
- '&fullfilename=' +
- fileNames[fileNames.length - 1];
- }
- // 下载方法
- export function download(data, name) {
- const a = document.createElement('a');
- const url = window.URL.createObjectURL(data);
- const filename = name;
- a.href = url;
- a.download = filename;
- a.click();
- window.URL.revokeObjectURL(url);
- }
- // 下载方法
- export function download1(url, name) {
- const a = document.createElement('a');
- const filename = name;
- a.href = url;
- a.download = filename;
- a.click();
- }
|