Skip to content

Commit

Permalink
Merge pull request #129 from blinko-space/#124
Browse files Browse the repository at this point in the history
fix: #124 add version number
  • Loading branch information
blinko-space authored Nov 18, 2024
2 parents 1a57c3e + 4f89d9d commit a2aa503
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 70 deletions.
4 changes: 3 additions & 1 deletion public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@
"rebuild": "Wiederherstellen",
"notes-imported-by-other-means-may-not-have-embedded-vectors": "Auf anderem Wege importierte Noten haben möglicherweise keine eingebetteten Vektoren",
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "Wenn Sie viele Scheine haben, können Sie eine bestimmte Anzahl von Token verbrauchen.",
"time-format": "Zeitformat"
"time-format": "Zeitformat",
"version": "Version",
"new-version-available": "Neue Version verfügbar"
}
4 changes: 3 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@
"notes-imported-by-other-means-may-not-have-embedded-vectors": "Notes imported by other means may not have embedded vectors",
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "If you have a lot of notes you may consume a certain number of tokens",
"order-by-create-time": "Order by create time",
"time-format": "Time Format"
"time-format": "Time Format",
"version": "Version",
"new-version-available": "New version available"
}
4 changes: 3 additions & 1 deletion public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,7 @@
"rebuild": "Reconstruir",
"notes-imported-by-other-means-may-not-have-embedded-vectors": "Los billetes importados por otros medios pueden no tener vectores incrustados",
"order-by-create-time": "Ordenar por hora de creación",
"time-format": "Formato de hora"
"time-format": "Formato de hora",
"version": "Versión",
"new-version-available": "Nueva versión disponible"
}
4 changes: 3 additions & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@
"rebuild-embedding-index": "Reconstruire l'index d'intégration",
"rebuild": "Reconstruction",
"order-by-create-time": "Ordre par temps de création",
"time-format": "Format de l'heure"
"time-format": "Format de l'heure",
"version": "Version",
"new-version-available": "Nouvelle version disponible"
}
4 changes: 3 additions & 1 deletion public/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,7 @@
"rebuild": "再構築",
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "多くのノートをお持ちの場合、一定数のトークンを消費する可能性があります。",
"order-by-create-time": "作成時間順",
"time-format": "時間形式"
"time-format": "時間形式",
"version": "バージョン",
"new-version-available": "新バージョン"
}
4 changes: 3 additions & 1 deletion public/locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@
"notes-imported-by-other-means-may-not-have-embedded-vectors": "다른 방법으로 가져온 노트에는 벡터가 내장되어 있지 않을 수 있습니다.",
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "노트가 많으면 특정 수의 토큰을 소모할 수 있습니다.",
"order-by-create-time": "생성 시간별 주문",
"time-format": "시간 형식"
"time-format": "시간 형식",
"version": "버전",
"new-version-available": "새 버전 사용 가능"
}
4 changes: 3 additions & 1 deletion public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,7 @@
"rebuild-embedding-index": "Reconstruir o índice de incorporação",
"notes-imported-by-other-means-may-not-have-embedded-vectors": "As notas importadas por outros meios podem não ter vectores incorporados",
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "Se tiver muitas notas, pode consumir um determinado número de fichas",
"time-format": "Formato da hora"
"time-format": "Formato da hora",
"version": "Versão",
"new-version-available": "Nova versão disponível"
}
4 changes: 3 additions & 1 deletion public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@
"notes-imported-by-other-means-may-not-have-embedded-vectors": "Ноты, импортированные другими способами, могут не иметь встроенных векторов",
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "Если у вас много заметок, вы можете израсходовать определенное количество жетонов.",
"order-by-create-time": "Заказать по времени создания",
"time-format": "Формат времени"
"time-format": "Формат времени",
"version": "Версия",
"new-version-available": "Доступна новая версия"
}
4 changes: 3 additions & 1 deletion public/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@
"rebuild": "重建",
"notes-imported-by-other-means-may-not-have-embedded-vectors": "通过其他方式导入的票据可能没有嵌入向量",
"order-by-create-time": "按创建时间排序",
"time-format": "时间格式"
"time-format": "时间格式",
"version": "版本",
"new-version-available": "新版本可用"
}
4 changes: 3 additions & 1 deletion public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@
"rebuild": "重建",
"notes-imported-by-other-means-may-not-have-embedded-vectors": "通过其他方式导入的票据可能没有嵌入向量",
"order-by-create-time": "按创建时间排序",
"time-format": "时间格式"
"time-format": "时间格式",
"version": "版本",
"new-version-available": "新版本可用"
}
42 changes: 0 additions & 42 deletions src/components/BlinkoNewVersion/index.tsx

This file was deleted.

57 changes: 57 additions & 0 deletions src/components/BlinkoSettings/AboutSetting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// blinko.public.value?.version

import { observer } from "mobx-react-lite";
import { Card, Tooltip } from "@nextui-org/react";
import { RootStore } from "@/store";
import { BlinkoStore } from "@/store/blinkoStore";
import { PromiseState } from "@/store/standard/PromiseState";
import { Icon } from "@iconify/react";
import { api } from "@/lib/trpc";
import { AiStore } from "@/store/aiStore";
import { useTranslation } from "react-i18next";
import { Item } from "./Item";
import { useEffect } from "react";
import { useMediaQuery } from "usehooks-ts";

