Browse Source

fix(nc-gui): export issue

pull/7704/head
աɨռɢӄաօռɢ 10 months ago
parent
commit
3da2128bc1
  1. 5
      packages/nc-gui/components/smartsheet/sidebar/toolbar/ExportCache.vue
  2. 7
      packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue
  3. 7
      packages/nc-gui/components/smartsheet/toolbar/MoreActions.vue

5
packages/nc-gui/components/smartsheet/sidebar/toolbar/ExportCache.vue

@ -1,4 +1,5 @@
<script setup lang="ts">
import { saveAs } from 'file-saver'
import { iconMap, message, useApi, useI18n } from '#imports'
const { t } = useI18n()
@ -6,8 +7,6 @@ const { t } = useI18n()
const { api } = useApi()
async function exportCache() {
const FileSaver = await import('file-saver')
try {
const data = await api.utils.cacheGet()
if (!data) {
@ -20,7 +19,7 @@ async function exportCache() {
type: 'text/plain;charset=utf-8',
})
FileSaver.saveAs(blob, 'cache_exported.json')
saveAs(blob, 'cache_exported.json')
// Exported Cache Successfully
message.info(t('msg.info.exportedCache'))

7
packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue

@ -1,6 +1,8 @@
<script setup lang="ts">
import type { RequestParams } from 'nocodb-sdk'
import { ExportTypes } from 'nocodb-sdk'
import { saveAs } from 'file-saver'
import * as XLSX from 'xlsx'
import {
ActiveViewInj,
FieldsInj,
@ -40,9 +42,6 @@ const exportFile = async (exportType: ExportTypes) => {
isExportingType.value = exportType
const XLSX = await import('xlsx')
const FileSaver = await import('file-saver')
try {
while (!isNaN(offset) && offset > -1) {
let res
@ -80,7 +79,7 @@ const exportFile = async (exportType: ExportTypes) => {
} else if (exportType === ExportTypes.CSV) {
const blob = new Blob([data], { type: 'text/plain;charset=utf-8' })
FileSaver.saveAs(blob, `${meta.value?.title}_exported_${c++}.csv`)
saveAs(blob, `${meta.value?.title}_exported_${c++}.csv`)
}
offset = +headers['nc-export-offset']

7
packages/nc-gui/components/smartsheet/toolbar/MoreActions.vue

@ -1,6 +1,8 @@
<script lang="ts" setup>
import type { RequestParams } from 'nocodb-sdk'
import { ExportTypes } from 'nocodb-sdk'
import { saveAs } from 'file-saver'
import * as XLSX from 'xlsx'
import {
ActiveViewInj,
FieldsInj,
@ -55,9 +57,6 @@ const exportFile = async (exportType: ExportTypes) => {
let c = 1
const responseType = exportType === ExportTypes.EXCEL ? 'base64' : 'blob'
const XLSX = await import('xlsx')
const FileSaver = await import('file-saver')
try {
while (!isNaN(offset) && offset > -1) {
let res
@ -87,7 +86,7 @@ const exportFile = async (exportType: ExportTypes) => {
XLSX.writeFile(workbook, `${meta.value?.title}_exported_${c++}.xlsx`)
} else if (exportType === ExportTypes.CSV) {
const blob = new Blob([data], { type: 'text/plain;charset=utf-8' })
FileSaver.saveAs(blob, `${meta.value?.title}_exported_${c++}.csv`)
saveAs(blob, `${meta.value?.title}_exported_${c++}.csv`)
}
offset = +headers['nc-export-offset']
if (offset > -1) {

Loading…
Cancel
Save