| | |
| | | <script setup> |
| | | import { ref, computed, watch, onMounted, onUnmounted, nextTick } from 'vue'; |
| | | import { getToken } from "@/utils/auth"; |
| | | import config from '@/config.js'; |
| | | |
| | | // Props 定义 |
| | | const props = defineProps({ |
| | |
| | | |
| | | // 计算属性 |
| | | const uploadFileUrl = computed(() => { |
| | | // 获取基础API地址,适配uniapp环境 |
| | | let baseUrl = ''; |
| | | |
| | | // 尝试多种方式获取baseUrl |
| | | if (process.env.VUE_APP_BASE_API) { |
| | | baseUrl = process.env.VUE_APP_BASE_API; |
| | | } else if (process.env.NODE_ENV === 'development') { |
| | | baseUrl = 'http://192.168.1.147:9036'; |
| | | } else { |
| | | baseUrl = 'http://192.168.1.147:9036'; |
| | | } |
| | | |
| | | // 获取基础API地址,优先使用 config.js 中的 baseUrl |
| | | const baseUrl = config.baseUrl || process.env.VUE_APP_BASE_API || 'http://192.168.1.147:7016'; |
| | | const fullUrl = baseUrl + props.action; |
| | | console.log('上传URL:', fullUrl); |
| | | return fullUrl; |
| | | }); |
| | | const headers = computed(() => { |