Skip to content

Commit

Permalink
feat: 记忆分类选择
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 19, 2024
1 parent a436f5f commit 0c81e20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.202",
"version": "2.14.203",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
15 changes: 14 additions & 1 deletion src/views/Sub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ const touchStartY = ref(null);
const touchStartX = ref(null);
const sortFailed = ref(false);
const hasUntagged = ref(false);
const getTag = () => {
return localStorage.getItem('sub-tag') || 'all'
}
const tag = ref(getTag());
const tags = computed(() => {
if(!hasSubs.value && !hasCollections.value) return []
// 从 subs 和 collections 中获取所有的 tag, 去重
Expand Down Expand Up @@ -289,9 +293,13 @@ const tags = computed(() => {
const result = [{ label: t("specificWord.all"), value: "all" }, ...tags]
if(hasUntagged.value) result.push({ label: t("specificWord.untagged"), value: "untagged" })
if (!result.find(i => i.value === tag.value)) {
tag.value = 'all'
}
return result
});
const tag = ref('all');
const filterdSubsCount = computed(() => {
if(tag.value === 'all') return subs.value.length
if(tag.value === 'untagged') return subs.value.filter(i => !Array.isArray(i.tag) || i.tag.length === 0).length
Expand Down Expand Up @@ -435,6 +443,11 @@ const toggleFold = (type) => {
// };
const setTag = (current) => {
tag.value = current
if (current === 'all') {
localStorage.removeItem('sub-tag')
} else {
localStorage.setItem('sub-tag', current)
}
};
const shouldShowElement = (element) => {
if(tag.value === 'all') return true
Expand Down

0 comments on commit 0c81e20

Please sign in to comment.