GitHub user jiderox added a comment to the discussion: 
/superset/language_pack/zh/

前端代码sdk嵌入
<template>
  <div class="amount-appeal-page">
    <div class="h-[70vh] border rounded shadow-lg">
      <div id="my-superset-container"></div>
    </div>
  </div>
</template>
<style>
#my-superset-container iframe {
  width: 100%;
  height: 100vh;
  border: 0;
  overflow: hidden;
}
</style>
<script>
import { embedDashboard } from '@superset-ui/embedded-sdk'
import { getAction } from '@/api/manage'
import { USER_INFO, USER_AUTH } from '@/store/mutation-types'
export default {
  data() {
    return {
      tabIndex: 'product_tag',
      info: {},
      dashboardId: '',
      dashboardUrl: ''
    }
  },
  async mounted() {
    await getAction('/sys/bi/superSet/getSupersetDomain/').then(res => {
      this.dashboardUrl = res.result
    })
    this.embedDashboardTabs()
  },
  methods: {
    async embedDashboardTabs() {
      await 
getAction(`/sys/bi/superSet/getResourceIdByResourceTag/${this.tabIndex}`).then(res
 => {
        this.dashboardId = res.result
      })
      console.log(this.dashboardUrl + '', 'this.dashboardUrl', 
this.dashboardId, 'this')
      embedDashboard({
        id: this.dashboardId, // given by the Superset embedding UI
        supersetDomain: this.dashboardUrl,
        mountPoint: document.getElementById('my-superset-container'), // any 
html element that can contain an iframe
        fetchGuestToken: () => this.fetchEmbedGuestToken(), // guest_token
        dashboardUiConfig: {
          hideTitle: true,
          hideTab: false,
          hideChartControls: false,
          filters: {
            expanded: true,
            visible: true
          } // dashboard UI config: hideTitle, hideTab, hideChartControls 
(optional)
        },
        initialBootstrapData: {
          common: { locale: 'zh' }
        },
        debug: true
      })
    },
    async fetchEmbedGuestToken() {
      return new Promise(resolve => {
        getAction('/sys/bi/superSet/fetchEmbedGuestToken/', {
          dashboardTag: this.tabIndex
        }).then(res => {
          if (res.success) {
            let token = res.result
            console.log('token: ' + token)
            resolve(token)
          }
        })
      })
    }
  }
}
</script>


GitHub link: 
https://github.com/apache/superset/discussions/35864#discussioncomment-14802495

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to