Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zyronon committed Mar 26, 2024
1 parent 7c262f4 commit 66733ef
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 47 deletions.
7 changes: 0 additions & 7 deletions src/api/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/api/user.js
Original file line number Diff line number Diff line change
@@ -1,14 1,5 @@
import request from "../utils/request";

export default {
friends(params, data) {
return request({url: '/user/friends', method: 'get', params, data})
},
author(params, data) {
return request({url: '/user/author', method: 'get', params, data})
},
}

export function userinfo(params, data) {
return request({url: '/user/userinfo', method: 'get', params, data})
}
Expand Down
20 changes: 10 additions & 10 deletions src/api/videos.js
Original file line number Diff line number Diff line change
@@ -1,15 1,15 @@
import request from "../utils/request";

export default {
recommended(params, data) {
return request({url: '/video/recommended', method: 'get', params, data})
},
historyVideo(params, data) {
return request({url: '/video/historyVideo', method: 'get', params, data})
},
historyOther(params, data) {
return request({url: '/video/historyOther', method: 'get', params, data})
},
export function historyOther(params, data) {
return request({url: '/video/historyOther', method: 'get', params, data})
}

export function historyVideo(params, data) {
return request({url: '/video/history', method: 'get', params, data})
}

export function recommendedVideo(params, data) {
return request({url: '/video/recommended', method: 'get', params, data})
}

export function myVideo(params, data) {
Expand Down
2 changes: 0 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,6 @@ import App from './App.vue'
import mitt from 'mitt'
import './assets/less/index.less'
import {startMock} from './mock'
import api from './api'
import router from "./router";
import store from "./store";
import mixin from "./utils/mixin";
Expand All @@ -17,7 16,6 @@ const pinia = createPinia()
const emitter = mitt()

const app = Vue.createApp(App)
app.config.globalProperties.$api = {...api}
app.config.globalProperties.emitter = emitter
app.config.unwrapInjectedRef = true
app.provide('mitt', emitter)
Expand Down
2 changes: 1 addition & 1 deletion src/mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 171,7 @@ export async function startMock() {
return [200, {data: v, code: 200}]
})

mock.onGet(/historyVideo/).reply(async (config) => {
mock.onGet(/video\/history/).reply(async (config) => {
let page = getPage2(config.params)
return [200, {
data: {
Expand Down
2 changes: 0 additions & 2 deletions src/pages/home/Attention.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 124,6 @@
import {onMounted, reactive} from "vue";
import {useNav} from "@/utils/hooks/useNav";
import api from "@/api";
import SlideList from "@/pages/home/slide/SlideList.vue";
import Utils, {$no} from "@/utils";
import Scroll from "@/components/Scroll.vue";
import goods from "@/assets/data/goods";
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/slide/LongVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 2,9 @@
import {computed, onMounted, onUnmounted, reactive, ref, watch} from "vue";
import {uniqueId} from "lodash-es";
import api from "@/api";
import {useStore} from "vuex";
import {_checkImgUrl, _duration, _formatNumber} from "@/utils";
import {recommendedVideo} from "@/api/videos";
const store = useStore()
const loading = computed(() => store.state.loading)
Expand Down Expand Up @@ -39,7 39,7 @@ function loadMore() {
async function getData(refresh = false) {
if (loading.value) return
store.commit('setLoading', true)
let res = await api.videos.recommended({pageNo: refresh ? 0 : state.pageNo, pageSize: state.pageSize})
let res = await recommendedVideo({pageNo: refresh ? 0 : state.pageNo, pageSize: state.pageSize})
console.log('getSlide4Data-', 'refresh', refresh, res)
store.commit('setLoading', false)
if (res.code === 200) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/slide/Slide0.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 47,7 @@
<SlideList
:active="props.active"
:style="{background: 'black',marginTop:state.subTypeVisible?state.subTypeHeight:0}"
:api="api.videos.recommended"
:api="recommendedVideo"
@touchstart="pageClick"
/>
</SlideItem>
Expand All @@ -58,8 58,8 @@ import SlideItem from '@/components/slide/SlideItem.vue'
import {onMounted, onUnmounted, reactive, ref} from "vue";
import bus, {EVENT_KEY} from "@/utils/bus";
import Utils from "@/utils";
import api from "@/api";
import SlideList from './SlideList.vue';
import {recommendedVideo} from "@/api/videos";
const props = defineProps({
cbs: {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/slide/Slide2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 17,7 @@
<SlideList
:active="props.active"
:style="{background: 'black',marginTop:state.subTypeVisible?state.subTypeHeight:0}"
:api="api.videos.recommended"
:api="recommendedVideo"
@touchstart="pageClick"
/>
</SlideItem>
Expand All @@ -28,8 28,8 @@ import SlideItem from '@/components/slide/SlideItem.vue'
import {onMounted, onUnmounted, reactive, ref} from "vue";
import bus, {EVENT_KEY} from "@/utils/bus";
import Utils from "@/utils";
import api from "@/api";
import SlideList from './SlideList.vue';
import {recommendedVideo} from "@/api/videos";
const props = defineProps({
active: {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/slide/Slide4.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 3,15 @@
<SlideList
style="background:#000;"
:active="props.active"
:api="api.videos.recommended"
:api="recommendedVideo"
/>
</SlideItem>
</template>

<script setup lang="jsx">
import SlideItem from '@/components/slide/SlideItem.vue'
import api from "@/api";
import SlideList from './SlideList.vue';
import {recommendedVideo} from "@/api/videos";
const props = defineProps({
active: {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/me/rightMenu/LookHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 45,7 @@
import Posters from "../../../components/Posters";
import Scroll from "../../../components/Scroll";
import NoMore from "../../../components/NoMore";
import {historyOther, historyVideo} from "@/api/videos";
export default {
name: "lookHistory",
Expand Down Expand Up @@ -94,7 95,7 @@ export default {
this.historyVideo.pageNo
}
this.loadingVideo = true
let res = await this.$api.videos.historyVideo({pageNo: this.historyVideo.pageNo, pageSize: this.pageSize,})
let res = await historyVideo({pageNo: this.historyVideo.pageNo, pageSize: this.pageSize,})
console.log(res)
this.loadingVideo = false
if (res.code === this.SUCCESS) {
Expand All @@ -109,7 110,7 @@ export default {
if (!init) {
this.historyOther.pageNo
}
let res = await this.$api.videos.historyOther({pageNo: this.historyOther.pageNo, pageSize: this.pageSize,})
let res = await historyOther({pageNo: this.historyOther.pageNo, pageSize: this.pageSize,})
this.loadingOther = false
if (res.code === this.SUCCESS) {
this.historyOther.list = this.historyOther.list.concat(res.data.list)
Expand Down
3 changes: 2 additions & 1 deletion src/pages/message/JoinedGroupChat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 35,7 @@ import {mapState} from "vuex";
import axios from "axios";
import Check from "../../components/Check";
import {forIn} from "lodash-es";
import {friends} from "@/api/user";
export default {
name: "Share2Friend",
Expand Down Expand Up @@ -72,7 73,7 @@ export default {
}
},
async getFriends() {
let res = await this.$api.user.friends()
let res = await friends()
if (res.code === this.SUCCESS) {
this.friends = res.data
this.friends.all = this.friends.all.sort((a, b) => {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/message/Share2Friend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 144,7 @@ import {mapState} from "vuex";
import axios from "axios";
import Check from "../../components/Check";
import {forIn} from "lodash-es";
import {friends} from "@/api/user";
export default {
name: "Share2Friend",
Expand Down Expand Up @@ -271,7 272,7 @@ export default {
}
},
async getFriends() {
let res = await this.$api.user.friends()
let res = await friends()
console.log('getFriends', res)
if (res.code === this.SUCCESS) {
this.friends = res.data
Expand Down
2 changes: 0 additions & 2 deletions src/pages/shop/Shop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 120,6 @@
import {onMounted, reactive} from "vue";
import {useNav} from "@/utils/hooks/useNav";
import api from "@/api";
import SlideList from "@/pages/home/slide/SlideList.vue";
import Utils, {$no} from "@/utils";
import Scroll from "@/components/Scroll.vue";
import goods from "@/assets/data/goods";
Expand Down
4 changes: 2 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,8 1,8 @@
import * as Vuex from "vuex";
import enums from '../utils/enums'
import api from '../api/index'
import CONST_VAR from "../utils/const_var";
import resource from "../assets/data/resource";
import {friends} from "@/api/user";

const store = Vuex.createStore({
state: {
Expand Down Expand Up @@ -79,7 79,7 @@ const store = Vuex.createStore({
},
actions: {
async getFriends(context) {
let res = await api.user.friends()
let res = await friends()
if (res.code === CONST_VAR.SUCCESS) {
context.commit('setFriends', res.data)
}
Expand Down

0 comments on commit 66733ef

Please sign in to comment.