resource.pipe.ts 833 Bytes
Newer Older
范雪寒's avatar
范雪寒 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
import {Pipe, PipeTransform} from '@angular/core';
// import {ElectronUtil} from '../util/ElectronUtil';

declare const APP_PATH;
// const isInElectron = localStorage.getItem('electron');

@Pipe({
  name: 'resource'
})
export class ResourcePipe implements PipeTransform {

  transform(pic_url: any, coursewareSid?: string): string {
    // return pic_url;
    if (pic_url &&  typeof pic_url === 'object') {
      return pic_url;
    }
    // console.log('resource', pic_url)
    return `${pic_url}?t=${Math.random()}`;

    // let ret = value ? `/api/resource/${value}/file` : '';
    // let ret = res_id ? `/resource/audio/${res_id}` : '';
    // if (isInElectron && ElectronUtil.hasCached(coursewareSid, res_id)) {
    //   ret = `file://${APP_PATH}/courseware_cache/${coursewareSid}/${res_id}`;
    // }
    // return ret;
  }

}