Browse Source

fix(gui-v2): $api in adapters

pull/2795/head
Wing-Kam Wong 2 years ago
parent
commit
76caddd6a4
  1. 7
      packages/nc-gui-v2/utils/parsers/ExcelUrlTemplateAdapter.ts
  2. 8
      packages/nc-gui-v2/utils/parsers/JSONUrlTemplateAdapter.ts

7
packages/nc-gui-v2/utils/parsers/ExcelUrlTemplateAdapter.ts

@ -1,19 +1,22 @@
import ExcelTemplateAdapter from './ExcelTemplateAdapter' import ExcelTemplateAdapter from './ExcelTemplateAdapter'
const { $api } = useNuxtApp() import { useNuxtApp } from '#imports'
export default class ExcelUrlTemplateAdapter extends ExcelTemplateAdapter { export default class ExcelUrlTemplateAdapter extends ExcelTemplateAdapter {
url: string url: string
excelData: any excelData: any
$api: any
constructor(url: string, parserConfig: Record<string, any>) { constructor(url: string, parserConfig: Record<string, any>) {
const { $api } = useNuxtApp()
const name = url.split('/').pop() const name = url.split('/').pop()
super(name, parserConfig) super(name, parserConfig)
this.url = url this.url = url
this.excelData = null this.excelData = null
this.$api = $api
} }
async init() { async init() {
const data: any = await $api.utils.axiosRequestMake({ const data: any = await this.$api.utils.axiosRequestMake({
apiMeta: { apiMeta: {
url: this.url, url: this.url,
}, },

8
packages/nc-gui-v2/utils/parsers/JSONUrlTemplateAdapter.ts

@ -1,16 +1,20 @@
import JSONTemplateAdapter from './JSONTemplateAdapter' import JSONTemplateAdapter from './JSONTemplateAdapter'
const { $api } = useNuxtApp() import { useNuxtApp } from '#imports'
export default class JSONUrlTemplateAdapter extends JSONTemplateAdapter { export default class JSONUrlTemplateAdapter extends JSONTemplateAdapter {
url: string url: string
$api: any
constructor(url: string, parserConfig: Record<string, any>) { constructor(url: string, parserConfig: Record<string, any>) {
const { $api } = useNuxtApp()
const name = url.split('/').pop() const name = url.split('/').pop()
super(name, parserConfig) super(name, parserConfig)
this.url = url this.url = url
this.$api = $api
} }
async init() { async init() {
const data = await $api.utils.axiosRequestMake({ const data = await this.$api.utils.axiosRequestMake({
apiMeta: { apiMeta: {
url: this.url, url: this.url,
}, },

Loading…
Cancel
Save