From 589e356f61436d136347411db074125681685958 Mon Sep 17 00:00:00 2001 From: King Zioywishing <539943419@qq.com> Date: Tue, 9 Jul 2024 16:41:48 +0800 Subject: [PATCH] =?UTF-8?q?update:24-07-09=2016:41:47=20-remark:=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=B7=BB=E5=8A=A0=E6=96=B0=E9=A1=B5=E9=9D=A2=E7=AC=94?= =?UTF-8?q?=E8=AE=B0=20-AutoCommit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aboutAETV.md | 312 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 184 insertions(+), 128 deletions(-) diff --git a/aboutAETV.md b/aboutAETV.md index 9b730f5..345400a 100644 --- a/aboutAETV.md +++ b/aboutAETV.md @@ -1,146 +1,202 @@ # 与星网项目相关 +* 如何去添加一个新的页面(addTabPage) + 可参考以下部分添加内容(部分文件、文件夹自行创建): + frame\frame.config.js + ```js + // PAGES,appreciation + singReplay: { + entry: 'frame/singReplay/main.ts', + template: 'frame/pages/index.html', + filename: 'singReplay.html', + title: '回放', + minify: true + }, + ``` + frame\singReplay\main.ts + ```ts + import SingReplay from '@/pages/singReplay/index.vue' + import exception from '@/plugins/exception' + import store from '@/store' + import logger from '@evideo/logger' + import { createApp } from 'vue' + + Promise.resolve() + .then(() => { + logger.setNamespace('singReplay') + }) + .then(() => { + const app = createApp(SingReplay) + app.use(store).use(exception) + app.mount('#app') + }) + ``` + src\hooks\useAddTabsPage.ts + ```ts + const goToSingReplay = _.debounce( + (data: any, pageId?: string) => { + const url = `${window.location.origin}/singReplay.html?id=${data.id}` + const webPage: IWebPage = { + name: `${data.name}`, + url: url, + data, + pageId + } + addTabPage(webPage) + }, + 300, + { leading: true, trailing: false } + ) + ``` +--- * apiFetch用法 -首先要在```@/services/api```中配置api,具体形式参考以下 -``` ts - getStudentRecords: { - remark: '获取学生录音列表', - url: '/teacher/student-records', - method: 'get', - baseURL: ApiServices.User, - apiServiceOption: { - // 这里对后端接口发来的数据进行预处理。 - afterResponse - } - }, - setStudentRecordStatus: { - remark: '设置学生录音状态(是否隐藏)', - url: '/teacher/student-records/{id}/setStatus', - method: 'post', - baseURL: ApiServices.User - }, -``` -然后在代码中使用可参考如下 -```ts -import useFetchApi from '@/hooks/useFetchApi' -import api from '@/services/api' -const { fetchApi } = useFetchApi() -const _api = api.Replay.setTeacherRecordStatus -const _id = props.cardData.originData.id -// 用法类似axios -const result: any = await fetchApi( - _api, - { - // body - data: { - status: 0 - } - }, - { matchUrl: { id: _id } } -) -if (result?.message !== 'success') { - throw result?.message -} -// result结果会自动json解析,如{message:'success'...} + 首先要在```@/services/api```中配置api,具体形式参考以下 + ``` ts + getStudentRecords: { + remark: '获取学生录音列表', + url: '/teacher/student-records', + method: 'get', + baseURL: ApiServices.User, + apiServiceOption: { + // 这里对后端接口发来的数据进行预处理。 + afterResponse + } + }, + setStudentRecordStatus: { + remark: '设置学生录音状态(是否隐藏)', + url: '/teacher/student-records/{id}/setStatus', + method: 'post', + baseURL: ApiServices.User + }, + ``` + 然后在代码中使用可参考如下 + ```ts + import useFetchApi from '@/hooks/useFetchApi' + import api from '@/services/api' -``` + const { fetchApi } = useFetchApi() + const _api = api.Replay.setTeacherRecordStatus + const _id = props.cardData.originData.id + // 用法类似axios + const result: any = await fetchApi( + _api, + { + // body + data: { + status: 0 + } + }, + { matchUrl: { id: _id } } + ) + if (result?.message !== 'success') { + throw result?.message + } + // result结果会自动json解析,如{message:'success'...} + + ``` + 然后就可以在项目中以如下方式进行调用: + ```ts + const { goToSingReplay } = useAddTabsPage() + // 传参 + goToSingReplay(data) + ``` --- * apiFetch之结果预处理: -代码可参考以下: -```ts -const afterResponse = (res: any) => { - let _res = { ...res } - res.data = { - data: { - items: _res.data.data, - meta: _res.data.meta + + 代码可参考以下: + ```ts + const afterResponse = (res: any) => { + let _res = { ...res } + res.data = { + data: { + items: _res.data.data, + meta: _res.data.meta + } } + _res = null + return res } - _res = null - return res -} -const Replay: { [key: string]: ApiConfOption } = { - getStudentRecords: { - remark: '获取学生录音列表', - url: '/teacher/student-records', - method: 'get', - baseURL: ApiServices.User, - apiServiceOption: { - // 这里对后端接口发来的数据进行预处理。 - afterResponse - } - }, -} -``` + const Replay: { [key: string]: ApiConfOption } = { + getStudentRecords: { + remark: '获取学生录音列表', + url: '/teacher/student-records', + method: 'get', + baseURL: ApiServices.User, + apiServiceOption: { + // 这里对后端接口发来的数据进行预处理。 + afterResponse + } + }, + } + ``` --- * TabList用法 -```html - -``` -导入 -```ts -import TabList from '@/components/tabList.vue' -``` -其中tabs的格式如下 -```ts -const tabs = ref([ - { - label: '教师作品', - value: 'teacherWorks' - } -]) -``` -作用为生成一个标签页 + + ```html + + ``` + 导入 + ```ts + import TabList from '@/components/tabList.vue' + ``` + 其中tabs的格式如下 + ```ts + const tabs = ref([ + { + label: '教师作品', + value: 'teacherWorks' + } + ]) + ``` + 作用为生成一个标签页 --- * ScrollLoad用法 -```html - - - - - - - - -``` -其中scrollLoadProps的参数为如下 -```ts -const scrollLoadProps = computed(() => { - return { - apiConf: api.something, - matchData: '@data.items@', - params: {} - } -}) -``` -具体为到底时使用传入的api请求一组数据,然后传回的data可以通过fetchEnd或是default插槽进行处理,有时候需要对传回的数据进行预处理才不会报错(因为后端的数据格式可能不会对上scroolList的格式) ---- -# 接口使用相关 + ```html + + + + + + + + + ``` + 其中scrollLoadProps的参数为如下 + ```ts + const scrollLoadProps = computed(() => { + return { + apiConf: api.something, + matchData: '@data.items@', + params: {} + } + }) + ``` + 具体为到底时使用传入的api请求一组数据,然后传回的data可以通过fetchEnd或是default插槽进行处理,有时候需要对传回的数据进行预处理才不会报错(因为后端的数据格式可能不会对上scroolList的格式) \ No newline at end of file