MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / createModal

Function createModal

tech-study.js:2086–2231  ·  view source on GitHub ↗

* @description 创建模态框 * @param options 选项 * @returns

(options)

Source from the content-addressed store, hash-verified

2084 * @returns
2085 */
2086function createModal(options) {
2087 // 配置
2088 const { title, subTitle = '', to = '用户', content, type, from = 'tech-study.js', } = options;
2089 // 内容文本
2090 let contentText = '';
2091 if (Array.isArray(content)) {
2092 contentText = content.map((ct) => `<div>${ct}</div>`).join('');
2093 }
2094 else {
2095 contentText = content;
2096 }
2097 // 日期
2098 const dateTime = formatDateTime();
2099 // 类型html
2100 let typeHTML = '';
2101 if (type && type.length) {
2102 if (type === 'info') {
2103 typeHTML = `
2104 <svg
2105 viewBox="64 64 896 896"
2106 style="color: #1890ff; width: 18px; height: 18px"
2107 fill="currentColor"
2108 aria-hidden="true"
2109 >
2110 <path
2111 d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"
2112 ></path>
2113 </svg>`;
2114 }
2115 if (type === 'warn') {
2116 typeHTML = `
2117 <svg
2118 viewBox="64 64 896 896"
2119 style="color: #faad14; width: 18px; height: 18px"
2120 fill="currentColor"
2121 aria-hidden="true"
2122 >
2123 <path
2124 d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"
2125 ></path>
2126 </svg>
2127 `;
2128 }
2129 if (type === 'success') {
2130 typeHTML = `
2131 <svg
2132 viewBox="64 64 896 896"
2133 style="color: #52c41a; width: 18px; height: 18px"
2134 fill="currentColor"
2135 aria-hidden="true"
2136 >
2137 <path
2138 d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
2139 ></path>
2140 </svg>
2141 `;
2142 }
2143 if (type === 'fail') {

Callers 1

pushModalFunction · 0.70

Calls 2

formatDateTimeFunction · 0.70
getHighlightHTMLFunction · 0.70

Tested by

no test coverage detected