6ee4087a29
- Centralize `useAgents` and `useModels` state within the Nuxt app context to prevent data leaks and improve initialization. - Migrate virtualization from `vue-virtual-scroller` to `@tanstack/vue-virtual` with new `RowVirtualizerFixed` and `RowVirtualizerDynamic` components. - Upgrade Nuxt to v4.3.1 and remove `@vue-macros/nuxt`. - Replace `big.js` with an optimized custom `lshDecimal` string manipulation logic for pricing calculations in the provider API. - Implement automatic focus redirection in `ChatInput` to capture standard keyboard input. - Refactor Sidenav and Settings components to utilize virtualization for long lists (topics, agents, models). - Enhance theme colors and mobile experience. More work to come on both of these.
55 lines
1.5 KiB
Vue
55 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import { h, Text, computed } from 'vue';
|
|
import MarkdownShikiHighlight from './ShikiHighlight.vue';
|
|
|
|
const props = defineProps<{
|
|
content: string;
|
|
finished: boolean;
|
|
id: string;
|
|
}>();
|
|
|
|
const { $remark } = useNuxtApp();
|
|
|
|
const ast = computed(() => {
|
|
const mdast = $remark.parse(props.content);
|
|
return $remark.runSync(mdast);
|
|
});
|
|
|
|
const renderNode = (node: any, index: number): any => {
|
|
if (node.type === 'text' || node.type === 'raw') return h(Text, node.value);
|
|
|
|
if (node.type === 'element') {
|
|
if (node.tagName === 'code') {
|
|
const isBlock = node.position?.start.line !== node.position?.end.line;
|
|
if (isBlock && node.children?.[0]?.type === 'text') {
|
|
return h(MarkdownShikiHighlight, {
|
|
key: `code-${index}`,
|
|
code: node.children[0].value,
|
|
language: node.properties?.className?.[0]?.replace('language-', '') || 'text'
|
|
});
|
|
}
|
|
}
|
|
|
|
const children = node.children?.map((child: any, i: number) => renderNode(child, i)) || [];
|
|
|
|
return h(
|
|
node.tagName,
|
|
{ ...node.properties, key: `${node.tagName}-${index}` },
|
|
children
|
|
);
|
|
}
|
|
return null;
|
|
};
|
|
|
|
const render = () => {
|
|
const children = ast.value?.children?.flatMap(renderNode) || [];
|
|
|
|
return h('div', { class: 'prose-wrapper' }, [
|
|
h('article', { class: 'markdown-body' }, children)
|
|
]);
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<render />
|
|
</template> |