perf(web): 使用map查找推送失败的源

This commit is contained in:
Xwite
2023-05-07 11:40:33 +08:00
parent 7d47970f70
commit 4874558fe8
3 changed files with 27 additions and 26 deletions
+7 -3
View File
@@ -4,7 +4,7 @@
border
:label="sourceUrl"
:class="{
error: errorPushSources.includes(source),
error: isSaveError,
edit: sourceUrl == currentSourceUrl,
}"
>
@@ -17,12 +17,16 @@
import { Edit } from "@element-plus/icons-vue";
const props = defineProps(["source"]);
const sourceUrl = props.source.bookSourceUrl || props.source.sourceUrl;
const store = useSourceStore();
const { errorPushSources, currentSourceUrl } = storeToRefs(store);
const { savedSourcesMap, currentSourceUrl, sourceUrlKey } = storeToRefs(store);
const sourceUrl = computed(() => props.source[sourceUrlKey.value]);
const handleSourceClick = (source) => {
store.changeCurrentSource(source);
};
const isSaveError = computed(() => {
if (savedSourcesMap.value.size == 0) return false;
return !savedSourcesMap.value.has(sourceUrl.value);
});
</script>
<style lang="scss" scoped>
:deep(.el-checkbox__label) {
+4 -3
View File
@@ -50,14 +50,15 @@ import SourceItem from "./SourceItem.vue";
const store = useSourceStore();
const sourceUrlSelect = ref([]);
const searchKey = ref("");
const { sources, sourcesMap, sourceUrlKey } = storeToRefs(store);
const { sources, sourcesMap } = storeToRefs(store);
const isBookSource = computed(() => {
return /bookSource/.test(window.location.href);
});
const sourceSelect = computed(() => {
if (sourceUrlSelect.value.length == 0) return [];
let searchKey = sourceUrlKey.value;
return sourceUrlSelect.value.map(sourceUrl => sourcesMap.value.get(sourceUrl));
return sourceUrlSelect.value.map(
(sourceUrl) => sourcesMap.value.get(sourceUrl) ?? {}
);
});
const deleteSelectSources = () => {
API.deleteSource(sourceSelect.value).then(({ data }) => {