mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
style(modules/web): lint code with eslint
This commit is contained in:
@@ -57,14 +57,12 @@ const props = defineProps(["books", "isSearch"]);
|
||||
const emit = defineEmits(["bookClick"]);
|
||||
const handleClick = (book) => emit("bookClick", book);
|
||||
const getCover = (coverUrl) => {
|
||||
return isLegadoUrl(coverUrl)
|
||||
? API.getProxyCoverUrl(coverUrl) : coverUrl
|
||||
return isLegadoUrl(coverUrl) ? API.getProxyCoverUrl(coverUrl) : coverUrl;
|
||||
};
|
||||
const proxyImage = (event) => {
|
||||
event.target.src = API.getProxyCoverUrl(event.target.src);
|
||||
};
|
||||
|
||||
|
||||
const subJustify = computed(() =>
|
||||
props.isSearch ? "space-between" : "flex-start",
|
||||
);
|
||||
|
||||
@@ -34,11 +34,15 @@ const props = defineProps({
|
||||
const getImageSrc = (content) => {
|
||||
const imgPattern = /<img[^>]*src="([^"]*(?:"[^>]+\})?)"[^>]*>/;
|
||||
const src = content.match(imgPattern)[1];
|
||||
if (isLegadoUrl(src)) return API.getProxyImageUrl(src, useBookStore().config.readWidth)
|
||||
if (isLegadoUrl(src))
|
||||
return API.getProxyImageUrl(src, useBookStore().config.readWidth);
|
||||
return src;
|
||||
};
|
||||
const proxyImage = (event) => {
|
||||
event.target.src = API.getProxyImageUrl(event.target.src, useBookStore().config.readWidth);
|
||||
event.target.src = API.getProxyImageUrl(
|
||||
event.target.src,
|
||||
useBookStore().config.readWidth,
|
||||
);
|
||||
};
|
||||
|
||||
const calculateWordCount = (paragraph) => {
|
||||
|
||||
@@ -27,10 +27,7 @@ import CatalogItem from "./CatalogItem.vue";
|
||||
|
||||
const store = useBookStore();
|
||||
|
||||
const {
|
||||
catalog,
|
||||
popCataVisible, miniInterface
|
||||
} = storeToRefs(store);
|
||||
const { catalog, popCataVisible, miniInterface } = storeToRefs(store);
|
||||
|
||||
//主题
|
||||
const isNight = computed(() => store.theme);
|
||||
@@ -89,7 +86,6 @@ const gotoChapter = (note) => {
|
||||
store.saveBookProgress();
|
||||
emit("getContent", chapterIndex);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -68,10 +68,7 @@
|
||||
"
|
||||
>确定</el-button
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="loadFontFromURL"
|
||||
<el-button type="primary" size="small" @click="loadFontFromURL"
|
||||
>网络下载</el-button
|
||||
>
|
||||
</div>
|
||||
@@ -196,14 +193,14 @@ watch(
|
||||
API.saveReadConfig(newValue);
|
||||
},
|
||||
{
|
||||
deep: 2 //深度为2
|
||||
}
|
||||
)
|
||||
deep: 2, //深度为2
|
||||
},
|
||||
);
|
||||
|
||||
//主题颜色
|
||||
const theme = computed(() => store.theme);
|
||||
const isNight = computed(() => store.isNight);
|
||||
const moonIcon = computed(() => theme.value == 6 ? "" : "");
|
||||
const moonIcon = computed(() => (theme.value == 6 ? "" : ""));
|
||||
const themeColors = [
|
||||
{
|
||||
background: "rgba(250, 245, 235, 0.8)",
|
||||
@@ -234,7 +231,7 @@ const popupTheme = computed(() => {
|
||||
});
|
||||
const setTheme = (theme) => {
|
||||
store.config.theme = theme;
|
||||
}
|
||||
};
|
||||
|
||||
//预置字体
|
||||
const fonts = ref(["雅黑", "宋体", "楷书"]);
|
||||
@@ -253,51 +250,45 @@ const setCustomFont = () => {
|
||||
};
|
||||
// 加载网络字体
|
||||
const loadFontFromURL = () => {
|
||||
ElMessageBox.prompt(
|
||||
"请输入 字体网络链接",
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
inputPattern: /^https?:.+$/,
|
||||
inputErrorMessage: "url 形式不正确",
|
||||
beforeClose: (action, instance, done) => {
|
||||
if (action === "confirm") {
|
||||
instance.confirmButtonLoading = true;
|
||||
instance.confirmButtonText = "下载中……";
|
||||
// instance.inputValue
|
||||
const url = instance.inputValue
|
||||
if (typeof FontFace !== "function") {
|
||||
ElMessage.error("浏览器不支持FontFace");
|
||||
return done();
|
||||
}
|
||||
const fontface = new FontFace(
|
||||
customFontName.value,
|
||||
`url("${url}")`
|
||||
)
|
||||
//@ts-ignore
|
||||
document.fonts.add(fontface);
|
||||
fontface.load()
|
||||
//API.getBookShelf()
|
||||
.then(function () {
|
||||
instance.confirmButtonLoading = false;
|
||||
ElMessage.info("字体加载成功!");
|
||||
setCustomFont();
|
||||
done();
|
||||
})
|
||||
.catch(function (error) {
|
||||
instance.confirmButtonLoading = false;
|
||||
instance.confirmButtonText = "确定";
|
||||
ElMessage.error("下载失败,请检查您输入的 url");
|
||||
throw error;
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
ElMessageBox.prompt("请输入 字体网络链接", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
inputPattern: /^https?:.+$/,
|
||||
inputErrorMessage: "url 形式不正确",
|
||||
beforeClose: (action, instance, done) => {
|
||||
if (action === "confirm") {
|
||||
instance.confirmButtonLoading = true;
|
||||
instance.confirmButtonText = "下载中……";
|
||||
// instance.inputValue
|
||||
const url = instance.inputValue;
|
||||
if (typeof FontFace !== "function") {
|
||||
ElMessage.error("浏览器不支持FontFace");
|
||||
return done();
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
const fontface = new FontFace(customFontName.value, `url("${url}")`);
|
||||
//@ts-ignore
|
||||
document.fonts.add(fontface);
|
||||
fontface
|
||||
.load()
|
||||
//API.getBookShelf()
|
||||
.then(function () {
|
||||
instance.confirmButtonLoading = false;
|
||||
ElMessage.info("字体加载成功!");
|
||||
setCustomFont();
|
||||
done();
|
||||
})
|
||||
.catch(function (error) {
|
||||
instance.confirmButtonLoading = false;
|
||||
instance.confirmButtonText = "确定";
|
||||
ElMessage.error("下载失败,请检查您输入的 url");
|
||||
throw error;
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
//字体大小
|
||||
const fontSize = computed(() => {
|
||||
|
||||
@@ -44,8 +44,8 @@ const startDebug = async () => {
|
||||
try {
|
||||
await API.saveSource(store.currentSource);
|
||||
} catch (e) {
|
||||
store.debugFinish()
|
||||
throw e
|
||||
store.debugFinish();
|
||||
throw e;
|
||||
}
|
||||
API.debug(
|
||||
store.currentSourceUrl,
|
||||
|
||||
@@ -26,11 +26,11 @@ import { Link } from "@element-plus/icons-vue";
|
||||
<el-link :icon="Link" href="/help/#httpTTSHelp" target="_blank"
|
||||
>在线朗读规则</el-link
|
||||
><br />
|
||||
<el-link :icon="Link" href="/help/#webDavBookHelp" target="_blank"
|
||||
> WebDav书籍简明使用教程</el-link
|
||||
<el-link :icon="Link" href="/help/#webDavBookHelp" target="_blank">
|
||||
WebDav书籍简明使用教程</el-link
|
||||
><br />
|
||||
<el-link :icon="Link" href="/help/#webDavHelp" target="_blank"
|
||||
> WebDav备份教程</el-link
|
||||
<el-link :icon="Link" href="/help/#webDavHelp" target="_blank">
|
||||
WebDav备份教程</el-link
|
||||
><br />
|
||||
<el-link :icon="Link" href="https://regexr-cn.com/" target="_blank"
|
||||
>正则表达式在线验证工具</el-link
|
||||
|
||||
@@ -54,7 +54,7 @@ import SourceItem from "./SourceItem.vue";
|
||||
const store = useSourceStore();
|
||||
const sourceUrlSelect = ref([]);
|
||||
const searchKey = ref("");
|
||||
const sources = computed(() => store.sources);
|
||||
const sources = computed(() => store.sources);
|
||||
|
||||
// 筛选源
|
||||
/** @type Ref<import('@/source').Source[]> */
|
||||
|
||||
Reference in New Issue
Block a user