Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/bounty #171

Open
wants to merge 6 commits into
base: test
Choose a base branch
from
Open

Refactor/bounty #171

wants to merge 6 commits into from

Conversation

missop
Copy link
Contributor

@missop missop commented Mar 15, 2025

No description provided.

@ourai
Copy link
Member

ourai commented Mar 15, 2025

先拉取最新代码处理下冲突

# Conflicts:
#	src/app/bounties/[id]/Activities.js
#	src/app/bounties/[id]/page.js
Copy link

vercel bot commented Mar 18, 2025

@missop is attempting to deploy a commit to the OpenBuild Team on Vercel.

A member of the Team first needs to authorize it.

@missop
Copy link
Contributor Author

missop commented Mar 18, 2025

已经合并成功

@ourai
Copy link
Member

ourai commented Mar 20, 2025

已经转移到其他文件中留在原文件中的代码,确定不再用了就删掉,而非注释。想日后找历史代码就从提交记录里找。

@missop
Copy link
Contributor Author

missop commented Mar 20, 2025 via email

@ourai ourai added the enhancement New feature or request label Mar 20, 2025
@ourai ourai self-assigned this Mar 20, 2025
@ourai ourai self-requested a review March 20, 2025 08:20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件可以直接移动到 domain/bounty/views/process-list 下,并且在 ProcessList 中使用,revalidatePathAction 作为组件属性传入。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个为什么推荐要从组件属性传入

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为那是个用到了 Next.js 机制的 server action

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个应该放在 widgets 文件夹下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件没有被多次引用,为何要放在 widgets 下面?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

判断是不是个视图(view)的标准,是相应的数据源是否为实体,这里 process list 实际上是个字典或枚举值。不符合视图条件的就放进 widgets。

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
import { useUser } from '#/state/application/hooks';

function ProcessListView({process=[],data={},setAppliedModalOpen,setApplyFinishedModalOpen,setAgreeFinishedModalOpen}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApplyFinishedModalAppliedModalApplyFinishedModal 都挪到同级文件夹下,对话框显示状态在这个组件里管理,并且 revalidatePathAction 作为组件属性传入

import { EXPERIENCE_OPTIONS } from '#/lib/user';
import { denyBuilder } from '#/services/creator';
import { useConfig, useMediaUrl } from '#/state/application/hooks';

function AppliedBuilderListView({data,isLoading,setCurrUser,setConfirmModalOpen,setApproveConfirmIds}) {
function AppliedBuilderListView({data,approve}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原则上来讲,UI 组件的属性不应该有函数,但 React 里没有 Vue 那种事件机制,所以用 on- 开头命名的函数视为事件,所以这个应该叫 onApprove

import { BountyABI } from '@/constants/abis/bounty';
import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { useAllowance, useApprove } from '@/hooks/useERC20';
import { fetcher } from '@/utils/request';
import { parseTokenUnits } from '@/utils/web3';

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
import AppliedBuilderListView from '#/domain/bounty/views/applied-builder-list';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

相对路径

<div className="max-h-[400px] overflow-auto">
<AppliedBuilderListView
data={data}
isLoading={isLoading}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有这个属性了

import { BountyABI } from '@/constants/abis/bounty';
import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain';
import { contracts, payTokens } from '@/constants/contract';
import { useAllowance, useApprove } from '@/hooks/useERC20';
import { fetcher } from '@/utils/request';
import { parseTokenUnits } from '@/utils/web3';

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

相对路径

@@ -23,17 +23,12 @@ import { Modal } from '@/components/Modal';
import { withdraw } from '@/constants/bounty';

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

相对路径

@@ -28,9 +28,7 @@ import { parseTokenUnits, signBounty } from '@/utils/web3';
import { useBountyEnvCheck } from '#/domain/bounty/hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

相对路径

import { revalidatePathAction } from '#/app/actions';
import { AgreeFinishedModal } from '#/domain/bounty/widgets/process-list/AgreeFinishedModal';
import { AppliedModal } from '#/domain/bounty/widgets/process-list/AppliedModal';
import { ApplyFinishedModal } from '#/domain/bounty/widgets/process-list/ApplyFinishedModal';
import { useUser } from '#/state/application/hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

三个对话框相对路径引用


import { formatTime } from '@/utils/date';

import { useBountyEnvCheck } from '#/domain/bounty/hooks';
import { revalidatePathAction } from '#/app/actions';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

作为组件属性传入:

  1. domain 不允许引用 appentry
  2. revalidatePathAction 是 server action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

2 participants