Skip to content

Commit

Permalink
feat: add guide view for new users (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyChen777 authored May 24, 2024
1 parent 9864e5d commit 6df1acb
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/common/services/preference-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface IPreferenceStore {
importedCSLStylesPath: string;

showPresetting: boolean;
showGuide: boolean;
showWelcome: boolean;
fontsize: "normal" | "large" | "larger";
}
Expand Down Expand Up @@ -211,6 +212,7 @@ const _defaultPreferences: IPreferenceStore = {
importedCSLStylesPath: "",

showPresetting: true,
showGuide: true,
showWelcome: true,
fontsize: "normal",
};
Expand Down
22 changes: 22 additions & 0 deletions app/locales/locales/en.GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,27 @@
"extensionscraper": "Scraper Extensions",
"extensionscraperrequired": "Please install the scraper extensions",
"extensionrecommend": "Recommened Extensions"
},
"guide": {
"import1title": "1. Import to the Library",
"import1info1": "Drag and drop your PDF files here to import them.",
"import1info2": "You can also download our browser extension to import PDFs directly from the web.",
"import2title": "2. Import to Tags/Folders",
"import2info1": "Drag and drop your PDF files to a tag/folder to import them directly to it.",
"supp1title": "Add supplementary files.",
"supp1info1": "Drag and drop your files here to add them as supplementary files.",
"supp1info2": "Right click on a file to delete or rename it.",
"search1title": "Search and Command Bar",
"search1info1": "You can search your library using the search bar.",
"search1info2": "By pressing '\\', you can open the command bar to do fulltext or advanced searching, and also perform various actions.",
"viewmode1title": "Three View Modes",
"viewmode1info1": "You can switch between list view, table view, and table reader view.",
"viewmode1info2": "In the preference view - mainview tab, you can choose which information to display in each view mode.",
"quickpaste1title": "Quick Copy-paste Window",
"quickpaste1info1": "By pressing `Ctrl/Cmd + Shift + I`, you can open the quick copy-paste window to copy and paste references.",
"quickpaste1info2": "It's a convenient way to copy BibTex, or plain text references to your clipboard when you are writing a paper.",
"more1title": "For More",
"more1info1": "Please visit our website for more guides and tutorials.",
"more1info2": "Click here."
}
}
22 changes: 22 additions & 0 deletions app/locales/locales/zh.CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,27 @@
"extensionscraper": "元数据搜刮器插件",
"extensionscraperrequired": "请安装元数据搜刮器插件",
"extensionrecommend": "推荐插件"
},
"guide": {
"import1title": "1. 导入论文到库",
"import1info1": "拖动你的 PDF 文件到这里导入论文。",
"import1info2": "你也可以下载我们的浏览器插件,来从网页上直接导入论文。",
"import2title": "2. 导入到标签或组",
"import2info1": "直接拖动 PDF 到一个标签或者组可以将论文直接导入到这个标签或组。",
"supp1title": "添加附件",
"supp1info1": "拖动你的文件到这里导入为附件。",
"supp1info2": "右键附件以删除和重命名",
"search1title": "搜索和命令栏",
"search1info1": "使用搜索栏搜索你的论文库。",
"search1info2": "按下 '\\', 你可以打开命令栏,进行全文或者高级搜索。或者运行各种命令。",
"viewmode1title": "三种视图",
"viewmode1info1": "你可以切换列表、表格、表格阅读三种视图。",
"viewmode1info2": "在设置界面的主视图设置,你可以选择在视图内显示哪些信息。",
"quickpaste1title": "快速引用窗口",
"quickpaste1info1": "按下 `Ctrl/Cmd + Shift + I`,你可以打开快速引用窗口来复制论文的引用。",
"quickpaste1info2": "这是一个十分便捷的方式,来帮你在写论文时,复制 BibTex,纯文本等引用。",
"more1title": "更多使用帮助",
"more1info1": "请访问官方网站,查看更多使用帮助。",
"more1info2": "点击这里。"
}
}
12 changes: 12 additions & 0 deletions app/renderer/ui/app-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import PresettingView from "./presetting-view/presetting-view.vue";
import WhatsNewView from "./whats-new-view/whats-new-view.vue";
import WelcomeView from "./welcome-view/welcome-view.vue";
import OverlayNotificationView from "./overlay-notification-view/overlay-notification-view.vue";
import GuideView from "./guide-view/guide-view.vue";
// ================================
// State
Expand Down Expand Up @@ -497,6 +498,17 @@ onMounted(async () => {
<OverlayNotificationView v-if="uiState.overlayNoticationShown" />
</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>
<GuideView v-if="prefState.showGuide" />
</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
Expand Down
284 changes: 284 additions & 0 deletions app/renderer/ui/guide-view/guide-view.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
<script setup lang="ts">
import { PaperEntity } from "@/models/paper-entity";
import { ref } from "vue";
const uiState = uiStateService.useState();
const currentGuide = ref(0);
const onClicked = (e: MouseEvent) => {
currentGuide.value += 1;
if (currentGuide.value === 1) {
selectAPaper();
}
if (currentGuide.value === 6) {
preferenceService.set({ showGuide: false });
}
};
const selectAPaper = async () => {
const papers = await paperService.load("", "addTime", "desc", undefined);
if (papers.length === 0) {
await paperService.update(
[
new PaperEntity({
title: "Welcome to PaperLib!",
authors: "Future Scholars, Geoffrey Chen",
publication: "Github, https://paperlib.app",
pubTime: "2020",
note: "<md>\n# Welcome to PaperLib!\n\nThis is a guide to help you get started with PaperLib.\n\n",
}),
],
false,
false
);
}
uiState.selectedIndex = [0];
};
</script>

<template>
<div
id="guide-view"
class="fixed top-0 right-0 left-0 z-40 w-screen h-screen"
@click="onClicked"
>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>
<div
id="import-guide-view"
class="w-full h-full select-none"
v-if="currentGuide === 0"
>
<div class="text-white left-1/2 top-1/2 relative">
<span class="p-2 flex">
<div
class="w-4 h-4 mt-[-6px] bg-neutral-600 drop-shadow-lg rounded-sm"
/>
<span
class="ml-[-10px] my-auto bg-neutral-100 rounded-md py-2 px-2 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.import1title") }}</span>
<span class="text-xs pl-3">
{{ $t("guide.import1info1") }}
</span>

