update model toggling

This commit is contained in:
Zhang Minghan 2023-07-23 12:43:58 +08:00
parent 9f5a4a2ee6
commit 77020c13f0
4 changed files with 12 additions and 8 deletions

View File

@ -1,12 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import Login from "./components/icons/login.vue"; import Login from "./components/icons/login.vue";
import {auth, username} from "./assets/script/auth"; import { auth, username } from "./assets/script/auth";
import Light from "./components/icons/light.vue"; import Light from "./components/icons/light.vue";
import Star from "./components/icons/star.vue"; import Star from "./components/icons/star.vue";
import { ref } from "vue"; import { mobile, gpt4 } from "./assets/script/shared";
import {mobile} from "./assets/script/shared";
const gpt4 = ref(false);
function goto() { function goto() {
window.location.href = "https://deeptrain.net/login?app=chatnio"; window.location.href = "https://deeptrain.net/login?app=chatnio";

View File

@ -1,14 +1,16 @@
import {nextTick, reactive, ref} from "vue"; import {nextTick, reactive, ref} from "vue";
import type { Ref } from "vue"; import type { Ref } from "vue";
import axios from "axios"; import axios from "axios";
import {auth, token} from "./auth"; import { auth, token } from "./auth";
import {ws_api} from "./conf"; import { ws_api } from "./conf";
import { gpt4 } from "./shared";
type Message = { type Message = {
content: string; content: string;
role: string; role: string;
time: string; time: string;
stamp: number; stamp: number;
gpt4?: boolean;
} }
type StreamMessage = { type StreamMessage = {
@ -132,6 +134,7 @@ export class Conversation {
role: "user", role: "user",
time: new Date().toLocaleTimeString(), time: new Date().toLocaleTimeString(),
stamp: new Date().getTime(), stamp: new Date().getTime(),
gpt4: gpt4.value,
}) })
nextTick(() => { nextTick(() => {
this.refresh(); this.refresh();
@ -144,6 +147,7 @@ export class Conversation {
role: "bot", role: "bot",
time: new Date().toLocaleTimeString(), time: new Date().toLocaleTimeString(),
stamp: new Date().getTime(), stamp: new Date().getTime(),
gpt4: gpt4.value,
}) })
this.typingEffect(this.len.value - 1, content); this.typingEffect(this.len.value - 1, content);
} }
@ -154,6 +158,7 @@ export class Conversation {
role: "bot", role: "bot",
time: new Date().toLocaleTimeString(), time: new Date().toLocaleTimeString(),
stamp: new Date().getTime(), stamp: new Date().getTime(),
gpt4: gpt4.value,
}) })
this.dynamicTypingEffect(this.len.value - 1, content, end); this.dynamicTypingEffect(this.len.value - 1, content, end);
} }

View File

@ -1,6 +1,7 @@
import {ref} from "vue"; import {ref} from "vue";
export const mobile = ref<boolean>((document.body.clientWidth < document.body.clientHeight) && (document.body.clientWidth < 600)); export const mobile = ref<boolean>((document.body.clientWidth < document.body.clientHeight) && (document.body.clientWidth < 600));
export const gpt4 = ref(false);
window.addEventListener("resize", () => { window.addEventListener("resize", () => {
mobile.value = (document.body.clientWidth < document.body.clientHeight) && (document.body.clientWidth < 600); mobile.value = (document.body.clientWidth < document.body.clientHeight) && (document.body.clientWidth < 600);

View File

@ -46,7 +46,7 @@ onMounted(() => {
</div> </div>
<div class="message" :class="{'user': message.role === 'user'}"> <div class="message" :class="{'user': message.role === 'user'}">
<div class="grow" v-if="message.role === 'user'"></div> <div class="grow" v-if="message.role === 'user'"></div>
<div class="avatar openai" v-else><openai /></div> <div class="avatar openai" :class="{'gpt4': message.gpt4}" v-else><openai /></div>
<div class="content"> <div class="content">
<span v-if="message.role === 'user'">{{ message.content }}</span> <span v-if="message.role === 'user'">{{ message.content }}</span>
<md-preview v-model="message.content" theme="dark" v-else /> <md-preview v-model="message.content" theme="dark" v-else />
@ -283,7 +283,7 @@ onMounted(() => {
transition: .5s; transition: .5s;
} }
.avatar.openai svg { .avatar.openai.gpt4 svg {
fill: #FFD700; fill: #FFD700;
} }