Skip to content

Commit

Permalink
chore: 增加不同情况下的流量显示
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 24, 2024
1 parent 67b678f commit fb04c6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/SubListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ const flow = computed(() => {
if (props.type === "sub") {
const urlList = Object.keys(flows.value);
const localOnly = props.sub.source === 'local' && !['localFirst', 'remoteFirst'].includes(props.sub.mergeSources)
if (localOnly) return t("subPage.subItem.local");
if (localOnly && !props.sub.subUserinfo) return t("subPage.subItem.local");
if (isFlowFetching.value && !urlList.includes(props.sub.url))
return t("subPage.subItem.loading");
const target = toRaw(flows.value[props.sub.url]);
const target = toRaw(flows.value[props.sub.url] || flows.value[props.sub.name]);
if (!target) {
return {
firstLine: t("subPage.subItem.noRecord"),
Expand Down
3 changes: 3 additions & 0 deletions src/utils/getFlowsUrlList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const getFlowsUrlList = (subs: Sub[]): string[][] => {
if (sub.url && !localOnly && !urlList.includes(sub.url)) {
urlList.push(sub.url);
nameList.push([sub.url, sub.name]);
} else if (sub.subUserinfo && !urlList.includes(sub.name)) {
urlList.push(sub.name);
nameList.push([sub.name, sub.name]);
}
});
return nameList.map(([raw, name]) => {
Expand Down
8 changes: 4 additions & 4 deletions src/views/SubEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -826,21 +826,21 @@ const urlValidator = (val: string): Promise<boolean> => {
};
watch([tag, form.subscriptions, subsSelectList], () => {
const selected = toRaw(form.subscriptions) || []
console.log(`form.subscriptions: ${selected}`)
// console.log(`form.subscriptions: ${selected}`)
const group = subsSelectList.value.filter(item => shouldShowElement(item[3])).map(item => item[0]) || []
// 1. group 中不包含 selected 中的任何元素, subCheckbox 为 false, subCheckboxIndeterminate 为 false
// 2. group 中包含 selected 中的任何元素, subCheckbox 为 true, subCheckboxIndeterminate 为 true
// 3. group 中包含 selected 中的所有元素, subCheckbox 为 true, subCheckboxIndeterminate 为 false
if (group.every(item => selected.includes(item))) {
console.log('group 中包含 selected 中的所有元素')
// console.log('group 中包含 selected 中的所有元素')
subCheckbox.value = true
subCheckboxIndeterminate.value = false
} else if (group.some(item => selected.includes(item))) {
console.log('group 中包含 selected 中的任意元素')
// console.log('group 中包含 selected 中的任意元素')
subCheckbox.value = true
subCheckboxIndeterminate.value = true
} else {
console.log('group 中不包含 selected 中的任意元素')
// console.log('group 中不包含 selected 中的任意元素')
subCheckbox.value = false
subCheckboxIndeterminate.value = false
}
Expand Down

0 comments on commit fb04c6f

Please sign in to comment.