
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@chenng99999/easymodal
Advanced tools
一个简单易用的原生弹窗组件库,支持样式隔离和跨框架使用。
npm install @chenng99999/easymodal
import { EasyModal } from '@chenng99999/easymodal';
// 显示提示弹窗
const result = await EasyModal.alert({
title: '提示',
content: '这是一个提示信息'
});
// 显示确认弹窗
const result = await EasyModal.confirm({
title: '确认',
content: '您确定要执行这个操作吗?'
});
<script src="https://unpkg.com/@chenng99999/easymodal/dist/index.js"></script>
<script>
const EasyModal = window.EasyModal;
EasyModal.alert({
title: '提示',
content: '这是一个提示信息'
});
</script>
EasyModal.alert(options)
显示提示弹窗,只有确定按钮。
EasyModal.confirm(options)
显示确认弹窗,有确定和取消按钮。
EasyModal.warning(options)
显示警告弹窗,有警告和取消按钮。
EasyModal.info(options)
显示信息弹窗,只有确定按钮。
interface ModalOptions {
// 基础配置
title?: string; // 弹窗标题
content: string | string[]; // 弹窗内容,支持HTML
// 按钮文本
confirmText?: string; // 确认按钮文本,默认"确定"
cancelText?: string; // 取消按钮文本,默认"取消"
warningText?: string; // 警告按钮文本,默认"警告"
// 样式配置
theme?: 'default' | 'dark' | 'minimal'; // 主题
width?: string | number; // 弹窗宽度
maxWidth?: string | number; // 最大宽度
// 行为配置
countdown?: number; // 倒计时秒数
showClose?: boolean; // 是否显示关闭按钮
maskClosable?: boolean; // 点击遮罩是否关闭
escClosable?: boolean; // 按ESC是否关闭
// 回调函数
onConfirm?: () => void | Promise<void>;
onCancel?: () => void | Promise<void>;
onWarning?: () => void | Promise<void>;
onClose?: () => void | Promise<void>;
onOpen?: () => void | Promise<void>;
}
所有方法都返回Promise,resolve的值为:
interface ModalResult {
confirmed: boolean; // 是否确认
action: 'confirm' | 'cancel' | 'warning' | 'close'; // 用户操作
statusCode?: number; // 状态码(如果设置)
}
我们提供了5种精美的主题,满足不同的设计需求:
现代化的设计风格,清晰的层次结构,优雅的动画效果
EasyModal.alert({
title: '默认主题',
content: '现代化的Shadcn设计风格',
theme: 'default' // 可省略,默认值
});
优雅的暗色调界面,减少眼部疲劳,适合低光环境
EasyModal.alert({
title: '深色主题',
content: '优雅的暗色调界面',
theme: 'dark'
});
注重简洁性,去除多余装饰,专注于内容本身
EasyModal.alert({
title: '简约主题',
content: '简洁明了的设计',
theme: 'minimal'
});
现代的毛玻璃效果,创造层次丰富的视觉体验
EasyModal.alert({
title: '毛玻璃主题',
content: '现代的毛玻璃效果',
theme: 'glass'
});
鲜明的色彩和圆润的设计,友好现代的用户体验
EasyModal.alert({
title: 'DaisyUI主题',
content: '友好现代的用户体验',
theme: 'daisyui'
});
const modal = PluginModal.create({
type: 'custom',
title: '自定义弹窗',
content: '这是自定义内容',
showClose: true
});
await modal.show();
// 动态更新内容
modal.updateContent('新的内容');
modal.updateTitle('新的标题');
// 手动关闭
modal.hide();
PluginModal.alert({
title: '倒计时弹窗',
content: '这个弹窗将在5秒后自动关闭',
countdown: 5
});
const result = await PluginModal.confirm({
title: '异步操作',
content: '点击确定后将执行异步操作',
onConfirm: async () => {
// 执行异步操作
await someAsyncOperation();
}
});
PluginModal.alert({
title: '多行内容',
content: [
'第一行内容',
'第二行内容',
'<strong>支持HTML标签</strong>'
]
});
使用Shadow DOM技术,确保弹窗样式不会被页面样式影响,也不会影响页面样式。这对于浏览器插件开发尤其重要。
零依赖,压缩后仅几KB大小,不会增加项目负担。
支持ES模块、CommonJS、UMD等多种模块格式,可以在任何JavaScript环境中使用。
考虑了插件开发的特殊需求,如样式隔离、跨域兼容等问题。
MIT License
欢迎提交Issue和Pull Request!
如果您在使用过程中遇到问题,请提交Issue或联系我们。
FAQs
The npm package @chenng99999/easymodal receives a total of 14 weekly downloads. As such, @chenng99999/easymodal popularity was classified as not popular.
We found that @chenng99999/easymodal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.