-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
295 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script lang="ts" setup> | ||
const { signIn, status, data } = useSession(); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<el-button v-if="status === 'unauthenticated'" text @click="() => signIn()"> | ||
<el-icon class="i-carbon:user"></el-icon> | ||
</el-button> | ||
<el-avatar | ||
v-else-if="status === 'authenticated'" | ||
:size="32" | ||
:src="data?.user?.image ?? ''" | ||
> | ||
{{ data?.user?.name }} | ||
</el-avatar> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts" setup> | ||
import { ToolItem } from "~~/types"; | ||
const localePath = useLocalePath(); | ||
defineProps<{ | ||
tool: ToolItem; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<div absolute left-0 top--8 w-full h-full flex justify-end gap-1> | ||
<NuxtLink | ||
:to="{ | ||
path: localePath('/create'), | ||
query: { | ||
id: tool.id, | ||
}, | ||
}" | ||
> | ||
<el-button size="small" text> | ||
<el-icon class="i-carbon:edit"></el-icon> | ||
</el-button> | ||
</NuxtLink> | ||
<ToolSettingDialog :tool="tool" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,20 @@ | ||
<script lang="ts" setup> | ||
import { ToolItem } from "~/composables/useTools"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
const localePath = useLocalePath(); | ||
import { ToolItem } from "~~/types"; | ||
const props = defineProps<{ | ||
defineProps<{ | ||
tool: ToolItem; | ||
showAction?: boolean; | ||
}>(); | ||
const { isLocalTool } = useTools(); | ||
const { save } = useCustomTools(); | ||
function handleFork() { | ||
const id = uuidv4(); | ||
save({ | ||
...props.tool, | ||
id, | ||
}); | ||
navigateTo({ | ||
path: localePath(`/ai-${id}`), | ||
replace: true, | ||
}); | ||
} | ||
</script> | ||
<template> | ||
<div flex gap-2 mb-4> | ||
<div | ||
v-if="tool?.icon" | ||
w-12 | ||
h-12 | ||
flex | ||
items-center | ||
justify-center | ||
rounded-md | ||
color-primary | ||
transition-all | ||
border | ||
dark:border-gray-800 | ||
> | ||
<div flex flex-col items-center text-center mb-8> | ||
<div v-if="tool?.icon" text-6xl color-primary my-2 sm:my-6> | ||
<ToolIcon :icon="tool.icon" /> | ||
</div> | ||
<div flex flex-col gap-y-1 flex-1> | ||
<div font-bold>{{ tool?.name }}</div> | ||
<div line-clamp-2 text-sm text-gray-500> | ||
{{ tool?.desc ?? "Nothing in here" }} | ||
</div> | ||
<div text-2xl font-semibold text-gray-900 dark:text-gray-100> | ||
{{ tool?.name }} | ||
</div> | ||
<div flex gap-1> | ||
<template v-if="showAction && isLocalTool(tool.id!)"> | ||
<ToolRemoteAction :tool="tool" /> | ||
<NuxtLink | ||
:to="{ | ||
path: localePath('/create'), | ||
query: { | ||
id: tool.id, | ||
}, | ||
}" | ||
> | ||
<el-button size="small" text> | ||
<el-icon class="i-carbon:edit"></el-icon> | ||
</el-button> | ||
</NuxtLink> | ||
<ToolSettingDialog :tool="tool" /> | ||
</template> | ||
<template v-else> | ||
<el-button @click="handleFork" size="small" text> | ||
<el-icon class="i-carbon:fork"></el-icon> | ||
</el-button> | ||
</template> | ||
<div v-if="tool?.desc" mt-1 font-medium text-gray-500 dark:text-gray-400> | ||
{{ tool?.desc }} | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,7 @@ | ||
<template> | ||
<main flex-1> | ||
<div max-w-2xl mx-auto mt-10> | ||
<div | ||
rounded-xl | ||
bg-white | ||
dark:bg-dark-900 | ||
transition-all | ||
drop-shadow-none | ||
sm:drop-shadow-lg | ||
border-light | ||
of-hidden | ||
px-16px | ||
py-20px | ||
> | ||
<slot></slot> | ||
</div> | ||
<div max-w-2xl mx-auto px-4 mt-6 sm:mt-10> | ||
<slot></slot> | ||
</div> | ||
</main> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { MaybeRef } from "@vueuse/shared"; | ||
import { STORAGE_KEY_TOOLS } from "~~/constants"; | ||
import { ToolItem } from "~~/types"; | ||
|
||
export const useLocalTools = () => { | ||
const tools = useLocalStorage<ToolItem[]>(STORAGE_KEY_TOOLS, []); | ||
function create(tool: ToolItem) { | ||
tools.value.push(tool); | ||
} | ||
|
||
function get(id: MaybeRef<string>) { | ||
return tools.value.find((v) => v.id === unref(id)); | ||
} | ||
|
||
function remove(id: MaybeRef<string>) { | ||
tools.value = tools.value.filter((v) => v.id !== unref(id)); | ||
} | ||
|
||
function update(tool: Partial<ToolItem>) { | ||
const { id, ...other } = tool; | ||
tools.value = tools.value.map((v) => { | ||
if (v.id === id) { | ||
return { | ||
...v, | ||
...other, | ||
}; | ||
} | ||
return v; | ||
}); | ||
} | ||
|
||
return { | ||
tools, | ||
create, | ||
get, | ||
remove, | ||
update, | ||
}; | ||
}; |
Oops, something went wrong.