generated from duanshuwen/webapp-vue-frontend
feat: 创建了请求的接口
This commit is contained in:
@@ -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')
|
||||
|
||||
11
src/api/AigcSceneListApi.ts
Normal file
11
src/api/AigcSceneListApi.ts
Normal 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,
|
||||
});
|
||||
};
|
||||
3
src/api/index.ts
Normal file
3
src/api/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
export * from './AigcSceneListApi';
|
||||
@@ -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参数
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user