<span class="text-xs pl-3 mt-4">
{{ $t("guide.import1info2") }}
</span>
</span>
</span>
</div>

<div class="text-white left-12 top-36 relative">
<span class="p-2 flex">
<div
class="w-4 h-4 mt-[-6px] bg-neutral-600 drop-shadow-lg rounded-sm"
/>
<span
class="ml-[-10px] my-auto bg-neutral-100 rounded-md py-2 px-2 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.import2title") }}</span>
<span class="text-xs pl-3">
{{ $t("guide.import2info1") }}
</span>
</span>
</span>
</div>
</div>
</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>

<div
id="supp-guide-view"
class="w-full h-full select-none"
v-if="currentGuide === 1"
>
<div class="text-white right-[60px] bottom-[20px] fixed">
<span class="p-2 flex items-end">
<span
class="ml-[-10px] my-auto bg-neutral-100 rounded-md py-2 px-2 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.supp1title") }}</span>
<span class="text-xs">
{{ $t("guide.supp1info1") }}
</span>

<span class="text-xs mt-4">
{{ $t("guide.supp1info2") }}
</span>
</span>
<div
class="w-4 h-4 mb-[-6px] ml-[-10px] bg-neutral-600 drop-shadow-lg rounded-sm -z-10"
/>
</span>
</div>
</div>

</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>

<div
id="search-guide-view"
class="w-full h-full select-none"
v-if="currentGuide === 2"
>
<div class="text-white left-1/2 top-6 fixed">
<span class="p-2 flex">
<div
class="w-4 h-4 mt-[-6px] bg-neutral-600 drop-shadow-lg rounded-sm"
/>
<span
class="ml-[-10px] my-auto bg-neutral-100 rounded-md py-2 px-3 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.search1title") }}</span>
<span class="text-xs">
{{ $t("guide.search1info1") }}
</span>
<span class="text-xs mt-4">
{{ $t("guide.search1info2") }}
</span>
</span>
</span>
</div>
</div>

</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>
<div
id="viewmode-guide-view"
class="w-full h-full select-none"
v-if="currentGuide === 3"
>
<div class="text-white right-[150px] top-6 fixed">
<span class="p-2 flex">
<span
class="my-auto bg-neutral-100 rounded-md py-2 px-3 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.viewmode1title") }}</span>
<span class="text-xs">
{{ $t("guide.viewmode1info1") }}
</span>
<span class="text-xs mt-4">
{{ $t("guide.viewmode1info2") }}
</span>
</span>
<div
class="w-4 h-4 mt-[-6px] ml-[-10px] bg-neutral-600 drop-shadow-lg rounded-sm -z-10"
/>
</span>
</div>
</div>

</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>

<div
id="quickpaste-guide-view"
class="w-full h-full select-none"
v-if="currentGuide === 4"
>
<div class="text-white left-1/2 top-1/2 fixed">
<span class="p-2 flex">
<div
class="w-4 h-4 mt-[-6px] bg-neutral-600 drop-shadow-lg rounded-sm"
/>
<span
class="ml-[-10px] my-auto bg-neutral-100 rounded-md py-2 px-2 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.quickpaste1title") }}</span>
<span class="text-xs">
{{ $t("guide.quickpaste1info1") }}
</span>
<span class="text-xs mt-4">
{{ $t("guide.quickpaste1info2") }}
</span>
</span>
</span>
</div>
</div>

</Transition>

<Transition
enter-active-class="transition ease-out duration-75"
enter-from-class="transform opacity-0"
enter-to-class="transform opacity-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100"
leave-to-class="transform opacity-0"
>

<div
id="more-guide-view"
class="w-full h-full select-none"
v-if="currentGuide === 5"
>
<div class="text-white left-1/2 top-1/2 fixed">
<span class="p-2 flex">
<div
class="w-4 h-4 mt-[-6px] bg-neutral-600 drop-shadow-lg rounded-sm"
/>
<span
class="ml-[-10px] my-auto bg-neutral-100 rounded-md py-2 px-2 text-neutral-800 drop-shadow-lg flex flex-col w-64"
>
<span class="text-sm font-semibold">{{ $t("guide.more1title") }}</span>
<span class="text-xs">
{{ $t("guide.more1info1") }}
</span>
<a
class="text-xs mt-4 underline"
href="https://paperlib.app/en/doc/getting-started.html"
>
{{ $t("guide.more1info2") }}
</a>
</span>
</span>
</div>
</div>

</Transition>
</div>
</template>
2 changes: 1 addition & 1 deletion app/renderer/ui/presetting-view/lang-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const onChangeLanguage = (language: string) => {
>
<option value="en-GB">en-GB</option>
<option value="zh-CN">zh-CN</option>
<option value="zh-CN">zh-TW</option>
<option value="zh-TW">zh-TW</option>
<option value="ar">ar</option>
</select>
</div>
Expand Down

0 comments on commit 6df1acb

Please sign in to comment.