feat: 创建了请求的接口

This commit is contained in:
zoujing
2026-04-02 16:46:09 +08:00
parent 2152029562
commit b2ca694fbd
7 changed files with 47 additions and 18 deletions

View File

@@ -7,11 +7,14 @@
</template>
<script setup>
import { Session } from '@utils/storage'
const router = useRouter()
const KeepAliveList = ref([])
router.beforeEach((to, from, next) => {
const keepAlive = to?.meta?.keepAlive
Session.set('token', to.query.token)
if (!router.hasRoute(to.name)) {
router.push('/home')

View File

@@ -0,0 +1,11 @@
/* eslint-disable */
// @ts-ignore
import request from '@common/ajax';
export const getAigcSceneList = (params: any) => {
return request({
url: '/aigc/aigcSceneList',
method: 'get',
params,
});
};

View File

3
src/api/index.ts Normal file
View File

@@ -0,0 +1,3 @@
/* eslint-disable */
// @ts-ignore
export * from './AigcSceneListApi';

View File

@@ -18,7 +18,8 @@ const instance = axios.create({
// 添加拦截器
instance.interceptors.request.use((config) => {
const token = Session.getToken()
// const token = Session.getToken()
const token = '0ng6bSau9IwBXmyfzgMCARAMdq_fRWg6D07Y9mmjIyZNGVUrmjCjw2s5_7UcYJNB2WBLEESPROkprEEjfD6HP4Lk-W-rPLISjcJPZCLCFJyEZyCoOHN-71m0C7kG7qqz'
config.headers['Authorization'] = `Bearer ${token}`
// get请求映射params参数

View File

@@ -48,11 +48,12 @@
</template>
<script setup>
import { ref, computed } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import TopNavBar from '../components/TopNavBar.vue';
import PhotoGuide from '../components/PhotoGuide.vue';
import AgreementTip from '../components/AgreementTip.vue';
import { getAigcSceneList } from '@api';
// --- 测试数据 ---
const styles = [
@@ -126,6 +127,18 @@ const handleStyleChange = (id) => {
activeStyleId.value = id;
activeSceneIndex.value = 0;
};
// 数据请求
const fetchSceneList = async () => {
// 这里可以替换成真实的 API 请求
const response = await getAigcSceneList();
// mockData[activeStyleId.value] = response.data.scenes;
};
onMounted(() => {
fetchSceneList();
});
</script>
<style scoped>