-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat(website): wiki/edit_detail #312
Conversation
我觉得一个页面一个PR比较好,而且关联 投票啥的API都还没做…
不用完全复刻 |
Preview DeploymentStorybook https://pr-312-storybook--bangumi-next.netlify.app |
这里的 select 有设计吧? |
你是指 Header 那个吗,那个只是导航栏是这样吧,通用的 Select 也按照那个吗 |
不对,我傻了,把select和radio弄混了 那这里也 @vistaing |
目前建议先使用浏览器默认样式,若后续确有需要,再参照 Header 的 hover 菜单来设计一个,我个人是觉得浏览器默认的样式差不多够用 |
还有个功能,如果觉得麻烦留成TODO也可以
|
packages/design/theme/variables.less
Outdated
@@ -2,6 +2,8 @@ | |||
|
|||
@primary-color: #f09199; | |||
|
|||
@bg-gray-10: #fcfcfc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我看错了,感觉有点迷,这里background好像没有色系,cc @vistaing
图里的是子项目输入框
packages/website/src/pages/index/subject/[id]/wiki/edit_detail.tsx
Outdated
Show resolved
Hide resolved
packages/website/src/pages/index/subject/[id]/wiki/edit_detail.tsx
Outdated
Show resolved
Hide resolved
packages/website/src/pages/index/subject/[id]/wiki/edit_detail.tsx
Outdated
Show resolved
Hide resolved
2. remove wikItem when key ctrl+x|X down 3. use class instead of inline style
<div | ||
className={style.Tips} | ||
style={{ display: editorType === EditorType.Beginner ? 'block' : 'none' }} | ||
> | ||
<div>Tips:</div> | ||
<div>可拖拽改变行顺序</div> | ||
<div> | ||
按<kbd>Ctrl</kbd>+<kbd>Enter</kbd>切换为二级项目 | ||
</div> | ||
<div> | ||
按<kbd>Ctrl</kbd>+<kbd>X</kbd>可删除项目 | ||
</div> | ||
</div> | ||
|
||
{/* 入门编辑模式 */} | ||
<div hidden={editorType !== EditorType.Beginner}> | ||
<WikiInfoContext.Provider | ||
value={{ | ||
els: wikiElement, | ||
addOneWikiElement, | ||
removeOneWikiElement, | ||
editOneWikiElement, | ||
switchWikiElementToArray, | ||
}} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{editorType === EditorType.Biginner && <>{// 里面的内容 }</>}
直接不渲染,不用 display: none
可以吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当时是想有可能切换得比较频繁,但具体我也不清楚维基人的日常操作(,如果切换得比较少,可以直接不渲染。
packages/website/src/pages/index/subject/[id]/wiki/edit_detail.tsx
Outdated
Show resolved
Hide resolved
wikiRef.current = parseWiki(subjectWikiInfo.infobox); | ||
monoEditorInstanceRef.current?.setValue(subjectWikiInfo.infobox); | ||
setWikiElement(toWikiElement(wikiRef.current)); | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint 的 deps 补一下吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 effect 只有第一次跑,如果 subjectWikiInfo.infobox
(api 来的数据) 变了也不应该重新跑的吧,感觉涉及到编辑冲突的一些问题。另外就是 WikiEditor 那边的 effect 也是,编辑器应该实例化一次就好了,defaultValue 只影响初始状态,如果 defaultValue 变了不应该重新实例化编辑器,应该是没反应。若需要修改编辑器的值,应该通过 api,而不是更新 defaultValue。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不会多次请求 subjectWikiInfo 吧?对于接口请求这类,请求之前是个 undefined,请求后才有数据是很常见的场合
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实不会,只是想表达这个 effect 应该只运行一次,无论什么情况 re-render,都不应该重新跑(
packages/utils/wiki.ts
Outdated
if (isEmpty(el.value) && isEmpty(el.key)) continue; | ||
const value = el.value; | ||
const initWikiItemValue = typeof value === 'string' ? value : ''; | ||
const item = new WikiItem(el.key ?? '', initWikiItemValue, 'object'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value 是数组的时候,可以用 WikiItem 的 type 参数吧?手动写 item.array 有点依赖 wiki-parser 的内部实现了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wiki-parser也是我们写的,需要的话可以改…(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写成现在这个样主要为了照顾静态语言的JSON序列化和反序列化…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在想有没有可能这里写成 const item = isArray(values) ? new WikiItem(..,.., 'array') : new WikiItem(..,.., 'object')
... 如果上游能够分开最好(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在想有没有可能这里写成 const item = isArray(values) ? new WikiItem(..,.., 'array') : new WikiItem(..,.., 'object')...
不太行,WikiItem 构造函数签名问题。估计 server 那边也有依赖 wiki-parser 吧。
写成现在这个样主要为了照顾静态语言的JSON序列化和反序列化…
没有太理解这个🤔,静态语言是指?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是按着之前go版本的写的(
还是先保持原样吧,后面再说了( |
packages/website/src/shared/wiki.ts
Outdated
|
||
export const WikiEditTabsItemsByKey = keyBy(WikiEditTabsItems, 'key'); | ||
|
||
export const getWikiTemplate = (subjectType: number, targetTemplate: string | undefined) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数能注释下吗?targetTemplate 是干啥的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道有没有写清楚,写得稍微有点绕。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上面的注释后没啥问题了
做得差不多了,各位大大可以点 https://pr-312-sites--bangumi-next.netlify.app/subject/363612/wiki/edit_detail 多测试测试哈,改动有点大 bgm38
ref #53
新增
Radio
组件Select
组件Input.Group
组件Form
组件,只封装了样式,逻辑在website
使用react-hook-form
实现修改
Input
组件样式Nav
组件拆分成Nav.Group
和Nav.Item
。Nav
保留原来的用法,只是现在可以更灵活的控制 activeStrictMode
,这功能会导致开发阶段react-beadutify-dnd
异常TODO
当项键/值为空时按退格键删除该项一些问题
确认下工作量,我这个 PR 是只做原站的/subject/xx/edit_detail
页面吗。还是说把整个 wiki 编辑的所有页面都做了 @trim21路由是必须按照原站的写吗,原站的一些路由有些问题,比如/subject/xx/edit
是历史记录等等。另外,由于 wiki 页面的路由和 subject 页面的路由混在一起了,也导致一些组件复用问题。如果不需要百分百复刻原站的话,使用/subject/xxx/wiki/xxx
可能更好