🔥 (offline) remove offline img
This commit is contained in:
@@ -12,12 +12,6 @@
|
|||||||
{{ title }}
|
{{ title }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<img
|
|
||||||
class="offline-ready"
|
|
||||||
v-if="fromCache"
|
|
||||||
src="@/assets/icons/saved.svg"
|
|
||||||
alt="offline ready"
|
|
||||||
/>
|
|
||||||
<section v-html="content"></section>
|
<section v-html="content"></section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Ref, onMounted, ref, watch } from '@vue/runtime-core'
|
|||||||
import { Octokit } from '@octokit/rest'
|
import { Octokit } from '@octokit/rest'
|
||||||
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
|
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
|
||||||
import { useMarkdown } from '@/hooks/useMarkdown.hook'
|
import { useMarkdown } from '@/hooks/useMarkdown.hook'
|
||||||
|
import { useNoteCache } from '@/modules/note/hooks/useNoteCache'
|
||||||
|
|
||||||
interface Tree {
|
interface Tree {
|
||||||
path?: string
|
path?: string
|
||||||
@@ -14,6 +15,7 @@ interface Tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
||||||
|
const { getCachedNote, saveCacheNote } = useNoteCache('README')
|
||||||
const { accessToken } = useGitHubLogin()
|
const { accessToken } = useGitHubLogin()
|
||||||
|
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
@@ -29,8 +31,13 @@ export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
|||||||
if (!owner.value || !repo.value) {
|
if (!owner.value || !repo.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const cachedReadme = await getCachedNote()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (cachedReadme) {
|
||||||
|
readme.value = render(cachedReadme.content)
|
||||||
|
}
|
||||||
|
|
||||||
const README = await octokit.repos.getReadme({
|
const README = await octokit.repos.getReadme({
|
||||||
owner: owner.value,
|
owner: owner.value,
|
||||||
repo: repo.value
|
repo: repo.value
|
||||||
@@ -38,6 +45,7 @@ export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
|||||||
|
|
||||||
if (README) {
|
if (README) {
|
||||||
readme.value = render(README.data.content)
|
readme.value = render(README.data.content)
|
||||||
|
saveCacheNote(README.data.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
const commits = await octokit.request(
|
const commits = await octokit.request(
|
||||||
@@ -69,9 +77,11 @@ export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
|||||||
console.log(tree.value)
|
console.log(tree.value)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (!cachedReadme) {
|
||||||
notFound.value = true
|
notFound.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => retrieveRepo())
|
onMounted(() => retrieveRepo())
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="repo-list">
|
<div class="repo-list">
|
||||||
<h1 class="title is-1">Repositories</h1>
|
<h1 class="title is-1">Repositories</h1>
|
||||||
<go-back />
|
<go-back />
|
||||||
<span v-if="!isReady">loading...</span>
|
<div v-if="!isReady">loading...</div>
|
||||||
<div v-else class="columns is-centered">
|
<div v-else class="columns is-centered">
|
||||||
<div class="column is-one-third">
|
<div class="column is-one-third">
|
||||||
<table
|
<table
|
||||||
|
|||||||
Reference in New Issue
Block a user