Skip to content

Commit

Permalink
feat: 发布作业hack
Browse files Browse the repository at this point in the history
  • Loading branch information
HardenSG committed Jun 6, 2024
1 parent 64068a2 commit 1972473
Show file tree
Hide file tree
Showing 23 changed files with 244 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 配置要求:必须以TARO_APP_开头否则不可以通过process.env.TARO_APP_XX获得

# 域名
TARO_APP_DOMAIN="https://805807.cn:8080"
TARO_APP_DOMAIN="https://805807.cn:8057"
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 配置要求:必须以TARO_APP_开头否则不可以通过process.env.TARO_APP_XX获得

# 域名
TARO_APP_DOMAIN="https://805807.cn:8080"
TARO_APP_DOMAIN="https://805807.cn:8057"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@tarojs/shared": "3.5.11",
"@tarojs/taro": "3.5.11",
"@tarojs/taro-h5": "3.5.11",
"@zlyboy/wx-formdata": "^1.0.2",
"classnames": "^2.3.2",
"immer": "^9.0.15",
"lottie-miniprogram": "^1.0.12",
Expand Down
9 changes: 8 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/components/baseBuiltComp/HocWrap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const Forbidden = (Component, props?: any) => {
return React.memo(() => {
const sysState = useSelector((root: RootState) => root.systemModel)
const userState = useSelector((root: RootState) => root.userinfoModel)
/** TODO: 更新字段取值口径 */
if (!sysState.coldStartSuccess) {
return <Loading isShow />
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Setting/Feedback/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default definePageConfig({
/** 页面标题 */
navigationBarTitleText: '',
// navigationBarTitleText: '',
navigationStyle: 'custom',
/** 是否开启下拉刷新 */
enablePullDownRefresh: false,
/** 自定义背景颜色 */
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Setting/Feedback/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
justify-content: center;
align-items: center;
width: 100%;
height: 30%;
height: 25%;
padding: 0 20% 0 20%;
background: url('https://hx.404fwf.cn/notifyBoard/img/title_banner.png') center center no-repeat;
background-size: contain;
Expand All @@ -22,17 +22,16 @@
.content_wrapper {
position: relative;
width: 100%;
height: 60%;
height: 70%;
margin-top: -10%;

.area {
box-sizing: border-box;
position: absolute;
width: 90%;
height: 100%;
left: 50%;
transform: translateX(-50%);
padding: 50rpx 20rpx 0 20rpx;
padding: 50rpx 20rpx 40rpx 20rpx;
z-index: 2;
border: 4rpx solid black;
border-radius: 30rpx;
Expand All @@ -43,7 +42,7 @@
width: 280rpx;
height: 80rpx;
text-align: center;
line-height: 80rpx;
line-height: 60rpx;
// box-shadow: -10rpx 13rpx $primary-color;
background-color: $primary-color;
margin-top: 30rpx;
Expand All @@ -68,6 +67,7 @@
.promise_text {
font-size: 26rpx;
color: #bfbbbb;
margin-top: 40rpx;
}

.from {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Setting/Feedback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const Index = () => {
/>
</Field>
<Button className='primary-button btn' onClick={clickBtn}>
提交
我已知悉 提交
</Button>
<View className='promise_text'>
您提供的联系方式我们会妥善保管,我们承诺仅用于系统升级的后续沟通跟进,不会将您的信息以任何种形式外借、售卖、展示给任何人,以防您的信息泄漏
Expand Down
2 changes: 1 addition & 1 deletion src/pages/main/Index/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TPropsThrough } from './types'

/** context props透传 https://zh-hans.react.dev/learn/passing-data-deeply-with-context# */
export const IndexContextProvider = createContext<TPropsThrough>({
page: 0,
page: 1,
})

/** 列表数据的基础路径 */
Expand Down
22 changes: 11 additions & 11 deletions src/pages/main/Index/components/Tasklist/task-list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, View } from '@tarojs/components'
import React, { FC, useCallback, useContext, useMemo, useState } from 'react'
import { Divider, Empty, List, PullRefresh } from '@taroify/core'
import { Divider, Empty, List } from '@taroify/core'
import { usePullDownRefresh, stopPullDownRefresh } from '@tarojs/taro'
import { IWork } from 'src/utils'
import TaskItem from './task-item'
import { TStateHookUpdateFn, TTaskList } from '../../types'
Expand All @@ -22,16 +23,19 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn<number> }> = ({
const pullDownRefreshList = useCallback(async () => {
console.log(' === 下拉刷新ing === ')
setRefreshStatus(true)
const res = await requestFn!({ page: 0 })
const res = await requestFn!({ page: 1 })
setTimeout(() => {
setRefreshStatus(false)
stopPullDownRefresh()
console.log(' === 下拉刷新结束 === ')
setPage(0)
}, 200)
setPage(1)
}, 300)
if (res) {
updateList!(res)
}
}, [requestFn, setPage, updateList])
/** 下拉刷新hook */
usePullDownRefresh(pullDownRefreshList)

/** 加载函数:触底加载「目前通过点击按钮触发」 */
const pullUpLoad = useCallback(async () => {
Expand All @@ -44,13 +48,12 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn<number> }> = ({
/** 更新数据 & 设置当前页 */
updateList!([...lists, ...res])
setPage(page + 1)
/** 解除Mutex锁 */
setRefreshStatus(false)
} else {
setRefreshStatus(false)
console.log(' === 加载结束到底了 === ')
setPage(-1)
}
/** 解除Mutex锁 */
setRefreshStatus(false)
}, [page, isRefresh, requestFn, updateList, lists, setPage])

/**
Expand All @@ -61,7 +64,6 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn<number> }> = ({
const handleTaskItemEvents = useCallback(
async (events: 'DELETE' | 'RESOLVE' | 'REOPEN', newTaskinfo: IWork) => {
const index = lists.findIndex((v) => v.id === newTaskinfo.id)
// const copiedList = lists.map((v) => v)
const copiedList = lists
if (index < 0) {
console.log(' === 任务索引错误,退出 === ', newTaskinfo)
Expand Down Expand Up @@ -98,9 +100,8 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn<number> }> = ({
},
[filterType, lists, updateList],
)

return (
// <PullRefresh loading={isRefresh} pullDistance={150} onRefresh={pullDownRefreshList}>
// {/* TODO: 暂时取消上拉加载 */}
<List>
{
/** 要求lists存在并且长度>0 */
Expand Down Expand Up @@ -147,7 +148,6 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn<number> }> = ({
)
}
</List>
// </PullRefresh>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/main/Index/components/Tasklist/task-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Index: FC<{
const searchBtn = useCallback(() => {
/** TODO: 或许可以优化下这个逻辑 + 从未输入时的空数据不发请求 */
setPage(0)
requestFn!({ page: 0, searchText: text }).then((res) => {
requestFn!({ page: 1, searchText: text }).then((res) => {
res && updateList!([...(res || [])])
})
setSearchText(text)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/main/Index/index.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default definePageConfig({
/** 页面标题 */
navigationBarTitleText: '',
/** 是否开启下拉刷新 */
enablePullDownRefresh: false,
enablePullDownRefresh: true,
/** 自定义导航栏 */
navigationStyle: 'default',
/** 开启朋友分享 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,30 @@
padding: 0 30rpx 0 20rpx;
box-sizing: border-box;
background-color: $bg-color-gary2;
margin-bottom: 5rpx;

&_left {
display: flex;
width: 100%;
flex-direction: column;
justify-content: center;
height: 100%;

.name {
.code {
font-family: AlibabaPuHuiTi;
font-size: 35rpx;
}
}
&_right {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
width: 100%;
height: 100%;

.time {
margin-top: 5rpx;
font-size: 25rpx;
}

.right {
text-align: end;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ const Index: FC<{ setView: React.Dispatch<React.SetStateAction<TComponents>> }>
<Frame targetView='apply' setView={setView}>
<View className='feedback_wrapper'>
<View key='button' className='back-btn'>
返回继续申请🔙
返回继续申请 🔙
</View>
<View className='list_wrapper'>
<List>
{({ code, createdAt }) => (
<View className='list'>
<View className='list_left'>
<View className='name'>{code}</View>
<View className='time right'>申请时间:{timeFormat(createdAt)}</View>
<View className='code'>{code}</View>
</View>
<View className='list_right'>
<View>已通过</View>
<View className='time'>{timeFormat(createdAt)}</View>
</View>
{/* <View className='list_right'>
<View className='publisher'>创建人</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable react/no-children-prop */
import { Calendar, Cell } from '@taroify/core'
import { useState } from 'react'
import { timeFormat } from 'src/utils'

export function CustomCalendar({ onChange }) {
const [open, setOpen] = useState(false)
const [value, setValue] = useState<Date>()
const [formatValue, setFormatValue] = useState<string>()

return (
<>
<Cell required title='选择截止时间' isLink children={formatValue} onClick={() => setOpen(true)} />
<Calendar
type='single'
value={value}
onChange={setValue}
poppable
showPopup={open}
showConfirm={false}
onClose={setOpen}
onConfirm={(newValue) => {
const timestamp = new Date(newValue).getTime()
const timeStr = timeFormat(timestamp, 'YYYY/MM/DD hh:mm:ss')
onChange(timestamp)
setFormatValue(timeStr)
setOpen(false)
}}
/>
</>
)
}
45 changes: 45 additions & 0 deletions src/pages/main/Manage/components/work-manage/components/upload.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* eslint-disable react/no-children-prop */
import { Uploader } from '@taroify/core'
import { chooseImage, getImageInfo } from '@tarojs/taro'
import { useState } from 'react'

export const handleFiles = (_files) =>
Promise.all(_files.map(({ path: src }) => getImageInfo({ src })))

export function CustomUploader({ onChange: onFileChange }) {
const [files, setFiles] = useState<Uploader.File[]>([])
const onUpload = () => {
chooseImage({
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
}).then(async ({ tempFiles }) => {
const preFiles = await handleFiles(files)
const curFiles = await handleFiles(tempFiles)
const _httpFiles = [...preFiles, ...curFiles]
const _files = [
...files,
...tempFiles.map(({ path, type, originalFileObj }) => ({
type,
url: path,
name: originalFileObj?.name,
})),
]
setFiles(_files)
onFileChange(_httpFiles)
})
}

return (
<Uploader
value={files}
multiple
onUpload={onUpload}
onChange={(_files) => {
handleFiles(_files).then((newFiles) => {
setFiles(_files as any)
onFileChange(newFiles)
})
}}
/>
)
}
13 changes: 13 additions & 0 deletions src/pages/main/Manage/components/work-manage/index.modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@
align-items: center;
width: 100%;
height: 100%;

view {
border-radius: 15rpx;
}
}

.choose_course {
width: 100%;
height: 100rpx;
}

.ipt_textarea {
width: 100%;
}

.btn {
margin-top: 20rpx;
}
Loading

0 comments on commit 1972473

Please sign in to comment.