Skip to content

Commit

Permalink
feat: 组合订阅支持通过单条订阅的标签进行关联
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Oct 11, 2024
1 parent ed94a08 commit c09d939
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 8 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.270",
"version": "2.14.271",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
19 changes: 16 additions & 3 deletions src/components/SubListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,28 @@ const icon = computed(() => {
});
const collectionDetail = computed(() => {
const nameList = props?.collection.subscriptions || [];
if (nameList.length === 0) {
const subTags = props?.collection.subscriptionTags || [];
if (nameList.length === 0 && subTags.length === 0) {
return t("subPage.collectionItem.noSub");
} else {
const displayNameList = nameList.map((name) => {
const sub = subsStore.getOneSub(name);
return sub?.displayName || sub?.["display-name"] || sub.name;
});
return `${t("subPage.collectionItem.contain")}: ${displayNameList.join(
""
if(nameList.length === 0) {
return `${t("subPage.collectionItem.containTag")}: ${subTags.join(
", "
)}`;
}
if(subTags.length === 0) {
return `${t("subPage.collectionItem.contain")}: ${displayNameList.join(
", "
)}`;
}
return `${t("subPage.collectionItem.containTag")}: ${subTags.join(
", "
)} | ${t("subPage.collectionItem.contain")}: ${displayNameList.join(
", "
)}`;
}
});
Expand Down
9 changes: 7 additions & 2 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ export default {
officialChannel: 'Official channel:',
},
collectionItem: {
noSub: 'Not contains subscription',
contain: 'Contains subs',
noSub: 'No subscription included',
contain: 'Included subs',
containTag: 'Included subscription tags',
},
subItem: {
local: 'Local subscription',
Expand Down Expand Up @@ -240,6 +241,10 @@ export default {
label: 'Tag(s)',
placeholder: 'The tag(s) (separated by comma) will be used for grouping.',
},
subscriptionTags: {
label: 'Subscription Tag(s)',
placeholder: 'Include all subscriptions that contain one of these tag(s) (separated by comma)',
},
source: {
label: 'Source',
remote: 'Remote URL',
Expand Down
9 changes: 7 additions & 2 deletions src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export default {
},
collectionItem: {
noSub: '没有包含子订阅',
contain: '包含的订阅',
contain: '手动选择的订阅',
containTag: '关联的订阅标签',
},
subItem: {
local: '本地订阅',
Expand Down Expand Up @@ -240,6 +241,10 @@ export default {
label: '标签',
placeholder: '标签(用 , 分隔) 将用于分组',
},
subscriptionTags: {
label: '关联订阅标签',
placeholder: '使用标签关联单条订阅(用 , 分隔)',
},
source: {
label: '来源',
remote: '远程订阅',
Expand All @@ -261,7 +266,7 @@ export default {
isIllegal: '订阅链接格式非法',
},
subscriptions: {
label: '包含的订阅',
label: '手动选择的订阅',
},
content: {
label: '内容',
Expand Down
1 change: 1 addition & 0 deletions src/types/store/subsStore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface Collection {
displayName?: string;
process: Process[];
subscriptions: string[];
subscriptionTags?: string[];
icon?: string;
tag?: string[];
}
Expand Down
39 changes: 39 additions & 0 deletions src/views/SubEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@
</template>

<template v-else-if="editType === 'collections'">
<!-- subscriptionTags -->
<nut-form-item
:label="$t(`editorPage.subConfig.basic.subscriptionTags.label`)"
prop="subscriptionTags"
>
<nut-input
:border="false"
class="nut-input-text"
v-model.trim="form.subscriptionTags"
:placeholder="$t(`editorPage.subConfig.basic.subscriptionTags.placeholder`)"
type="text"
input-align="right"
left-icon="tips"
@click-left-icon="subscriptionTagsTips"
/>
</nut-form-item>
<nut-form-item
:label="$t(`editorPage.subConfig.basic.subscriptions.label`)+ selectedSubs"
prop="subscriptions"
Expand Down Expand Up @@ -544,6 +560,9 @@ watchEffect(() => {
form.tag = Array.isArray(sourceData.tag)
? sourceData.tag.join(", ")
: sourceData.tag;
form.subscriptionTags = Array.isArray(sourceData.subscriptionTags)
? sourceData.subscriptionTags.join(", ")
: sourceData.subscriptionTags;
switch (editType) {
case "collections":
Expand Down Expand Up @@ -732,6 +751,14 @@ const submit = () => {
.filter((item: string) => item.length)
),
];
data.subscriptionTags = [
...new Set(
(data.subscriptionTags || "")
.split(",")
.map((item: string) => item.trim())
.filter((item: string) => item.length)
),
];
data["display-name"] = data.displayName;
data.process = actionsToProcess(data.process, actionsList, ignoreList);
Expand Down Expand Up @@ -873,6 +900,18 @@ const urlValidator = (val: string): Promise<boolean> => {
lockScroll: false,
});
};
const subscriptionTagsTips = () => {
Dialog({
title: '组合订阅与单条订阅',
content: '组合订阅中将包含\n\n1. 含有关联订阅标签的单条订阅\n\n2. 手动选择的单条订阅\n\n举例: 设置了关联订阅标签为 "A, B" 后\n包含标签 "A" 或 "B" 的单条订阅将自动关联到此组合订阅',
popClass: 'auto-dialog',
textAlign: 'left',
okText: 'OK',
noCancelBtn: true,
closeOnPopstate: true,
lockScroll: false,
});
};
const urlTips = () => {
Dialog({
title: t('editorPage.subConfig.basic.url.tips.title'),
Expand Down

0 comments on commit c09d939

Please sign in to comment.