wujingjing
2024-11-11 cfdc37f5b480377a44955f429a6e610d3c474090
src/components/amis/AMISRenderer.vue
@@ -12,6 +12,8 @@
import { NO_AUTH_API_LIST } from '/@/api/ai/chat';
import { LOGIN_URL, TEL_LOGIN_URL } from '/@/api/ai/user';
import { Local } from '/@/utils/storage';
import { isSharePage } from '/@/stores/chatRoom';
const amisRootRef = ref<HTMLDivElement>(null);
const props = defineProps({
@@ -23,6 +25,10 @@
      }),
   },
   locals: {
      type: Object,
      default: () => ({}),
   },
   context:{
      type: Object,
      default: () => ({}),
   },
@@ -67,9 +73,7 @@
   });
}
const context = reactive({
   siteName: 'AMIS DEMO',
});
const current = router.currentRoute.value;
const location = {
@@ -86,9 +90,9 @@
const updateProps = () => {
   amisInstance.value?.updateProps({
      data: {
         ...props.locals,
         // ...props.locals,
      },
      context: context,
      context: props.context,
      ...props.props,
   });
};
@@ -127,9 +131,9 @@
      props.schema,
      {
         data: {
            ...props.locals,
            // ...props.locals,
         },
         context: context,
         context: props.context,
         location: location,
         // todo 下发 location 对象
@@ -142,7 +146,7 @@
            // api.context 中包含发送请求前的上下文信息
            // 获取本地的 token
            const accessSession = Local.get(accessSessionKey);
            if (!NO_AUTH_API_LIST.includes(api.url)) {
            if (!NO_AUTH_API_LIST.includes(api.url) && !isSharePage.value) {
               if (accessSession) {
                  // 将 token 添加到请求报文头中
                  api.headers['hswatersession'] = accessSession;