export const AboutSetting = observer(() => {
const blinko = RootStore.Get(BlinkoStore)
const ai = RootStore.Get(AiStore)
const { t } = useTranslation()
const isPc = useMediaQuery('(min-width: 768px)')
const store = RootStore.Local(() => ({
version: new PromiseState({
function: async () => {
return await api.public.version.query()
}
}),
latestVersion: new PromiseState({
function: async () => {
return await api.public.latestVersion.query()
}
})
}))
useEffect(() => {
store.version.call()
store.latestVersion.call()
}, [])
return <Card shadow="none" className="flex flex-col p-4 bg-background pb-6">
<div className='text-desc text-sm'>About</div>
<Item
leftContent={<>{t('version')}</>}
rightContent={
<div className="flex items-center" onClick={() => { }}>
<div>v{store.version.value}</div>
{store.latestVersion.value}
{
store.latestVersion.value != '' && store.latestVersion.value != store.version.value && <Tooltip content={t('new-version-available')}>
<Icon onClick={() => {
window.open(`https://github.com/blinko-space/blinko`, '_blank')
}} icon="mingcute:up-fill" width="24" height="24" className="text-green-500 cursor-pointer" />
</Tooltip>
}
</div>} />
<Item
leftContent={<>Github</>}
rightContent={<a href="https://github.com/blinko-space/blinko">https://github.com/blinko-space/blinko</a>} />
</Card>
})
3 changes: 0 additions & 3 deletions src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useTranslation } from "react-i18next";
import { BaseStore } from "@/store/baseStore";
import { BlinkoAi } from "../BlinkoAi";
import { ScrollArea } from "../Common/ScrollArea";
import { BlinkoNewVersion } from "../BlinkoNewVersion";
import { BlinkoRightClickMenu } from '@/components/BlinkoRightClickMenu';
import { useMediaQuery } from "usehooks-ts";
import { push as Menu } from 'react-burger-menu';
Expand Down Expand Up @@ -72,7 +71,6 @@ export const CommonLayout = observer(({
{
theme == 'dark' ? <Image src="/logo-dark.svg" width={100} /> : <Image src="/logo.svg" width={100} />
}
<BlinkoNewVersion />
</div>
<ScrollShadow className="-mr-[16px] mt-[-5px] h-full max-h-full pr-6 ">
<div>
Expand All @@ -90,7 +88,6 @@ export const CommonLayout = observer(({
</Link>
})
}

<div>
{blinkoStore.tagList.value?.listTags.length != 0 && blinkoStore.tagList.value?.listTags && <>
<TagListPanel />
Expand Down
2 changes: 2 additions & 0 deletions src/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ScrollArea } from "@/components/Common/ScrollArea";
import { UserStore } from "@/store/user";
import { RootStore } from "@/store";
import { UserSetting } from "@/components/BlinkoSettings/UserSetting";
import { AboutSetting } from "@/components/BlinkoSettings/AboutSetting";

const Page = observer(() => {
const user = RootStore.Get(UserStore)
Expand All @@ -19,6 +20,7 @@ const Page = observer(() => {
{user.isSuperAdmin && <AiSetting />}
{user.isSuperAdmin && <TaskSetting />}
{user.isSuperAdmin && <ImportSetting />}
<AboutSetting />
</ScrollArea >
</div>
});
Expand Down
19 changes: 11 additions & 8 deletions src/server/routers/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export const publicRouter = router({
.output(z.string())
.query(async function () {
return await cache.wrap('version', async () => {
return packageJson.version
}, { ttl: 60 * 60 * 1000 })
}),
latestVersion: publicProcedure
.meta({ openapi: { method: 'GET', path: '/v1/public/latest-version', summary: 'Get a new version', tags: ['Public'] } })
.input(z.void())
.output(z.string())
.query(async function () {
return await cache.wrap('latest-version', async () => {
const url = `https://api.github.com/repos/blinko-space/blinko/releases/latest`;
try {
const res = await axios.get(url, {
Expand All @@ -24,17 +33,11 @@ export const publicRouter = router({
},
})
const latestVersion = res.data.tag_name.replace('v', '');
const currentVersion = packageJson.version;
if (latestVersion !== currentVersion) {
return latestVersion
} else {
return ''
}
return latestVersion
} catch (error) {
// console.error(error)
return ''
}
}, { ttl: 60 * 60 * 1000 })
}, { ttl: 60 * 10 * 1000 })
}),
linkPreview: publicProcedure
.meta({ openapi: { method: 'GET', path: '/v1/public/link-preview', summary: 'Get a link preview info', tags: ['Public'] } })
Expand Down
8 changes: 1 addition & 7 deletions src/store/blinkoStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ export class BlinkoStore implements Store {
}
})

public = new PromiseState({
function: async () => {
const version = await api.public.version.query()
return { version }
}
})


get showAi() {
return this.config.value?.isUseAI && this.config.value?.aiApiKey
Expand Down Expand Up @@ -187,7 +182,6 @@ export class BlinkoStore implements Store {
this.tagList.call()
this.config.call()
this.dailyReviewNoteList.call()
this.public.call()
this.task.call()
}

Expand Down

0 comments on commit a2aa503

Please sign in to comment.