perf(web): 使用map查找推送失败的源
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user