From 0b5aecfe65af9d8afb3e7e478b21157dd1b2cf43 Mon Sep 17 00:00:00 2001 From: SG <93599358+HardenSG@users.noreply.github.com> Date: Thu, 9 May 2024 01:14:03 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20=E6=96=B0=E5=A2=9E=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E3=80=81=E6=B5=B7=E6=8A=A5=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=88=86=E4=BA=AB=20&=20=E4=BF=AE=E6=94=B9storage=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=8E=A8=E6=96=AD"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.tsx | 3 +- src/common-model.ts | 2 +- .../baseBuiltComp/FORBIDDEN/index.module.scss | 11 +- .../baseBuiltComp/FORBIDDEN/index.tsx | 23 +- .../baseBuiltComp/HocWrap/index.tsx | 4 +- .../baseBuiltComp/Loading/index.module.scss | 4 +- src/config.ts | 1 + src/hooks/useRequest.ts | 2 - src/pages/Detail/components/Poster.tsx | 107 -------- src/pages/Detail/components/poster.scss | 15 -- src/pages/Detail/index.config.ts | 2 +- src/pages/Detail/index.module.scss | 149 ----------- src/pages/Detail/index.tsx | 235 +++++++----------- .../Index/components/Tasklist/task-item.tsx | 11 +- .../Index/components/Tasklist/task-list.tsx | 89 +++---- src/pages/main/Index/types.ts | 12 +- src/pages/main/Manage/Publish/index.config.ts | 10 + .../Manage/Publish/index.module.scss} | 0 src/pages/main/Manage/Publish/index.tsx | 7 + .../main/Manage/components/apple.modules.scss | 0 .../main/Manage/components/apply-manage.tsx | 15 -- .../main/Manage/components/work-manage.tsx | 10 - .../main/Manage/components/work.modules.scss | 0 src/pages/main/Manage/index.config.ts | 4 +- src/pages/main/Manage/index.module.scss | 65 ----- src/pages/main/Manage/index.tsx | 44 +--- src/static/SVG/lottie-map.ts | 34 +-- src/utils/perfTrack/business.ts | 36 +-- src/utils/request/Result.ts | 10 +- src/utils/request/business.ts | 23 +- src/utils/request/request.ts | 2 +- src/utils/route/constants.ts | 2 + src/utils/storage.ts | 8 +- src/utils/subscribe.ts | 4 +- src/utils/types/entity/index.ts | 1 - src/utils/types/entity/task.ts | 22 -- src/utils/types/index.ts | 1 - 37 files changed, 229 insertions(+), 739 deletions(-) delete mode 100644 src/pages/Detail/components/Poster.tsx delete mode 100644 src/pages/Detail/components/poster.scss create mode 100644 src/pages/main/Manage/Publish/index.config.ts rename src/pages/{Detail/types.ts => main/Manage/Publish/index.module.scss} (100%) create mode 100644 src/pages/main/Manage/Publish/index.tsx delete mode 100644 src/pages/main/Manage/components/apple.modules.scss delete mode 100644 src/pages/main/Manage/components/apply-manage.tsx delete mode 100644 src/pages/main/Manage/components/work-manage.tsx delete mode 100644 src/pages/main/Manage/components/work.modules.scss delete mode 100644 src/utils/types/entity/index.ts delete mode 100644 src/utils/types/entity/task.ts diff --git a/src/app.tsx b/src/app.tsx index ab38461..1b48ab1 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,6 +4,7 @@ import Error from 'src/components/baseBuiltComp/Error' import { store } from './store' import './app.scss' import { Get, getStorage, preloadResource, requestUrlCreator } from './utils' +import { IUserInfo } from './common-model' import { JSON_MAP } from './static/SVG/lottie-map' function App(props) { @@ -14,7 +15,7 @@ function App(props) { useLaunch(async () => { /** 1. 校验登陆态 */ - const token = getStorage('userInfo')?.token + const token = getStorage('userInfo')?.token /** 2. 校验获取用户信息 */ /** TODO: 需和后端确定响应体 */ diff --git a/src/common-model.ts b/src/common-model.ts index bff23c5..0a93207 100644 --- a/src/common-model.ts +++ b/src/common-model.ts @@ -35,7 +35,7 @@ export interface ICommonState { /** 默认store值 从storage中激活 */ export const defaultValue: ICommonState = { - userInfo: getStorage('userInfo') || {}, + userInfo: getStorage('userInfo') || {}, system: { coolStartSuccess: false, hasAccountCompleted: false, diff --git a/src/components/baseBuiltComp/FORBIDDEN/index.module.scss b/src/components/baseBuiltComp/FORBIDDEN/index.module.scss index 8d865c4..41881a1 100644 --- a/src/components/baseBuiltComp/FORBIDDEN/index.module.scss +++ b/src/components/baseBuiltComp/FORBIDDEN/index.module.scss @@ -5,8 +5,8 @@ flex-direction: column; justify-content: center; align-items: center; - width: 100%; - height: 100%; + width: 100vw; + height: 100vh; &__bgContainer { position: relative; @@ -16,8 +16,8 @@ height: 70%; align-items: center; - &__canvas { - } + + &__canvas {} &__title { text-align: center; @@ -27,4 +27,5 @@ color: $base-element-color; } } -} + +} \ No newline at end of file diff --git a/src/components/baseBuiltComp/FORBIDDEN/index.tsx b/src/components/baseBuiltComp/FORBIDDEN/index.tsx index 4a06527..5aabfae 100644 --- a/src/components/baseBuiltComp/FORBIDDEN/index.tsx +++ b/src/components/baseBuiltComp/FORBIDDEN/index.tsx @@ -1,31 +1,22 @@ import { Button, Canvas, CoverView, View } from '@tarojs/components' -import { $, URL, goTo } from 'src/utils' +import { $ } from 'src/utils' import useAnimation from 'src/hooks/useAnimation' import { JSON_MAP } from 'src/static/SVG/lottie-map' -import { useCallback, useEffect } from 'react' +import { useEffect } from 'react' import './index.module.scss' -const Index = (props) => { +const Index = () => { const { run, instance } = useAnimation({ node: $('#ForbiddenContainer__bgContainer__canvas'), template: JSON_MAP['forbidden'], isAutoRun: false, }) - - const goToIndex = useCallback(() => { - goTo({ - url: URL.Index, - methodType: 'reLaunch', - options: { authorize: false }, - }) - }, []) - useEffect(() => { run() // setTimeout(() => { // instance?.pause() // }, 4000); - }, [instance, run]) + }, [instance]) return ( @@ -37,11 +28,7 @@ const Index = (props) => { SRY 你没有权限访问该页面 - {props.children ? ( - - ) : ( - - )} + ) diff --git a/src/components/baseBuiltComp/HocWrap/index.tsx b/src/components/baseBuiltComp/HocWrap/index.tsx index 0e8860f..e9ca49a 100644 --- a/src/components/baseBuiltComp/HocWrap/index.tsx +++ b/src/components/baseBuiltComp/HocWrap/index.tsx @@ -21,14 +21,14 @@ export const Authorize = (Component) => { } /** @HOC 禁止页面要求必须是已授权的 */ -export const Forbidden = (Component, props?: any) => { +export const Forbidden = (Component) => { return React.memo(() => { const state = useSelector((root: RootState) => root.common) if (!state.system.coolStartSuccess) { return } else { if (state.userInfo.isBindManage) return - return {props} + return } }) } diff --git a/src/components/baseBuiltComp/Loading/index.module.scss b/src/components/baseBuiltComp/Loading/index.module.scss index 86bcefd..6935166 100644 --- a/src/components/baseBuiltComp/Loading/index.module.scss +++ b/src/components/baseBuiltComp/Loading/index.module.scss @@ -14,10 +14,10 @@ align-items: center; width: 100%; height: 100%; - z-index: 1000; &__canvas { width: 100%; // height: 40%; } -} + +} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 0696267..88062e9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,6 +6,7 @@ export const config: Config = { 'pages/main/Index/index', 'pages/main/Calendar/index', 'pages/main/Manage/index', + 'pages/main/Manage/Publish/index', 'pages/main/My/index', // 'pages/Detail/index', // 'pages/Initial/index', diff --git a/src/hooks/useRequest.ts b/src/hooks/useRequest.ts index 3a312e9..454e223 100644 --- a/src/hooks/useRequest.ts +++ b/src/hooks/useRequest.ts @@ -71,8 +71,6 @@ const useRequest = (requestFn: TRequestFn, options?: TRequestOptions) => { /** 请求开始 */ PerfTackerInstance.requestBegin() res = await fn({ url, data: req, silent }) - console.log(res.extraData?.count) - /* __PURE__ */ console.log(' === 响应返回 === ', res) /** 校验是否成功 */ diff --git a/src/pages/Detail/components/Poster.tsx b/src/pages/Detail/components/Poster.tsx deleted file mode 100644 index 453fe72..0000000 --- a/src/pages/Detail/components/Poster.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import React, { useRef, FC, useCallback, useState } from 'react' -import { pxTransform } from '@tarojs/taro' -import { PosterRender, PosterRenderRef } from '@poster-render/taro-react' -import { View } from '@tarojs/components' -import Button from '@taroify/core/button/button' -import { TTaskItem, getStorage, showToast, trackJsError } from 'src/utils' -import './poster.scss' - -const lists = (data: TTaskItem) => [ - { - type: 'image', - x: 0, - y: 0, - width: 540, - height: 960, - backgroundColor: 'black', - src: 'https://hx.404fwf.cn/notifyBoard/img/backposter.png', - mode: 'contain', - }, - { - type: 'text', - textAlign: 'center', - x: 270, - y: 340, - lineNum: 3, - width: 350, - height: 30, - text: data.title, - color: 'black', - fontSize: 30, - baseLine: 'top', - fontWeight: 'Bold', - }, - { - type: 'text', - textAlign: 'left', - x: 80, - y: 400, - lineNum: 15, - width: 372, - height: 22, - text: data.desc, - color: 'black', - fontSize: 22, - lineHeight: 30, - }, -] - -type TPosterProps = { - posterData: TTaskItem -} -const Index: FC = ({ posterData }) => { - const posterRender = useRef(null) - const [posterPath, setPath] = useState() - - // TODO: 加埋点 - const savePosterToPhoto = useCallback( - () => - posterRender.current?.savePosterToPhoto().then((path) => { - showToast(`已保存到相册 ${path}`) - setPath(path || '') - }), - [posterRender], - ) - const trackError = useCallback((type, err) => { - showToast('保存图片失败了,重新进入尝试一下') - trackJsError({ - token: getStorage('userInfo').token || 'no_login', - errMsg: err, - errName: type, - location: 'detail/poster', - }) - }, []) - - return ( - - trackError('poster_render_failed', err)} - onSaveFail={(err) => trackError('poster_save_failed', err)} - list={lists(posterData)} - /> - - {!posterPath ? ( - - ) : ( - - )} - - - ) -} - -export default React.memo(Index) diff --git a/src/pages/Detail/components/poster.scss b/src/pages/Detail/components/poster.scss deleted file mode 100644 index b154a05..0000000 --- a/src/pages/Detail/components/poster.scss +++ /dev/null @@ -1,15 +0,0 @@ -.poster_wrapper { - width: 100%; - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - - .button_groups { - display: flex; - justify-content: space-around; - width: 70%; - margin-top: 80rpx; - } -} diff --git a/src/pages/Detail/index.config.ts b/src/pages/Detail/index.config.ts index d8922e7..5453636 100644 --- a/src/pages/Detail/index.config.ts +++ b/src/pages/Detail/index.config.ts @@ -8,7 +8,7 @@ export default definePageConfig({ /** 开启朋友分享 */ enableShareAppMessage: true, /** 开启朋友圈分享 */ - enableShareTimeline: false, + enableShareTimeline: true, /** 自定义背景颜色 */ backgroundColor: '#ffffff', /** 非首页设置返回Home */ diff --git a/src/pages/Detail/index.module.scss b/src/pages/Detail/index.module.scss index 5e6e64d..e69de29 100644 --- a/src/pages/Detail/index.module.scss +++ b/src/pages/Detail/index.module.scss @@ -1,149 +0,0 @@ -.detail_wrapper { - display: flex; - flex-direction: column; - width: 100vw; - height: 100vh; - overflow-y: scroll; - padding: 0 30rpx 0 30rpx; - box-sizing: border-box; - - .title_wrapper { - display: flex; - align-items: center; - justify-content: space-between; - width: 100%; - margin: 0 0 20rpx 0; - box-sizing: border-box; - - .title_wrapper__text { - font-size: 40rpx; - font-weight: 700; - font-family: AlibabaPuHuiTi; - } - - .title_wrapper__tags { - display: flex; - - .tag { - padding: 5rpx 20rpx 5rpx 20rpx; - background-color: rgb(15, 198, 15); - border-radius: 25rpx; - margin-right: 10rpx; - } - } - } - - .body_wrapper { - width: 100%; - box-sizing: border-box; - height: auto; - border: 2rpx dashed #aeabab; - border-radius: 15rpx; - padding: 30rpx 20rpx 20rpx 20rpx; - - &__title { - font-size: 30rpx; - font-weight: bold; - font-family: AlibabaPuHuiTi; - } - - .font-line { - font-size: 26rpx; - color: #7b7979; - margin: 5rpx 0 5rpx 0; - } - - &__content { - font-size: 26rpx; - color: #7b7979; - margin: 5rpx 0 5rpx 0; - } - - &__imgs { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(30%, 1fr)); - grid-gap: 10px; - width: 100%; - height: auto; - margin-top: 30rpx; - - .img-view { - width: 100%; - margin: 5px; - aspect-ratio: 1; - - .img { - object-fit: cover; - width: 100%; - height: 100%; - } - } - } - } - - .btn_wrapper { - .btn_groups { - display: flex; - justify-content: space-between; - width: 100%; - height: auto; - margin-top: 20rpx; - } - - .half-btn { - display: flex; - justify-content: center; - align-items: center; - width: 47%; - height: 80rpx; - border-radius: 40rpx; - } - - .border { - border: 1rpx solid black; - } - - .green { - background-color: rgb(16, 196, 16); - } - - .full-btn { - width: 100%; - height: 80rpx; - border-radius: 40rpx; - } - } -} - -.poster-popup { - display: flex; - position: absolute; - left: 0; - top: 0; - flex-direction: column; - // justify-content: center; - align-items: center; - z-index: 1000; - - .poster_section { - height: 80%; - width: 100%; - } - - .closeBtn_section { - } -} - -.popup { - position: absolute; - width: 100vw; - height: 100vh; -} - -.mask { - background-color: #fff; -} - -.bold { - font-weight: bold; -} diff --git a/src/pages/Detail/index.tsx b/src/pages/Detail/index.tsx index 8b6423b..12cbc69 100644 --- a/src/pages/Detail/index.tsx +++ b/src/pages/Detail/index.tsx @@ -1,151 +1,104 @@ -import { View, Text, Image } from '@tarojs/components' -import React, { FC, useCallback, useState } from 'react' -import Taro, { useShareAppMessage } from '@tarojs/taro' -import { - Post, - TTaskItem, - getCurrentPage, - query, - requestUrlCreator, - showToast, - taskStatusEnum, - timeFormat, -} from 'src/utils' -import Button from '@taroify/core/button/button' -import useRequest from 'src/hooks/useRequest' -import Loading from 'src/components/baseBuiltComp/Loading' +import { Canvas, View } from '@tarojs/components' +import React, { useEffect, useRef, FC } from 'react' +import Taro, { pxTransform } from '@tarojs/taro' +import { URL, getCurrentPage, goTo, $, getCurrentPageInstance } from 'src/utils' +import { PosterRender, PosterRenderRef } from '@poster-render/taro-react' import './index.module.scss' -import Poster from './components/Poster' -const Index: FC = () => { - const { data, loading, err } = useRequest( - () => ({ - url: requestUrlCreator({ absolutePath: '/detail' }), - type: 'Get', - reqData: { - id: query()?.id, - }, - silent: true, - }), - { auto: true }, - ) +// const Index = () => { +// // const storage = query() +// // const { data, loading, err, run } = useRequest( +// // () => ({ +// // url: requestUrlCreator({ absolutePath: '/detail' }), +// // type: 'Get', +// // reqData: { +// // id: storage?.id +// // }, +// // silent: true +// // }), { auto: true } +// // ) +// // console.log(query()); +// useEffect(() => { +// console.log(getCurrentPage()) - const [isShowPoster, setIsShowPoster] = useState(false) - const updateTaskStatus = useCallback(() => { - if (data!.status > 1) { - showToast('任务已过期,无法更新状态') - return - } - Post({ - url: requestUrlCreator({ absolutePath: '/changeStatus' }), - data: { - id: data?.id, - status: !data?.status, - }, - }) - }, [data]) +// // console.log('我调用了一次', query()); +// }, []) +// return ( +// +// {/* loading ? : loading结束了 */} +// goTo({ url: URL.Setting, methodType: 'navigateTo' })}> +// loading结束了 +// +// +// ) +// } - useShareAppMessage((payload) => { - const { from, target } = payload - const dataset = target?.['dataset'] || {} - let imageUrl = 'https://hx.404fwf.cn/notifyBoard/img/share_img3.png' - let title = '有新作业偷袭!请注意查收~' - console.log(payload) +const lists = [ + { + type: 'rect', + x: 0, + y: 0, + width: 644, + height: 1104, + radius: 0, + backgroundColor: 'black', + }, + { + type: 'image', + x: 250, + y: 40, + width: 185, + height: 210, + mode: 'cover', + src: 'https://p6-passport.byteacctimg.com/img/user-avatar/25facc1742ed0fa4856946823517dbe7~180x180.awebp', + radius: 90, + }, + { + type: 'line', + x: 50, + y: 50, + destX: 200, + destY: 50, + color: '#fff', + lineWidth: 4, + }, + { + type: 'text', + x: 100, + y: 180, + width: 150, + height: 30, + text: '中二猪猪猪', + color: '#fff', + fontSize: 28, + textAlign: 'left', + baseLine: 'top', + textDecoration: 'line-through', + }, +] - if (from === 'button' && dataset?.poster?.path) { - imageUrl = dataset?.poster?.path - title = '我创建了一个作业海报,快来看看叭!' - } - return { - title, - imageUrl, - path: getCurrentPage().route + '?id=' + query()?.id + '&isShare=true', - } - }) +const Index: FC = () => { + const posterRender = useRef(null) - if (loading) { - return - } return ( - - - 作业详情 - - {data!.tags?.map((tag) => { - return ( - - {tag} - - ) - })} - - - - {data?.title} - - 截止日期: - {timeFormat(data?.time, 'YYYY年MM月DD日 hh:mm:ss')} - - - 发布人: - {data?.publisher} - - - 内容: - {'\n'}        - {data?.desc} - - - <> - {(data!.imgs || []).map((img) => { - return ( - { - Taro.previewImage({ - current: img, - urls: [...(data?.imgs || [])], - }) - }} - key={1} - > - - - ) - })} - - - - {!query().isShare && ( - - - - - - {data!.status < 2 && ( - - - - )} - - )} - {isShowPoster && ( - - - - - setIsShowPoster(false)}> - ❌ - - - )} - + console.log('onRender')} + onLongTap={() => posterRender.current?.savePosterToPhoto()} + onRenderFail={(err) => console.error('onRenderFail', err?.message)} + onSave={(url) => console.log('onSave', url)} + onSaveFail={(err) => console.error('onSaveFail', err?.message)} + list={lists} + /> ) } diff --git a/src/pages/main/Index/components/Tasklist/task-item.tsx b/src/pages/main/Index/components/Tasklist/task-item.tsx index cb0f68b..52a7792 100644 --- a/src/pages/main/Index/components/Tasklist/task-item.tsx +++ b/src/pages/main/Index/components/Tasklist/task-item.tsx @@ -1,6 +1,6 @@ import { View, Text } from '@tarojs/components' import React from 'react' -import { Delete, Put, TTaskItem, URL, goTo, subscribeHOF, timeFormat } from 'src/utils' +import { Delete, Put, URL, goTo, subscribeHOF, timeFormat } from 'src/utils' import { SwipeCell } from '@taroify/core' import { TGeneralObject } from 'src/types' import type { SwipeCellProps } from '@taroify/core/swipe-cell/swipe-cell' @@ -10,7 +10,7 @@ import { Replay as ReplayIcon, Exchange as ExchangeIcon, } from '@taroify/icons' -import { TPropsThrough } from '../../types' +import { TPropsThrough, TTaskItem } from '../../types' import { IndexContextProvider, TASK_STATUS, taskInterUrl, tplIds } from '../../common' import './item.module.scss' @@ -129,12 +129,7 @@ class Index extends React.PureComponent { @subscribeHOF(tplIds) goToDetail() { console.log(' === 点击卡片,详情页开始跳转 === ') - goTo({ - url: URL.Detail, - methodType: 'navigateTo', - extraParams: { id: this.props.taskInfo.id }, - options: { authorize: false }, - }) + goTo({ url: URL.Detail, methodType: 'navigateTo', extraParams: { id: this.props.taskInfo.id } }) } /** 删除任务 */ diff --git a/src/pages/main/Index/components/Tasklist/task-list.tsx b/src/pages/main/Index/components/Tasklist/task-list.tsx index 10a2ed4..555b4c3 100644 --- a/src/pages/main/Index/components/Tasklist/task-list.tsx +++ b/src/pages/main/Index/components/Tasklist/task-list.tsx @@ -1,9 +1,8 @@ import { Button, View } from '@tarojs/components' import React, { FC, useCallback, useContext, useMemo, useState } from 'react' import { Divider, Empty, List, PullRefresh } from '@taroify/core' -import { TTaskItem } from 'src/utils' import TaskItem from './task-item' -import { TStateHookUpdateFn, TTaskList } from '../../types' +import { TStateHookUpdateFn, TTaskItem, TTaskList } from '../../types' import { IndexContextProvider } from '../../common' import './list.module.scss' @@ -94,54 +93,48 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn }> = ({ [filterType, lists, updateList], ) return ( - // - // {/* TODO: 暂时取消上拉加载 */} - - { - /** 要求lists存在并且长度>0 */ - isCanShowList ? ( - <> - {lists.map((v, index) => { - return ( - { - e.stopPropagation() - e.preventDefault() + + {/* TODO: 暂时取消上拉加载 */} + + { + /** 要求lists存在并且长度>0 */ + isCanShowList ? ( + <> + {lists.map((v, index) => { + return ( + + + + ) + })} + {/* 没有更多页面了,增加分割线 */} + {page < 0 ? ( + - - - ) - })} - {/* 没有更多页面了,增加分割线 */} - {page < 0 ? ( - - 到底了呦~ - - ) : ( - /* 用来兜底用户删了过多元素,从而无法触发触底的case */ - - )} - - ) : ( - /** lists不存在或lists长度为0 */ - - - 暂时没有更多了 - - ) - } - - // + 到底了呦~ + + ) : ( + /* 用来兜底用户删了过多元素,从而无法触发触底的case */ + + )} + + ) : ( + /** lists不存在或lists长度为0 */ + + + 暂时没有更多了 + + ) + } + + ) } diff --git a/src/pages/main/Index/types.ts b/src/pages/main/Index/types.ts index 04fcc7c..f4b1a97 100644 --- a/src/pages/main/Index/types.ts +++ b/src/pages/main/Index/types.ts @@ -1,6 +1,16 @@ import React from 'react' import useRequest from 'src/hooks/useRequest' -import { TTaskItem } from 'src/utils' + +/** 任务的类型 */ +export type TTaskItem = { + title: string + time: number + desc: string + /** 当前任务状态 */ + status: 0 | 1 | 2 + /** 当前任务ID */ + id: number +} /** 任务列表的类型 */ export type TTaskList = TTaskItem[] diff --git a/src/pages/main/Manage/Publish/index.config.ts b/src/pages/main/Manage/Publish/index.config.ts new file mode 100644 index 0000000..e6280eb --- /dev/null +++ b/src/pages/main/Manage/Publish/index.config.ts @@ -0,0 +1,10 @@ +export default definePageConfig({ + /** 页面标题 */ + navigationBarTitleText: '发布', + /** 是否开启下拉刷新 */ + enablePullDownRefresh: false, + /** 自定义导航栏 */ + navigationStyle: 'custom', + /** 自定义背景颜色 */ + backgroundColor: '#ffffff', +}) diff --git a/src/pages/Detail/types.ts b/src/pages/main/Manage/Publish/index.module.scss similarity index 100% rename from src/pages/Detail/types.ts rename to src/pages/main/Manage/Publish/index.module.scss diff --git a/src/pages/main/Manage/Publish/index.tsx b/src/pages/main/Manage/Publish/index.tsx new file mode 100644 index 0000000..7359ace --- /dev/null +++ b/src/pages/main/Manage/Publish/index.tsx @@ -0,0 +1,7 @@ +import { View } from '@tarojs/components' + +const Index = () => { + return 管理-发布页面 +} + +export default Index diff --git a/src/pages/main/Manage/components/apple.modules.scss b/src/pages/main/Manage/components/apple.modules.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/main/Manage/components/apply-manage.tsx b/src/pages/main/Manage/components/apply-manage.tsx deleted file mode 100644 index 719aa72..0000000 --- a/src/pages/main/Manage/components/apply-manage.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Input, View } from '@tarojs/components' -import React, { FC } from 'react' -import './apple.modules.scss' - -const Index: FC<{ setCurrentTab: React.Dispatch> }> = () => { - return ( - - 输入框 - 申请授权 - 查看授权历史 - - ) -} - -export default React.memo(Index) diff --git a/src/pages/main/Manage/components/work-manage.tsx b/src/pages/main/Manage/components/work-manage.tsx deleted file mode 100644 index 712045c..0000000 --- a/src/pages/main/Manage/components/work-manage.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { View } from '@tarojs/components' -import React from 'react' -import { Forbidden } from 'src/components/baseBuiltComp/HocWrap' -import './work.modules.scss' - -const Index = () => { - return 1 -} - -export default React.memo(Forbidden(Index)) diff --git a/src/pages/main/Manage/components/work.modules.scss b/src/pages/main/Manage/components/work.modules.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/main/Manage/index.config.ts b/src/pages/main/Manage/index.config.ts index 03f148a..0bce516 100644 --- a/src/pages/main/Manage/index.config.ts +++ b/src/pages/main/Manage/index.config.ts @@ -1,8 +1,10 @@ export default definePageConfig({ /** 页面标题 */ - navigationBarTitleText: '', + navigationBarTitleText: '管理页面', /** 是否开启下拉刷新 */ enablePullDownRefresh: false, + /** 自定义导航栏 */ + navigationStyle: 'custom', /** 自定义背景颜色 */ backgroundColor: '#ffffff', }) diff --git a/src/pages/main/Manage/index.module.scss b/src/pages/main/Manage/index.module.scss index 6922089..e69de29 100644 --- a/src/pages/main/Manage/index.module.scss +++ b/src/pages/main/Manage/index.module.scss @@ -1,65 +0,0 @@ -.manage_wrapper { - display: flex; - flex-direction: column; - width: 100vw; - height: 100vh; - overflow-y: scroll; - padding: 0 30rpx 0 30rpx; - box-sizing: border-box; - - .body_wrapper { - width: 100%; - height: 90%; - border: 1rpx solid rgb(131, 214, 110); - box-sizing: border-box; - margin-top: 1%; - border-radius: 20rpx; - .tabs_areas { - display: flex; - width: 100%; - height: 6%; - .tag_item { - display: flex; - justify-content: center; - align-items: center; - width: 140rpx; - height: 100%; - border-radius: 20rpx 20rpx 0 0; - background-color: rgb(93, 232, 135); - margin-right: 5rpx; - } - - .active { - box-shadow: 5rpx -2rpx 10rpx rgb(86, 85, 85); - } - } - - .tabs_views { - width: 100%; - height: 94%; - } - } -} - -.title_wrapper { - display: flex; - align-items: center; - justify-content: space-between; - width: 100%; - margin: 0 0 10rpx 0; - box-sizing: border-box; - - .title_wrapper__text { - font-size: 45rpx; - font-weight: 700; - font-family: AlibabaPuHuiTi; - } -} - -.space { - width: 94%; - height: 1rpx; - background-color: rgb(220, 217, 217); - margin: 10rpx 0 10rpx 3%; - box-sizing: border-box; -} diff --git a/src/pages/main/Manage/index.tsx b/src/pages/main/Manage/index.tsx index 862740f..1bce1c1 100644 --- a/src/pages/main/Manage/index.tsx +++ b/src/pages/main/Manage/index.tsx @@ -1,47 +1,11 @@ -import React, { useMemo, useState } from 'react' +import React from 'react' import { View, Text } from '@tarojs/components' -import classNames from 'classnames' -import WorkManage from './components/work-manage' -import ApplyManage from './components/apply-manage' -import './index.module.scss' +// import { Forbidden } from 'src/components/baseBuiltComp/HocWrap' -const tabs = [ - { - name: '授权管理', - component: ApplyManage, - }, - { - name: '发布管理', - component: WorkManage, - }, -] const Index = () => { - const [currentTab, setTab] = useState(0) - const ViewComponent = useMemo(() => tabs[currentTab].component, [currentTab]) return ( - - - 作业详情 - - - - - {tabs.map((tab, i) => { - return ( - setTab(i)} - > - {tab.name} - - ) - })} - - - - - + + 管理页面 ) } diff --git a/src/static/SVG/lottie-map.ts b/src/static/SVG/lottie-map.ts index 1b799ec..8c75ad6 100644 --- a/src/static/SVG/lottie-map.ts +++ b/src/static/SVG/lottie-map.ts @@ -1,16 +1,22 @@ const BASE_CDN_DOMAIN = 'https://hx.404fwf.cn/notifyBoard/SVG/' -const _uri = (subpath: string) => BASE_CDN_DOMAIN + subpath -/** 只读lottie动画映射 */ -export const JSON_MAP = { - '404': _uri('404.json'), - forbidden: _uri('forbidden.json'), - loading1: _uri('loading1.json'), - loading2: _uri('loading2.json'), - loading3: _uri('loading3.json'), - loading4: _uri('loading4.json'), - loading5: _uri('loading5.json'), - loading6: _uri('loading6.json'), - loading7: _uri('loading7.json'), - success: _uri('success.json'), -} as const +/** 只读元组 */ +const MAPPING = [ + '404', + 'forbidden', + 'loading1', + 'loading2', + 'loading3', + 'loading4', + 'loading5', + 'loading6', + 'loading7', + 'success', + 'initial_success', +] as const + +/** lottie动画映射 */ +export const JSON_MAP = MAPPING.reduce((pre, cur) => { + pre[cur] = BASE_CDN_DOMAIN + cur + '.json' + return pre +}, {} as Record<(typeof MAPPING)[number], string>) diff --git a/src/utils/perfTrack/business.ts b/src/utils/perfTrack/business.ts index 3703552..02ce46a 100644 --- a/src/utils/perfTrack/business.ts +++ b/src/utils/perfTrack/business.ts @@ -23,6 +23,7 @@ type TTrackAPIErrorParams = Pick & { reqData?: TGeneralObject | string | undefined errMsg: any } + /** 网络请求错误埋点 */ export const trackAPIError = ({ token, @@ -43,38 +44,3 @@ export const trackAPIError = ({ }, }) } - -/** 请求错误埋点 */ -type TTrackJsErrorParams = Pick & { - token: string - errMsg: any - location: string - errName: string -} -/** 运行时错误上报 */ -export const trackJsError = ({ - token, - extraParams = {}, - errMsg, - location, - errName, -}: TTrackJsErrorParams) => { - /* __PURE__ */ console.log( - ' === 运行时错误埋点上报 === ', - token, - location, - errName, - extraParams, - errMsg, - ) - trackEvent({ - eventId: BUSINESS_EVENT_MAP.API_ERROR, - extraParams: { - ...extraParams, - token, - err_msg: JSON.stringify(errMsg), - location, - errName, - }, - }) -} diff --git a/src/utils/request/Result.ts b/src/utils/request/Result.ts index 2854bcf..4f1ee22 100644 --- a/src/utils/request/Result.ts +++ b/src/utils/request/Result.ts @@ -2,9 +2,10 @@ import exception from './exception' interface IResultWrapBase { data: T + // header: object, + // cookies: string, msg: string code: number - extraData: { [key: string]: any } isSuccess: boolean } @@ -13,7 +14,6 @@ class ResultWrapBase implements Partial> { private _data?: T private _msg?: string private _code?: number - private _extraData?: { [key: string]: any } private _isSuccess?: boolean /** 获取请求数据 */ @@ -31,11 +31,6 @@ class ResultWrapBase implements Partial> { return this._code } - /** 用于获取非标准code-msg-data结构的额外参数 */ - get extraData() { - return this._extraData - } - /** 获得到是否成功请求 */ get isSuccess() { return this._isSuccess @@ -45,7 +40,6 @@ class ResultWrapBase implements Partial> { this._data = params.data this._msg = params.msg this._code = params.code - this._extraData = params.extraData this._isSuccess = params.isSuccess } } diff --git a/src/utils/request/business.ts b/src/utils/request/business.ts index cdf594b..543345e 100644 --- a/src/utils/request/business.ts +++ b/src/utils/request/business.ts @@ -27,7 +27,7 @@ export const request = ( ...baseExtraConfig, ...params, header: { - token: getStorage('userInfo').token, + token: getStorage('userInfo').token, ...params.header, }, }) @@ -43,16 +43,11 @@ export const request = ( } const { data, code, msg } = originData - const extraData = Object.keys(originData) - .filter((k) => !['code', 'data', 'msg'].includes(k)) - .reduce((pre, cur) => (pre[cur] = originData[cur]), {}) - resInstance = new ResultWrap({ data, msg, code, isSuccess: !type, - extraData, type, }) if (!params.silent) { @@ -65,7 +60,7 @@ export const request = ( if (!type) { /** 上报错误埋点 */ trackAPIError({ - token: getStorage('userInfo').token || 'no_login', + token: getStorage('userInfo').token || 'noLogin', api: params.url, reqData: params.data, errMsg: msg, @@ -78,20 +73,6 @@ export const request = ( msg: _err, type: 'system_error', }) - if (!params.silent) { - const { loadingNeedMask: mask } = params - showToast({ - title: '执行失败了.....', - mask, - }) - } - /** 上报错误埋点 */ - trackAPIError({ - token: getStorage('userInfo').token || 'no_login', - api: params.url, - reqData: params.data, - errMsg: _err, - }) } resolve(resInstance) }) diff --git a/src/utils/request/request.ts b/src/utils/request/request.ts index 1a77e10..bc8db04 100644 --- a/src/utils/request/request.ts +++ b/src/utils/request/request.ts @@ -1,5 +1,5 @@ import Taro from '@tarojs/taro' -import { hideLoading, showLoading } from '../extraUiEffect' +import { hideLoading, showLoading, showToast } from '../extraUiEffect' /** Taro.request入参类型 */ type TTaroRequestParams = Parameters>[0] diff --git a/src/utils/route/constants.ts b/src/utils/route/constants.ts index 3870d01..13a811d 100644 --- a/src/utils/route/constants.ts +++ b/src/utils/route/constants.ts @@ -5,6 +5,8 @@ export const enum URL { Calendar = '/pages/main/Calendar/index', /** 管理页面 */ Manage = '/pages/main/Manage/index', + /** 发布页面 */ + ManagePublish = '/pages/main/Manage/index', /** 我的页面 */ My = '/pages/main/My/index', /** 详细页面 */ diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 99b951e..7874cbc 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -1,17 +1,21 @@ import Taro from '@tarojs/taro' -import { IUserInfo } from 'src/common-model' +import { ISystemInfo, IUserInfo } from 'src/common-model' import { isObj } from './jsBase' /** 可存储的storage接口 */ export interface IStorageData { userInfo: IUserInfo + system: ISystemInfo & { + /** 是否弹过未授权消息 */ + isPopNoAuthorizeMessage?: boolean + } } type TStorageKey = keyof IStorageData /** * 获取本地存储 */ -export const getStorage = (key: K): IStorageData[K] => { +export const getStorage = (key: TStorageKey): T => { return Taro.getStorageSync(key) } diff --git a/src/utils/subscribe.ts b/src/utils/subscribe.ts index effe37c..45e0abc 100644 --- a/src/utils/subscribe.ts +++ b/src/utils/subscribe.ts @@ -79,8 +79,8 @@ export function subscribeHOF(tplIds: string[]) { /** 额外执行订阅逻辑 */ descriptor.value = async function () { /** 先等授权逻辑走完 */ - subscribe({ tplId: tplIds }) - return originalFunction.apply(this, arguments) + const { errno } = await subscribe({ tplId: tplIds }) + return !errno ? originalFunction.apply(this, arguments) : () => void 0 } return descriptor } diff --git a/src/utils/types/entity/index.ts b/src/utils/types/entity/index.ts deleted file mode 100644 index 746e7a9..0000000 --- a/src/utils/types/entity/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './task' diff --git a/src/utils/types/entity/task.ts b/src/utils/types/entity/task.ts deleted file mode 100644 index e66893d..0000000 --- a/src/utils/types/entity/task.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** 任务的类型 */ -export type TTaskItem = { - title: string - time: number - desc: string - /* 当前任务状态 */ - status: 0 | 1 | 2 - /* 当前任务ID */ - id: number - /* 标签 */ - tags?: string[] - imgs?: string[] - /* 发布人 */ - publisher: string -} - -/** 任务状态的枚举 */ -export const taskStatusEnum = { - 0: '未完成', - 1: '已完成', - 2: '已过期', -} diff --git a/src/utils/types/index.ts b/src/utils/types/index.ts index 3d9b976..73b6124 100644 --- a/src/utils/types/index.ts +++ b/src/utils/types/index.ts @@ -1,2 +1 @@ export * from './enumHelper' -export * from './entity'