Compass helpers for browser platforms
    Preparing search index...

    Function downloadFile

    • Parameters

      Returns Promise<DownloadResult>

      Promise

      主要的文件下载函数

      // 基本使用
      await downloadFile('Hello World', { filename: 'hello.txt' });

      // 下载 JSON 数据
      await downloadFile({ name: 'test', value: 123 }, {
      filename: 'data.json',
      addTimestamp: true
      });

      // 下载二进制数据
      const buffer = new ArrayBuffer(1024);
      await downloadFile(buffer, {
      filename: 'binary.dat',
      blobOptions: { type: 'application/octet-stream' }
      });

      // 带确认和回调
      await downloadFile(csvData, {
      filename: 'export.csv',
      showConfirm: true,
      confirmMessage: '确定要下载这个 CSV 文件吗?',
      onSuccess: () => console.log('下载成功'),
      onError: (error) => console.error('下载失败:', error)
      });