wujingjing
2024-08-26 a2595cdfc4a8ee55220585119bcb39fdd29da6b1
src/components/amis/AMISRenderer.vue
@@ -1,19 +1,20 @@
<template><div>Loading...</div></template>
<template><div>加载中...</div></template>
<script>
import 'amis/sdk/sdk.js';
import 'amis/sdk/sdk.css';
import 'amis/sdk/iconfont.css';
<script lang="ts">
// import '/static/sdk/sdk.js';
// import '/static/sdk/sdk.css';
// import '/static/sdk/iconfont.css';
import { accessSessionKey, handleNoAuth } from '/@/utils/request';
import { NO_AUTH_API_LIST } from '/@/api/ai/chat';
import { LOGIN_URL, TEL_LOGIN_URL } from '/@/api/ai/user';
import { MAIN_URL } from '/@/constants';
import router from '/@/router/index';
import { Local } from '/@/utils/storage';
// 可以不引用, 如果你不想要任何辅助类样式的话 (比如 `m-t-xs` 这种)
// https://aisuda.bce.baidu.com/amis/zh-CN/style/index
import 'amis/sdk/helper.css';
// import 'amis/sdk/helper.css';
import qs from 'qs';
function loadScript(src, callback) {
@@ -41,8 +42,8 @@
         resolve();
         return;
      }
      loadStyles(['/amis/sdk/sdk.css', '/amis/sdk/helper.css', '/amis/sdk/iconfont.css']);
      loadScript('/amis/sdk/sdk.js', (err) => {
      loadStyles(['/static/amis/sdk/sdk.css', '/static/amis/sdk/helper.css', '/static/amis/sdk/iconfont.css']);
      loadScript('/static/amis/sdk/sdk.js', (err) => {
         if (err) {
            reject(err);
            return;
@@ -77,7 +78,6 @@
      },
   },
   data() {
      const router = this.$router;
      return {
         // 这里面的数据所有 amis 页面都可以获取到
         // 可以用来放一下公共数据,比如用户信息等
@@ -86,12 +86,12 @@
            siteName: 'AMIS DEMO',
         },
         get location() {
            const current = router?.history?.current;
            const current = router.currentRoute.value;
            return {
               pathname: current?.path,
               hash: current?.hash,
               query: current?.query,
               search: `?a=23`,
               search: `?${qs.stringify(current.query)}`,
            };
            // return 'localtion'
         },
@@ -125,7 +125,6 @@
      const scoped = amisRequire('amis/embed');
      const { normalizeLink } = amisRequire('amis');
      const router = this.$router;
      const instance = scoped.embed(
         this.$el,
         this.schema,
@@ -165,8 +164,12 @@
            // 覆盖 amis env
            // 参考 https://aisuda.bce.baidu.com/amis/zh-CN/docs/start/getting-started#sdk
            jumpTo: (to, action) => {
               return;
               console.log("🚀 ~ to:", to)
               console.log("🚀 ~ action:", action)
               if (to === 'goBack') {
                  return router.go(-1);
               }
               to = normalizeLink(to, this.location);
@@ -190,6 +193,10 @@
            },
            updateLocation: (location, replace) => {
               // 禁止跳转
               return;
               console.log("🚀 ~ location:", location)
               console.log("🚀 ~ replace:", replace)
               if (location === 'goBack') {
                  return router.go(-1);
               }