Skip to content

Commit

Permalink
🚀release: v0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
blinko-space committed Oct 28, 2024
1 parent 732a261 commit b94340e
Show file tree
Hide file tree
Showing 47 changed files with 698 additions and 387 deletions.
2 changes: 1 addition & 1 deletion app/api/file/[filename]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const GET = async (req: Request, { params }: any) => {
},
});
} catch (error) {
console.log("Error occurred ", error);
console.error("Error occurred ", error);
return NextResponse.json({ Message: "File not found", status: 404 });
}
};
1 change: 0 additions & 1 deletion app/api/file/delete/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import path from "path";
export const POST = async (req: Request, res: NextResponse) => {
try {
const { attachment_path } = await req.json();
console.log(attachment_path)
const attachment = await prisma.attachments.findFirst({ where: { path: attachment_path } })
if (attachment) {
await prisma.attachments.delete({ where: { id: attachment.id } })
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blinko",
"version": "0.0.5",
"version": "0.0.6",
"private": true,
"browser": {
"fs": false,
Expand Down
8 changes: 7 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@
"backup-file": "BACKUP FILE",
"status": "STATUS",
"running": "Running",
"stopped": "Stopped"
"stopped": "Stopped",
"show-navigation-bar-on-mobile": "Hidden navigation bar on mobile",
"schedule-archive-blinko": "Schedule Archive Blinko",
"there-are-no-resources-yet-go-upload-them-now": "There are no resources yet go upload them now",
"confrim": "Confirm",
"daily-review": "Daily Review",
"detail": "Detail"
}
10 changes: 8 additions & 2 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"your-changes-have-been-saved": "您的更改已保存!",
"add-tag": "添加标签",
"cancel": "取消",
"confrim": "Confrim",
"confrim": "确认",
"no-data-here-well-then-time-to-write-a-note": "没有数据?是时候开始写一篇Blinko啦~",
"basic-information": "基本信息",
"language": "语言",
Expand Down Expand Up @@ -97,5 +97,11 @@
"backup-file": "备份文件",
"status": "状态",
"running": "运行中",
"stopped": "已停止"
"stopped": "已停止",
"show-navigation-bar-on-mobile": "移动端隐藏导航栏",
"schedule-archive-blinko": "定时归档闪念",
"there-are-no-resources-yet-go-upload-them-now": "还没有资源,现在就去上传吧",
"daily-review": "每日回顾",
"detail": "详情",
"total": "全部"
}
10 changes: 6 additions & 4 deletions src/components/BlinkoAi/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { DialogStore } from "@/store/module/Dialog";
import { UserStore } from "@/store/user";
import { useTranslation } from "react-i18next";
import { ScrollArea, ScrollAreaHandles } from "../Common/ScrollArea";
import { useRouter } from "next/router";
import Link from "next/link";

export const BlinkoAiChat = observer(() => {
const ai = RootStore.Get(AiStore)
Expand All @@ -27,7 +29,7 @@ export const BlinkoAiChat = observer(() => {

return <div className="flex flex-col p-0 md:p-2 relative h-full">
<ScrollArea
onBottom={() => {}}
onBottom={() => { }}
ref={scrollAreaRef}
key='BlinkoAiChat'
className={`mx-1 w-full !h-[500px] md:!h-[360px]`}>
Expand Down Expand Up @@ -59,11 +61,11 @@ export const BlinkoAiChat = observer(() => {
</div>
{
(ai.chatHistory.list?.length == index + 1) && <div className="flex flex-col gap-1">
{ai.relationNotes?.map(note => {
return <div className="w-full flex gap-1 items-center blinko-tag cursor-pointer" style={{ fontSize: '11px' }}>
{ai.relationNotes?.list?.map(note => {
return <Link href={`/detail?id=${note.id}`} className="w-[90%] flex gap-1 items-center blinko-tag cursor-pointer" style={{ fontSize: '11px' }}>
<Icon className="min-w-[15px]" icon="uim:arrow-up-left" width="15" height="15" />
<div className="truncate">{note.content}</div>
</div>
</Link>
})}
</div>
}
Expand Down
50 changes: 50 additions & 0 deletions src/components/BlinkoCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { observer } from "mobx-react-lite";
import { BlinkoStore } from '@/store/blinkoStore';
import { Card } from '@nextui-org/react';
import { _ } from '@/lib/lodash';
import { useTranslation } from 'react-i18next';
import { RootStore } from '@/store';
import { motion } from "framer-motion"
import { FilesAttachmentRender } from '@/components/Common/Editor/attachmentsRender';
import { ContextMenuTrigger } from '@/components/Common/ContextMenu';
import { MarkdownRender } from '@/components/Common/MarkdownRender';
import { Icon } from '@iconify/react';
import dayjs from '@/lib/dayjs';
import { Note, NoteType } from '@/server/types';

export const BlinkoCard = observer(({ blinkoItem }: { blinkoItem: Note }) => {
const { t } = useTranslation();
const blinko = RootStore.Get(BlinkoStore)

return <motion.div key={blinkoItem.id} className='w-full' style={{ boxShadow: '0 0 15px -5px #5858581a' }}>
<ContextMenuTrigger id="blink-item-context-menu" >
<div onContextMenu={e => {
blinko.curSelectedNote = _.cloneDeep(blinkoItem)
}}
onClick={() => {
if (blinko.isMultiSelectMode) {
blinko.onMultiSelectNote(blinkoItem.id!)
}
}}>
<Card shadow='none' className={`mb-4 flex flex-col p-4 bg-background transition-all ${blinko.curMultiSelectIds?.includes(blinkoItem.id!) ? 'border-2 border-primary' : ''}`}>
<div className='mb-2 text-xs text-desc'>{dayjs(blinkoItem.createdAt).fromNow()}</div>
<MarkdownRender content={blinkoItem.content} />
<div className={blinkoItem.attachments?.length != 0 ? 'my-2' : ''}>
<FilesAttachmentRender files={blinkoItem.attachments ?? []} preview />
</div>
{
blinkoItem.type == NoteType.BLINKO ?
<div className='flex items-center justify-start mt-2'>
<Icon className='text-yellow-500' icon="basil:lightning-solid" width="12" height="12" />
<div className='text-desc text-xs font-bold ml-1'>{t('blinko')}</div>
</div> :
<div className='flex items-center justify-start mt-2'>
<Icon className='text-blue-500' icon="solar:notes-minimalistic-bold-duotone" width="12" height="12" />
<div className='text-desc text-xs font-bold ml-1'>{t('note')}</div>
</div>
}
</Card>
</div>
</ContextMenuTrigger>
</motion.div>
})
19 changes: 16 additions & 3 deletions src/components/BlinkoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { RootStore } from "@/store"
import { BlinkoStore } from "@/store/blinkoStore"
import dayjs from "@/lib/dayjs"
import { useRef } from "react"
import { NoteType } from "@/server/types"
import { useRouter } from "next/router"

type IProps = {
mode: 'create' | 'edit',
Expand All @@ -14,13 +16,13 @@ export const BlinkoEditor = observer(({ mode, onSended, onHeightChange }: IProps
const isCreateMode = mode == 'create'
const blinko = RootStore.Get(BlinkoStore)
const editorRef = useRef<any>(null)

const router = useRouter()
return <div ref={editorRef} id='global-editor'>
<Editor
originFiles={!isCreateMode ? blinko.curSelectedNote?.attachments : []}
content={isCreateMode ? blinko.noteContent! : blinko.curSelectedNote?.content!}
onChange={v => {
onHeightChange?.(editorRef.current.clientHeight)
onHeightChange?.(editorRef.current?.clientHeight ?? 90)
isCreateMode ? (blinko.noteContent = v) : (blinko.curSelectedNote!.content = v)
}}
isSendLoading={blinko.upsertNote.loading.value}
Expand All @@ -31,7 +33,18 @@ export const BlinkoEditor = observer(({ mode, onSended, onHeightChange }: IProps
onSend={async ({ files }) => {
if (isCreateMode) {
//@ts-ignore
await blinko.upsertNote.call({ content: blinko.noteContent, attachments: files.map(i => { return { name: i.name, path: i.uploadPath, size: i.size } }) })
await blinko.upsertNote.call({ refresh: false, content: blinko.noteContent, attachments: files.map(i => { return { name: i.name, path: i.uploadPath, size: i.size } }) })
if (blinko.noteTypeDefault == NoteType.NOTE && router.pathname != '/notes') {
await router.push('/notes')
blinko.forceQuery++
return
}
if (blinko.noteTypeDefault == NoteType.BLINKO && router.pathname != '/') {
await router.push('/')
blinko.forceQuery++
return
}
blinko.updateTicker++
} else {
await blinko.upsertNote.call({
id: blinko.curSelectedNote!.id,
Expand Down
1 change: 0 additions & 1 deletion src/components/BlinkoRightClickMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const BlinkoRightClickMenu = observer(() => {
const store = RootStore.Local(() => ({
editorHeight: 90,
editBlinko() {
console.log(123)
RootStore.Get(DialogStore).setData({
size: '2xl',
isOpen: true,
Expand Down
9 changes: 6 additions & 3 deletions src/components/BlinkoSettings/AiSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { useTranslation } from "react-i18next";
import { Item } from "./Item";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { useMediaQuery } from "usehooks-ts";

export const AiSetting = observer(() => {
const blinko = RootStore.Get(BlinkoStore)
const ai = RootStore.Get(AiStore)
const { t } = useTranslation()
const isPc = useMediaQuery('(min-width: 768px)')
const store = RootStore.Local(() => ({
isVisible: false,
apiKey: '',
Expand All @@ -37,7 +39,6 @@ export const AiSetting = observer(() => {
value: e.target.checked
}))
}}
// defaultSelected={blinko.config.value?.isUseAI}
/>} />
<Item
leftContent={<>{t('model-provider')}</>}
Expand Down Expand Up @@ -86,6 +87,7 @@ export const AiSetting = observer(() => {
</Select>} />

<Item
type={isPc ? 'row' : 'col'}
leftContent={<div className="flex flex-col ga-1">
<div>API Key</div>
<div className="text-desc text-xs">{t('user-custom-openai-api-key')}</div>
Expand All @@ -95,7 +97,7 @@ export const AiSetting = observer(() => {
size='sm'
label="API key"
variant="bordered"
className="w-[300px]"
className="w-full md:w-[300px]"
placeholder="Enter your api key"
value={store.apiKey}
onChange={e => { store.apiKey = e.target.value }}
Expand All @@ -118,6 +120,7 @@ export const AiSetting = observer(() => {
/>
} />
<Item
type={isPc ? 'row' : 'col'}
leftContent={<div className="flex flex-col gap-1">
<>{t('api-endpoint')}</>
<div className="text-desc text-xs">{t('must-start-with-http-s-or-use-api-openai-as-default')}</div>
Expand All @@ -126,7 +129,7 @@ export const AiSetting = observer(() => {
size='sm'
label={t('api-endpoint')}
variant="bordered"
className="w-[300px]"
className="w-full md:w-[300px]"
placeholder="https://api.openapi.com"
value={store.apiEndPoint}
onChange={e => { store.apiEndPoint = e.target.value }}
Expand Down
18 changes: 13 additions & 5 deletions src/components/BlinkoSettings/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { observer } from "mobx-react-lite"

export const Item = observer(({ leftContent, rightContent }: any) => {
return <div className="flex flex-col md:flex-row items-center py-2">
<div className="font-bold">{leftContent}</div>
<div className="ml-auto mt-2 md:mt-0">{rightContent}</div>
</div>
export const Item = observer(({ leftContent, rightContent, type = 'row' }: any) => {

if (type == 'col') {
return <div className="flex flex-col py-2">
<div className="font-bold">{leftContent}</div>
<div className="mt-2 w-full">{rightContent}</div>
</div>
} else {
return <div className="flex flex-row items-center py-2">
<div className="font-bold">{leftContent}</div>
<div className="ml-auto">{rightContent}</div>
</div>
}
})
18 changes: 17 additions & 1 deletion src/components/BlinkoSettings/PerferSetting.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { observer } from "mobx-react-lite";
import { Card } from "@nextui-org/react";
import { Card, Switch } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import { Item } from "./Item";
import ThemeSwitcher from "../Common/ThemeSwitcher";
import LanguageSwitcher from "../Common/LanguageSwitcher";
import { RootStore } from "@/store";
import { BlinkoStore } from "@/store/blinkoStore";
import { PromiseCall } from "@/store/standard/PromiseState";
import { api } from "@/lib/trpc";

export const PerferSetting = observer(() => {
const { t } = useTranslation()
const blinko = RootStore.Get(BlinkoStore)
return <Card shadow="none" className="flex flex-col p-4 bg-background">
<div className='text-desc text-sm'>{t('preference')}</div>
<Item
Expand All @@ -15,6 +20,17 @@ export const PerferSetting = observer(() => {
<Item
leftContent={<>{t('language')}</>}
rightContent={<LanguageSwitcher />} />
<Item
leftContent={<>{t('show-navigation-bar-on-mobile')}</>}
rightContent={<Switch
isSelected={blinko.config.value?.isHiddenMobileBar}
onChange={e => {
PromiseCall(api.config.update.mutate({
key: 'isHiddenMobileBar',
value: e.target.checked
}))
}}
/>} />
</Card>

})
Loading

0 comments on commit b94340e

Please sign in to comment.