Support latex (#219)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
0e76bf04b2
commit
d9d50279f3
10 files changed
+97
-268
No files matched your search
@@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<dark-switch class="switch" dark-background="#333" light-background="#fff" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { getDomain } from '@/utils';
|
||||
import { getCookie, setCookie } from 'typescript-cookie';
|
||||
import { defineComponent } from 'vue';
|
||||
import { Switch as DarkSwitch, toggleDark, isDark } from 'vue-dark-switch';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
DarkSwitch
|
||||
},
|
||||
emits: ['update:dark'],
|
||||
computed: {
|
||||
dark() {
|
||||
return getCookie('THEME') === 'dark';
|
||||
},
|
||||
switchValue() {
|
||||
return isDark.value;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
switchValue(val) {
|
||||
console.log('switchValue', val);
|
||||
this.setCookie(val);
|
||||
},
|
||||
dark(val) {
|
||||
document.documentElement.classList.toggle('dark', val);
|
||||
this.setCookie(this.dark);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('dark selector mounted');
|
||||
if (this.dark) {
|
||||
toggleDark(true);
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
toggleDark(false);
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setCookie(isDark: boolean) {
|
||||
setCookie('THEME', isDark ? 'dark' : 'light', {
|
||||
path: '/',
|
||||
domain: getDomain()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.switch {
|
||||
--n-rail-color-active: var(--el-color-primary) !important;
|
||||
--n-loading-color: var(--el-color-primary) !important;
|
||||
border-radius: 10px !important;
|
||||
border: 1px solid var(--el-border-color);
|
||||
overflow: hidden;
|
||||
.n-switch__button {
|
||||
border-radius: 50% !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,39 +0,0 @@
|
||||
<template>
|
||||
<el-menu mode="horizontal" :default-active="active">
|
||||
<el-menu-item v-if="site?.features?.midjourney?.enabled" index="/midjourney" @click="$router.push('/midjourney')">
|
||||
{{ $t('common.nav.midjourney') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="site?.features?.flux?.enabled" index="/flux" @click="$router.push('/flux')">
|
||||
{{ $t('common.nav.flux') }}
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ElMenu, ElMenuItem } from 'element-plus';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ImageNavigator',
|
||||
components: {
|
||||
ElMenu,
|
||||
ElMenuItem
|
||||
},
|
||||
computed: {
|
||||
site() {
|
||||
return this.$store.state.site;
|
||||
},
|
||||
active() {
|
||||
console.log(this.$route.path);
|
||||
return this.$route.path;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.el-menu {
|
||||
justify-content: center;
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,68 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dropdown max-height="700" trigger="click" @command="onSelectLocale">
|
||||
<i class="icon">
|
||||
<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" width="1.2em" height="1.2em">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"
|
||||
></path>
|
||||
</svg>
|
||||
</i>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="(locale, localeIndex) in locales" :key="localeIndex" :command="locale.value">
|
||||
{{ locale.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDropdown, ElDropdownItem, ElDropdownMenu } from 'element-plus';
|
||||
import { SUPPORTED_LOCALES, setI18nLanguage } from '@/i18n';
|
||||
import { setCookie } from 'typescript-cookie';
|
||||
import { getDomain } from '@/utils/initializer';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LanguageSelector',
|
||||
components: {
|
||||
ElDropdown,
|
||||
ElDropdownItem,
|
||||
ElDropdownMenu
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
locales: SUPPORTED_LOCALES
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async onSelectLocale(locale: string) {
|
||||
// change router
|
||||
this.$router.push({ query: { ...this.$route.query, locale: undefined } });
|
||||
await setI18nLanguage(locale);
|
||||
this.setCookie(locale);
|
||||
window.location.reload();
|
||||
},
|
||||
setCookie(locale: string) {
|
||||
setCookie('LOCALE', locale, {
|
||||
path: '/',
|
||||
domain: getDomain()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.icon {
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
margin-top: 4px;
|
||||
color: var(--el-menu-text-color);
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
@@ -48,8 +48,6 @@
|
||||
<dark-selector class="float-right mr-4" />
|
||||
</div>
|
||||
<div v-else class="float-right">
|
||||
<dark-selector />
|
||||
<language-selector class="locale" />
|
||||
<div class="console" @click="onConsole">
|
||||
{{ $t('common.button.console') }}
|
||||
</div>
|
||||
@@ -73,8 +71,6 @@ import defaultAvatar from '@/assets/images/avatar.png';
|
||||
import { getBaseUrlAuth } from '@/utils';
|
||||
import { ROUTE_AUTH_LOGIN, ROUTE_CONSOLE_ROOT, ROUTE_INDEX } from '@/router';
|
||||
import { ElCol, ElRow, ElDropdown, ElMenu, ElSubMenu, ElMenuItem, ElDropdownItem, ElButton } from 'element-plus';
|
||||
import DarkSelector from './DarkSelector2.vue';
|
||||
import LanguageSelector from './LanguageSelector.vue';
|
||||
import Logo from './Logo.vue';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -83,14 +79,12 @@ export default defineComponent({
|
||||
ElCol,
|
||||
Logo,
|
||||
ElRow,
|
||||
DarkSelector,
|
||||
ElDropdown,
|
||||
ElMenu,
|
||||
ElMenuItem,
|
||||
ElDropdownItem,
|
||||
ElButton,
|
||||
ElSubMenu,
|
||||
LanguageSelector
|
||||
ElSubMenu
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<template>
|
||||
<el-menu mode="horizontal" :default-active="active">
|
||||
<el-menu-item v-if="site?.features?.luma?.enabled" index="/luma" @click="$router.push('/luma')">
|
||||
{{ $t('common.nav.luma') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="site?.features?.pika?.enabled" index="/pika" @click="$router.push('/pika')">
|
||||
{{ $t('common.nav.pika') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="site?.features?.hailuo?.enabled" index="/hailuo" @click="$router.push('/hailuo')">
|
||||
{{ $t('common.nav.hailuo') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="site?.features?.kling?.enabled" index="/kling" @click="$router.push('/kling')">
|
||||
{{ $t('common.nav.kling') }}
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ElMenu, ElMenuItem } from 'element-plus';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VideoNavigator',
|
||||
components: {
|
||||
ElMenu,
|
||||
ElMenuItem
|
||||
},
|
||||
computed: {
|
||||
site() {
|
||||
return this.$store.state.site;
|
||||
},
|
||||
active() {
|
||||
console.log(this.$route.path);
|
||||
return this.$route.path;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.el-menu {
|
||||
justify-content: center;
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
@@ -2,6 +2,8 @@
|
||||
import type { PropType } from 'vue';
|
||||
import { defineComponent, computed, h } from 'vue';
|
||||
import MarkdownIt, { Options as MarkdownItOptions } from 'markdown-it';
|
||||
import 'katex/dist/katex.min.css';
|
||||
import { katex } from '@mdit/plugin-katex';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VueMarkdown',
|
||||
@@ -17,7 +19,13 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
setup(props, { attrs }) {
|
||||
const md = new MarkdownIt(props.options);
|
||||
const md = new MarkdownIt(props.options).use(katex as any, {
|
||||
delimiters: 'all',
|
||||
throwOnError: false,
|
||||
errorColor: '#cc0000',
|
||||
mathFence: true
|
||||
});
|
||||
|
||||
const content = computed(() => {
|
||||
const src = props.source;
|
||||
return md?.render(src);
|
||||
|
||||
@@ -45,7 +45,7 @@ import { ERROR_CODE_CANCELED, ERROR_CODE_NOT_APPLIED, ERROR_CODE_UNKNOWN } from
|
||||
import { Status } from '@/models';
|
||||
import Disclaimer from '@/components/chat/Disclaimer.vue';
|
||||
import Layout from '@/layouts/Chat.vue';
|
||||
import { isImageUrl, isJSONString } from '@/utils/is';
|
||||
import { isImageUrl } from '@/utils/is';
|
||||
import { chatOperator } from '@/operators';
|
||||
|
||||
export interface IData {
|
||||
|
||||
Reference in new issue
Block a user