feat: 添加BI组件并优化多个页面样式和功能
refactor: 重构slideshow-box组件,移除帖子标签 fix: 修复item-bottom组件中QR码加载状态显示问题 style: 调整多个页面的CSS样式,包括字体大小和间距 perf: 优化save.js文件同步逻辑,支持更多模板格式 docs: 更新组件文档和注释 chore: 添加bi组件相关文件并配置监听同步 test: 更新测试用例以适应组件变更
This commit is contained in:
14
js/save.js
14
js/save.js
@@ -29,6 +29,9 @@ const watchList = {
|
||||
"../component/hot-tag/hot-tag.txt": "../component/hot-tag/hot-tag.js",
|
||||
// 监听 hot-search.txt,同步到 hot-search.js
|
||||
"../component/hot-search/hot-search.txt": "../component/hot-search/hot-search.js",
|
||||
|
||||
// 监听 bi.txt,同步到 bi.js
|
||||
"../component/bi/bi.txt": "../component/bi/bi.js",
|
||||
|
||||
// 可添加更多文件(格式:'txt路径': 'js路径')
|
||||
// './component/other/other.txt': './component/other/other.js',
|
||||
@@ -56,12 +59,19 @@ function syncContent(txtPath, jsPath) {
|
||||
|
||||
// 匹配 template: `...` 结构,替换反引号内的内容
|
||||
const templateRegex = /(template:\s*)(`[^`]*`)/;
|
||||
// 匹配 template.innerHTML = `...` 结构
|
||||
const innerHTMLRegex = /(template\.innerHTML\s*=\s*)(`[^`]*`)/;
|
||||
|
||||
if (templateRegex.test(jsContent)) {
|
||||
jsContent = jsContent.replace(templateRegex, `$1\`${txtContent}\``);
|
||||
fs.writeFileSync(jsPath, jsContent, "utf8");
|
||||
console.log(`✅ 同步成功:${path.basename(txtPath)} → ${path.basename(jsPath)}`);
|
||||
console.log(`✅ 同步成功:${path.basename(txtPath)} → ${path.basename(jsPath)} (template格式)`);
|
||||
} else if (innerHTMLRegex.test(jsContent)) {
|
||||
jsContent = jsContent.replace(innerHTMLRegex, `$1\`${txtContent}\``);
|
||||
fs.writeFileSync(jsPath, jsContent, "utf8");
|
||||
console.log(`✅ 同步成功:${path.basename(txtPath)} → ${path.basename(jsPath)} (innerHTML格式)`);
|
||||
} else {
|
||||
console.error(`❌ 格式错误:${path.basename(jsPath)} 中未找到 template: \`...\``);
|
||||
console.error(`❌ 格式错误:${path.basename(jsPath)} 中未找到 template: \`...\` 或 template.innerHTML = \`...\``);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`❌ 同步失败:${err.message}`);
|
||||
|
||||
Reference in New Issue
Block a user