|
@@ -128,12 +128,6 @@
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
- function getAllCheckedTags() {
|
|
|
|
- let elements = document.querySelectorAll('input[name="category"]:checked');
|
|
|
|
- // 获取values
|
|
|
|
- elements = Array.from(elements).map(ele => ele.value);
|
|
|
|
- return elements;
|
|
|
|
- }
|
|
|
|
|
|
|
|
function setTagsToLocal() {
|
|
function setTagsToLocal() {
|
|
// 如果是location.href 包含tag,则return,否则存储到localStorage
|
|
// 如果是location.href 包含tag,则return,否则存储到localStorage
|
|
@@ -141,7 +135,7 @@
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// 存储到localStorage
|
|
// 存储到localStorage
|
|
- let tags = getAllCheckedTags();
|
|
|
|
|
|
+ let tags = getSelectedCategories();
|
|
localStorage.setItem('tags', JSON.stringify(tags));
|
|
localStorage.setItem('tags', JSON.stringify(tags));
|
|
}
|
|
}
|
|
function getTagsFromLocal() {
|
|
function getTagsFromLocal() {
|
|
@@ -276,7 +270,8 @@
|
|
// 添加多选按钮选择的分类到内容前面
|
|
// 添加多选按钮选择的分类到内容前面
|
|
let updatedContent = content;
|
|
let updatedContent = content;
|
|
if (categories.length > 0) {
|
|
if (categories.length > 0) {
|
|
- updatedContent = `#${categories.join(' ')} ${content}`;
|
|
|
|
|
|
+ // 循环拼接类似 #tag #tag2 content
|
|
|
|
+ updatedContent = categories.map(tag => `#${tag}`).join(' ') + ' ' + content;
|
|
}
|
|
}
|
|
|
|
|
|
// updatedContent 去除尾部的\n,可能有多个
|
|
// updatedContent 去除尾部的\n,可能有多个
|