Skip to content

Commit

Permalink
Merge pull request #158 from GeoffreyChen777/electron-dev
Browse files Browse the repository at this point in the history
v2.0.4
  • Loading branch information
GeoffreyChen777 authored Oct 8, 2022
2 parents b1e2077 + fafadac commit 8aa6765
Show file tree
Hide file tree
Showing 32 changed files with 434 additions and 426 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/electron_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ jobs:
node-version: ${{ matrix.node-versions }}

- name: 'Install Node Module'
run: npm install --force
run: cp ./package.win.temp.json ./package.json && npm install --force

- name: 'Build and Package'
run: npm run build
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v2.0.4 08/10 2022

1. 全文搜索的高亮结果可以显示在 PDF 预览视图下。
2. 可调整详情面板的宽度。
3. 优化了对于预印本论文的判断规则。
4. 修复了内置 PDF 浏览视图下可能出现的遮挡 Bug。
5. 修复了 Markdown 渲染超出视图,以及无法渲然 HTML 图片的 Bug。
6. 修复了 MacOS Catalina 的兼容性 Bug。

## v2.0.3 02/10 2022

1. 为物理学和地球科学增添优化了元数据搜寻器以及预设推荐选择。Springer Nature, Elseivier Scopus, NASA Astrophysics Data System, SPIE: Inte. Society for Optics and Photonics.
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG_EN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v2.0.4 Oct 08 2022

1. Fulltext search mode: the highlights of the search results will be displayed in the PDF preview view.
2. Adjustable width of the detail panel.
3. Better rules for preprint papers.
4. Fixed a bug in the PDF preview view.
5. Fixed a bug in the markdown preview.
6. Fixed a compatibility issue in MacOS Catalina.

## v2.0.3 Oct 02 2022

