diff --git a/apps/dg-college/第一册,世界的真相/chapter_3 经济就是世界的运作规律.md b/apps/dg-college/第一册,世界的真相/chapter_3 经济就是世界的运作规律.md index cb02147..7f4529b 100644 --- a/apps/dg-college/第一册,世界的真相/chapter_3 经济就是世界的运作规律.md +++ b/apps/dg-college/第一册,世界的真相/chapter_3 经济就是世界的运作规律.md @@ -94,6 +94,36 @@ 如果一个国家,不想背债,那就要上门槛,不让外资轻易进入搞价格战,不能把价格搞得非常之低。 +## 统治者,银行家的剥削手段 + +通货膨胀,稀释普通人财富。 + +通货膨胀并不直接等于经济泡沫,泡沫是分领域的,只有供不应求的领域才有泡沫,例如,房地产,芯片。 + +想要规避通货膨胀,就要把所有的钱,以保值的形式储蓄,只保留必要的现金流。 + +如果需要大量的现金流,那就贷款,把通胀的损失转嫁给银行。 + +如果银行也随通胀而提高利率,那就要懂得非法融资,以会员制,充值,押金等方式,变相获得低息贷款。 + +产能过剩,十分有利于控制着稀缺土地的统治者利益,各种,水电,油,电信,房价,只要价格不降反升,就能实现收割。 + +产能过剩,还能节约给公务员发的年薪,理由就用经济不好,反正物价便宜,对公务员生活影响不是很大。 + +普通人,之要还在使用法币,还在支付电信和房租,就注定是被剥削的对象。 + +## 统治者只需提高生存成本,即使不打价格战,仍可以变相打压所有行业 + +房租,电信,水电,这几个是拉高人工成本的关键,收入不变,刚需费用上升,人群购买力降低,利润降低,引发变相价格战。 + +## 线下倒卖,和线上倒卖 + +如果你是一个旅行者,每到一个城市,都需要把 + + + + + diff --git a/note/rust和ts对比.md b/note/rust和ts对比.md index c70a56e..27cc433 100644 --- a/note/rust和ts对比.md +++ b/note/rust和ts对比.md @@ -122,3 +122,7 @@ index.js,作为入口文件名,不同语法的,会插入第二扩展名, 但如如果是给 ts 搞,那就固定为 index.d.ts 。 +## useState的局限性,每次发信号都强制渲染,造成很多不必要的渲染 + +## 状态提升,加上复杂状态结构,能解决嵌套通讯的任何问题 + diff --git a/packages/ui-react/.npmrc b/packages/ui-react/.npmrc new file mode 100644 index 0000000..4056773 --- /dev/null +++ b/packages/ui-react/.npmrc @@ -0,0 +1,2 @@ +registry=https://registry.npmmirror.com +node-linker=hoisted \ No newline at end of file diff --git a/packages/ui-react/demo/App.tsx b/packages/ui-react/demo/App.tsx index b93e820..a06c8e2 100644 --- a/packages/ui-react/demo/App.tsx +++ b/packages/ui-react/demo/App.tsx @@ -3,14 +3,18 @@ import { ButtonGallery } from "./gallery/button-gallery"; import { MenuGallery } from "./gallery/menu-gallery"; import { PopoverGallery } from "./gallery/popover-gallery"; import "../src/index.css"; +import { BadgeGallery } from "./gallery/badge-gallery"; +import { TagGallery } from "./gallery/tag-gallery"; function App() { return (
+ +
); diff --git a/packages/ui-react/demo/common/iw.tsx b/packages/ui-react/demo/common/iw.tsx index 26652c8..44cb34a 100644 --- a/packages/ui-react/demo/common/iw.tsx +++ b/packages/ui-react/demo/common/iw.tsx @@ -4,7 +4,7 @@ export const IW = ({ children }: { children: ReactNode }) => { return (
{ + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/packages/ui-react/demo/gallery/menu-gallery.tsx b/packages/ui-react/demo/gallery/menu-gallery.tsx index 24175ea..3ba97d3 100644 --- a/packages/ui-react/demo/gallery/menu-gallery.tsx +++ b/packages/ui-react/demo/gallery/menu-gallery.tsx @@ -14,7 +14,7 @@ export const MenuGallery = () => { return ( - + diff --git a/packages/ui-react/src/components/menu/menu-radio-item-group.tsx b/packages/ui-react/src/components/menu/menu-radio-item-group.tsx index 48ce040..231b90d 100644 --- a/packages/ui-react/src/components/menu/menu-radio-item-group.tsx +++ b/packages/ui-react/src/components/menu/menu-radio-item-group.tsx @@ -1,10 +1,8 @@ - import type { CommonProps } from "../../utils/common-props"; -import { useMenuContext } from "./use-menu-context"; import { RadioboxInputGroup } from "../radiobox-input/radiobox-input-group"; +import { useMenuContext } from "./use-menu-context"; export type MenuRadioItemGroupProps = CommonProps & { - size?: "sm" | "md"; name: string; defaultSelectedValue?: string; onChange?: (nextSelected?: string) => void; @@ -13,7 +11,6 @@ export type MenuRadioItemGroupProps = CommonProps & { export const MenuRadioItemGroup = (props: MenuRadioItemGroupProps) => { const { - size = "sm", defaultSelectedValue, name, onChange, @@ -21,14 +18,16 @@ export const MenuRadioItemGroup = (props: MenuRadioItemGroupProps) => { children, } = props; - const { size: menuSize } = useMenuContext()!; + // ======================================= - const currentSize = menuSize ?? size; + const { size } = useMenuContext()!; + + // ======================================= return ( void; @@ -32,7 +32,6 @@ export type MenuRadioItemProps = CommonProps & { export const MenuRadioItem = (props: MenuRadioItemProps) => { const { - size: propSize = "sm", value, iconSvg, hotkey, @@ -52,33 +51,33 @@ export const MenuRadioItem = (props: MenuRadioItemProps) => { ); const inputRef = useRef(null); - // =============== Menu Context Consumer ==================================================================== + // ==================================================================== - const menuContext = useMenuContext(); - const size = menuContext?.size ?? propSize; + // 获取来自所属菜单的公共状态 + const { size } = useMenuContext()!; - const stateRegistry = menuContext?.stateRegistry; - const stateKeyRef = useRef(null); + // ==================================================================== - useEffect(() => { - stateKeyRef.current = useId(); - stateRegistry?.insertKey(stateKeyRef.current); - stateRegistry?.updateValue(stateKeyRef.current, { + const { stateRegistryRef } = useMenuDropdownContext()!; + const stateKey = useId(); + + // 此函数一定会在 “父同名函数” 之前执行,在 “子同名函数” 之后执行。 + useLayoutEffect(() => { + stateRegistryRef.current.insertKey(stateKey); + stateRegistryRef.current.updateValue(stateKey, { hasIcon: iconSvg != undefined, hasCheckbox: true, hasIndicator: false, }); - return () => { - // 清除注册表里的数据,永远不会有无用 key - stateRegistry?.deleteEntry(stateKeyRef.current!); + stateRegistryRef.current.deleteEntry(stateKey); }; - }, []); + }); - // 后面渲染要用到 - const stateResult = menuContext?.stateResult; + // 当菜单搜集完毕,刷新时,此处总是拿到最终结果。 + const stateResult = stateRegistryRef.current.getResult(); - // =============== Menu Floating Context Consumer ==================================================================== + // =================================================================================== const menuFloatingContext = useMenuFloatingContext(); const { getItemProps, activeIndex } = menuFloatingContext!; @@ -91,7 +90,7 @@ export const MenuRadioItem = (props: MenuRadioItemProps) => { const rootClass = mergeClass( displayRecipe({ justifyContent: "between" }), containerRecipe({ hasFocusOutline: "false" }), - itemSizeRecipe({ size, shape: "rounded" }), + itemSizeRecipe({ size, shape: "rounded"}), variantRecipe({ variant: "ghost", isDisabled }), ); @@ -127,6 +126,8 @@ export const MenuRadioItem = (props: MenuRadioItemProps) => { onChange?.(nextChecked); } + // ========================================================= + return (