当前位置: 首页 > news >正文

卢湾品牌网站建设/seo品牌推广方法

卢湾品牌网站建设,seo品牌推广方法,专业的开发网站建设,一级造价工程师分几个专业shadcn/ui很灵活可以方便的自己修改class样式,但是仅仅一个确认删除弹窗,需要拷贝太多代码和导入太多包,重复的代码量太多,不利于代码维护。所以进一步封装以符合项目中使用。 封装cx-alert-dialog.tsx import {AlertDialog,Ale…

shadcn/ui很灵活可以方便的自己修改class样式,但是仅仅一个确认删除弹窗,需要拷贝太多代码和导入太多包,重复的代码量太多,不利于代码维护。所以进一步封装以符合项目中使用。

封装cx-alert-dialog.tsx

import {AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"
import { CustomButton } from "./custom-button"export const CxAlertDialog = (props: {visible: boolean, title?: string, content?: string, cancelText?: string, okText?: string,okColor?: string,loading?: boolean,disabled: boolean,onClose: ()=>void,onOk: ()=>void,
}) => {const buildOkButton = () => {if(props.okColor == "red") {return (<CustomButton variant="destructive" loading={props.loading} disabled={props.disabled} onClick={props.onOk}>{props.okText}</CustomButton>)}else {return (<CustomButton loading={props.loading} disabled={props.disabled} onClick={props.onOk}>{props.okText}</CustomButton>)}}return (<><AlertDialog open={props.visible}><AlertDialogContent><AlertDialogHeader><AlertDialogTitle>{props.title}</AlertDialogTitle><AlertDialogDescription>{props.content}</AlertDialogDescription></AlertDialogHeader><AlertDialogFooter><AlertDialogCancel onClick={props.onClose} disabled={props.disabled}>{props.cancelText}</AlertDialogCancel>{ buildOkButton() }{/* {props.okColor == "red"?<AlertDialogAction className="bg-red-500 hover:bg-red-600" onClick={props.onOk}>{props.okText}</AlertDialogAction>:<AlertDialogAction onClick={props.onOk}>{props.okText}</AlertDialogAction>} */}</AlertDialogFooter></AlertDialogContent></AlertDialog></>)
}

custom-button.tsx

"use client"
import React, { MouseEventHandler } from "react";
import { Button } from "../ui/button";
import LcIcon from "./lc-icon";
import { cn } from "@/lib/utils";/** * Button扩展,增加图标功能 * <CustomButton icon="Loader" onClick={handleSubmit}>Button</CustomButton>* */
export const CustomButton = (props: {variant?: string,size?: string,className?: string,iconClassName?: string,icon?: string, loading?: booleandisabled?: boolean,type?: string,onClick?: MouseEventHandler<HTMLButtonElement>,children?: any
}) => {const buildIcon = () => {if(props.loading != null && props.loading) {return <LcIcon name="Loader" size={16} className={cn("animate-spin", props.iconClassName ?? 'mr-1' )}/>}else if(props.icon != null) {return <LcIcon name={props.icon} size={16} className={props.iconClassName ?? 'mr-1'}/>}return ""}return (<Button size={props.size as any ?? "default"} variant={props.variant as any ?? "default"} type={props.type ?? 'button' as any} className={props.className} disabled={props.disabled} onClick={props.onClick}>{ buildIcon() }{ props.children }</Button>)
}

使用CxAlertDialog组件

const [delAlertVisible, setDelAlertVisible]:[boolean, Dispatch<SetStateAction<boolean>>] = React.useState(false);const [delAlertLoading, setDelAlertLoading]:[boolean, Dispatch<SetStateAction<boolean>>] = React.useState(false);const currOperId = useRef(BigInt(0))const handleDelAlertOk = async () => {setDelAlertLoading(true)await ChapterApi.del(Number(props.docId), currOperId.current).catch((e) => ErrUtils.apiHandle(e)).then((resp)=>{//console.log(resp)if(!resp) returnif(resp?.code == RespCode.Success) {setDelAlertVisible(false)ToastUtils.success({ msg: resp?.msg })currChapterId.current = ""refresh()} else {ToastUtils.error({ msg: resp?.msg ?? "22" })}}).finally(()=>{setDelAlertLoading(false)})}const buildDel = () => {return (<CxAlertDialog visible={delAlertVisible} okColor="red" title="提示" content="确认删除?" cancelText="取消" okText="删除"onClose={() => setDelAlertVisible(false)} onOk={() => handleDelAlertOk()} loading={delAlertLoading} disabled={delAlertLoading}/>)}
http://www.whsansanxincailiao.cn/news/31946016.html

相关文章:

  • 做软件与做网站建设有什么区别/宁波seo网络推广软件系统
  • 网页版面/东莞seo托管
  • 站长工具国产2023/推一手新闻发稿平台
  • 2o17甘孜建设网站/宁波seo推广定制
  • 乌鲁木齐市建设委员会网站/网络推广网站排行榜
  • 重庆市场调研公司/上海百网优seo优化公司
  • 国办政府网站建设/seo技巧课程
  • 设计常用网站/企业建站公司
  • 太原市网站制作公司/自媒体平台排名前十
  • 网络网站如何推广/在线营销推广
  • 网站付费推广方式/营销顾问公司
  • 比较好看的网站设计/策划是做什么的
  • 芒市网站建设/seo是什么字
  • 个人网站源代码/上海优化外包公司排名
  • wordpress动漫小人/班级优化大师免费下载电脑版
  • php网站开发要学什么软件/列举常见的网络营销工具
  • 本人找做钢筋笼的活网站/百度平台营销收费标准
  • 乐陵建设网站/谷歌搜图
  • 清河县做网站/做一个个人网站
  • 一 网站开发背景/企业网站托管
  • 天天新品网做网站/googleplaystore
  • 网站渗透案例/浙江新手网络推广
  • 山西网站建设制作推广/信息检索关键词提取方法
  • 装饰行业网站模板/株洲seo
  • 旺苍网站建设/关键词优化好
  • 网站排名推广自己怎么做/最新一周新闻
  • 淮北网站建设/网站seo
  • 新浪云服务器做网站/怎么自己建立网站
  • 推荐做pc端网站/怎么做推广网站
  • 做网站国外访问/天津seo网站管理