1. Added some new metadata scrapers for Physics and Earth Science. Also provide a recommended presetting. Springer Nature, Elseivier Scopus, NASA Astrophysics Data System, SPIE: Inte. Society for Optics and Photonics
Expand Down
38 changes: 22 additions & 16 deletions app/interactors/render-interactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class RenderInteractor {
this.renderingPDF = null;
this.createPDFWorker();

this.markdownIt = new MarkdownIt().use(tm, {
this.markdownIt = new MarkdownIt({ html: true }).use(tm, {
engine: require("katex"),
delimiters: "dollars",
katexOptions: { macros: { "\\RR": "\\mathbb{R}" } },
Expand Down Expand Up @@ -118,27 +118,33 @@ export class RenderInteractor {
};
}

async renderMarkdown(content: string) {
async renderMarkdown(content: string, renderFull = false) {
try {
return this.markdownIt.render(content);
let renderContent;
let overflow;
if (!renderFull) {
const lines = content.split("\n");
const renderLines = lines.slice(0, 10)
overflow = lines.length > 10;
renderContent = renderLines.join("\n");
} else {
overflow = false;
renderContent = content;
}
return { renderedStr: this.markdownIt.render(renderContent), overflow: overflow };
} catch (e) {
console.error(e);
return "";
return { renderedStr: "", overflow: false };
}
}

async renderMarkdownFile(url: string) {
// Read content from file
try {
const content = await fsPromise.readFile(
url.replace("file://", ""),
"utf8"
);
return this.markdownIt.render(content);
} catch (e) {
console.error(e);
return "";
}
async renderMarkdownFile(url: string, renderFull = false) {
const content = await fsPromise.readFile(
url.replace("file://", ""),
"utf8"
);

return await this.renderMarkdown(content, renderFull);
}

async renderMath(content: string) {
Expand Down
1 change: 1 addition & 0 deletions app/locales/locales/en.GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"title": "Title",
"authors": "Authors",
"publicationyear": "Publication Year",
"pubyear": "Year",
"publicationtitle": "Publication",
"publicationtype": "Publication Type",
"addtime": "Add Time",
Expand Down
1 change: 1 addition & 0 deletions app/main/win_main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function setWindowsSpecificStyles(win: BrowserWindow | null) {
}
::-webkit-scrollbar {
width: 4px;
height: 4px;
}
::-webkit-scrollbar-corner {
Expand Down
2 changes: 2 additions & 0 deletions app/preference/preference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface PreferenceStore {
shortcutCopyKey: string;

sidebarWidth: number;
detailPanelWidth: number;
mainviewSortBy: string;
mainviewSortOrder: string;
mainviewType: string;
Expand Down Expand Up @@ -169,6 +170,7 @@ export const defaultPreferences: PreferenceStore = {
shortcutCopyKey: "CommandOrControl+Shift+K",

sidebarWidth: 20,
detailPanelWidth: 75,
mainviewSortBy: "addTime",
mainviewSortOrder: "desc",
mainviewType: "list",
Expand Down
35 changes: 13 additions & 22 deletions app/renderer/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,33 +134,24 @@ ol {
text-decoration: underline;
}





/* Track */
::-webkit-scrollbar-track {
background: var(--q-bg-secondary);
border-radius: 2px;
#detail-markdown-preview img {
margin-top: 15px;
margin-bottom: 15px;
}

/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 2px;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
#main-view .splitpanes--vertical>.splitpanes__splitter {
min-width: 4px !important;
border-right: 1px solid rgb(229 229 229);
background-color: rgba(0, 0, 0, 0) !important;
}

::-webkit-scrollbar {
width: 4px;
@media (prefers-color-scheme: dark) {
#main-view .splitpanes--vertical>.splitpanes__splitter {
border-right: 1px solid rgb(64, 64, 64);
}
}

::-webkit-scrollbar-corner {
background: transparent;
width: 0 !important;
height: 0 !important;
.splitpanes .splitpanes__pane {
transition: none !important;
}
2 changes: 1 addition & 1 deletion app/renderer/ui/app-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ onMounted(async () => {
</button>
</div> -->
<splitpanes @resized="onSidebarResized($event)">
<pane :key="1" min-size="12" :size="viewState.sidebarWidth">
<pane :key="1" min-size="12" :size="prefState.sidebarWidth">
<SidebarView class="sidebar-windows-bg" />
</pane>
<pane :key="2">
Expand Down
10 changes: 8 additions & 2 deletions app/renderer/ui/main-view/data-view/paper-data-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import TableTitle from "./components/table-title.vue";
// ================================
// State
// ================================
const viewState = MainRendererStateStore.useViewState();
const selectionState = MainRendererStateStore.useSelectionState();
const prefState = MainRendererStateStore.usePreferenceState();
Expand Down Expand Up @@ -93,7 +94,12 @@ const accessMainFile = async (index: number) => {
const paperEntity = paperEntities?.value[index];
if (paperEntity) {
const url = await window.appInteractor.access(paperEntity!.mainURL, false);
showingUrl.value = `./viewer/viewer.html?file=${url}`;
if (viewState.searchMode === "fulltext" && viewState.searchText !== "") {
showingUrl.value = `./viewer/viewer.html?file=${url}&search=${viewState.searchText}`;
} else {
showingUrl.value = `./viewer/viewer.html?file=${url}`;
}
} else {
showingUrl.value = "";
}
Expand Down Expand Up @@ -135,7 +141,7 @@ onMounted(() => {
</script>

<template>
<div id="data-view" class="grow pl-2">
<div id="data-view" class="pl-2">
<RecycleScroller
class="scroller pr-2 max-h-[calc(100vh-3rem)]"
:items="paperEntities"
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/ui/main-view/detail-view/components/code.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const onClick = (codeJSONstr: string) => {
</script>

<template>
<div class="flex flex-wrap mt-1 text-xs space-x-1">
<div class="flex flex-wrap mt-1 text-xs">
<div
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer"
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer mb-1 mr-1"
v-for="code in codes"
@click="onClick(code)"
>
Expand Down
47 changes: 19 additions & 28 deletions app/renderer/ui/main-view/detail-view/components/markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,41 @@ const renderedHTML = ref("");
const isExpanded = ref(false);
const isOverflow = ref(true);
const render = async () => {
const render = async (renderFull = false) => {
let rendered = false;
if (props.content) {
renderedHTML.value = await window.renderInteractor.renderMarkdown(
props.content.slice(4) || ""
);
const { renderedStr, overflow } =
await window.renderInteractor.renderMarkdown(
props.content.slice(4) || "",
renderFull
);
renderedHTML.value = renderedStr;
rendered = true;
isOverflow.value = overflow;
} else {
for (const url of props.sups || []) {
if (url.endsWith(".md") || url.endsWith(".markdown")) {
const mdURL = await window.appInteractor.access(url, false);
renderedHTML.value = await window.renderInteractor.renderMarkdownFile(
mdURL
);
const mdURL = await window.appInteractor.access(url, true);
const { renderedStr, overflow } =
await window.renderInteractor.renderMarkdownFile(mdURL, renderFull);
renderedHTML.value = renderedStr;
rendered = true;
isOverflow.value = overflow;
}
}
}
if (!rendered) {
renderedHTML.value = "";
isOverflow.value = false;
}
nextTick(() => {
isOverflow.value = renderedHTML.value.length > 0;
checkOverflow();
});
};
const markdownArea = ref();
const checkOverflow = () => {
const el = markdownArea.value;
if (el) {
const height = el.offsetHeight;
const scrollHeight = el.scrollHeight;
isOverflow.value = height < scrollHeight;
}
const onExpandClicked = async () => {
await render(!isExpanded.value);
isExpanded.value = !isExpanded.value;
};
onMounted(() => {
Expand All @@ -80,14 +78,7 @@ watch(props, (props, prevProps) => {

<div
class="invisible group-hover:visible hover:bg-neutral-300 hover:dark:bg-neutral-700 hover:drop-shadow-sm rounded-md p-1 cursor-pointer my-auto"
@click="
() => {
isExpanded = !isExpanded;
$nextTick(() => {
checkOverflow();
});
}
"
@click="onExpandClicked"
>
<BIconArrowsExpand
class="text-xxs text-neutral-400 dark:text-neutral-500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,23 @@ watch(
<BIconCloudArrowDown class="text-xs my-auto" />
<div class="text-xxs my-auto">webdav</div>
</div>
<div class="flex space-x-2" v-show="fileExistingStatus === 1">
<div class="flex flex-wrap" v-show="fileExistingStatus === 1">
<div
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer"
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer mb-1 mr-1"
@click="showFilePicker"
>
<BIconPlus class="text-xs my-auto" />
<div class="text-xxs my-auto">Choose</div>
</div>
<div
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer"
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer mb-1 mr-1"
@click="render"
>
<BIconArrowClockwise class="text-xs my-auto" />
<div class="text-xxs my-auto">Refresh</div>
</div>
<div
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer"
class="flex space-x-1 bg-neutral-200 dark:bg-neutral-700 rounded-md p-1 hover:bg-neutral-300 hover:dark:bg-neutral-600 hover:shadow-sm select-none cursor-pointer mb-1 mr-1"
@click="locatePDF"
>
<BIconSearch class="text-xs my-auto" />
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/ui/main-view/detail-view/feed-detail-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ watch(props, (props, prevProps) => {
<template>
<div
id="detail-view"
class="flex-none flex flex-col w-80 max-h-[calc(100vh-3rem)] pl-4 pr-2 pb-4 overflow-auto"
class="flex-none flex flex-col w-full max-h-[calc(100vh-3rem)] pl-4 pr-2 pb-4 overflow-auto"
>
<div
class="flex mr-2 mb-4 h-8 bg-accentlight dark:bg-accentdark text-neutral-50 rounded-md shadow-md cursor-pointer hover:shadow-lg"
Expand Down
Loading

0 comments on commit 8aa6765

Please sign in to comment.