Amber后台配置迁移和优化

将应用的配置从状态管理仓库迁移到独立的配置文件,以简化配置的管理。同时,统一使用新的配置方式,优化了配置的加载逻辑,提高了代码的可读性和维护性。此外,对部分Vue组件和API插件进行了相应的配置路径调整,确保应用的各个部分都能正确地使用新的配置方式。

BREAKING CHANGE: 由于配置项的位置和加载方式已更改,因此任何依赖于旧配置路径或方法的代码都必须进行相应的调整,以确保应用能够正常运行。
This commit is contained in:
ivamp 2024-08-04 17:11:23 +08:00
parent 2001fb5e51
commit 5a085d3c60
17 changed files with 237 additions and 324 deletions

424
src/auto-imports.d.ts vendored
View File

@ -5,271 +5,187 @@
// Generated by unplugin-auto-import
export {}
declare global {
const EffectScope: (typeof import("vue"))["EffectScope"];
const computed: (typeof import("vue"))["computed"];
const createApp: (typeof import("vue"))["createApp"];
const customRef: (typeof import("vue"))["customRef"];
const defineAsyncComponent: (typeof import("vue"))["defineAsyncComponent"];
const defineComponent: (typeof import("vue"))["defineComponent"];
const effectScope: (typeof import("vue"))["effectScope"];
const getCurrentInstance: (typeof import("vue"))["getCurrentInstance"];
const getCurrentScope: (typeof import("vue"))["getCurrentScope"];
const h: (typeof import("vue"))["h"];
const inject: (typeof import("vue"))["inject"];
const isProxy: (typeof import("vue"))["isProxy"];
const isReactive: (typeof import("vue"))["isReactive"];
const isReadonly: (typeof import("vue"))["isReadonly"];
const isRef: (typeof import("vue"))["isRef"];
const markRaw: (typeof import("vue"))["markRaw"];
const nextTick: (typeof import("vue"))["nextTick"];
const onActivated: (typeof import("vue"))["onActivated"];
const onBeforeMount: (typeof import("vue"))["onBeforeMount"];
const onBeforeRouteLeave: (typeof import("vue-router"))["onBeforeRouteLeave"];
const onBeforeRouteUpdate: (typeof import("vue-router"))["onBeforeRouteUpdate"];
const onBeforeUnmount: (typeof import("vue"))["onBeforeUnmount"];
const onBeforeUpdate: (typeof import("vue"))["onBeforeUpdate"];
const onDeactivated: (typeof import("vue"))["onDeactivated"];
const onErrorCaptured: (typeof import("vue"))["onErrorCaptured"];
const onMounted: (typeof import("vue"))["onMounted"];
const onRenderTracked: (typeof import("vue"))["onRenderTracked"];
const onRenderTriggered: (typeof import("vue"))["onRenderTriggered"];
const onScopeDispose: (typeof import("vue"))["onScopeDispose"];
const onServerPrefetch: (typeof import("vue"))["onServerPrefetch"];
const onUnmounted: (typeof import("vue"))["onUnmounted"];
const onUpdated: (typeof import("vue"))["onUpdated"];
const provide: (typeof import("vue"))["provide"];
const reactive: (typeof import("vue"))["reactive"];
const readonly: (typeof import("vue"))["readonly"];
const ref: (typeof import("vue"))["ref"];
const resolveComponent: (typeof import("vue"))["resolveComponent"];
const shallowReactive: (typeof import("vue"))["shallowReactive"];
const shallowReadonly: (typeof import("vue"))["shallowReadonly"];
const shallowRef: (typeof import("vue"))["shallowRef"];
const toRaw: (typeof import("vue"))["toRaw"];
const toRef: (typeof import("vue"))["toRef"];
const toRefs: (typeof import("vue"))["toRefs"];
const toValue: (typeof import("vue"))["toValue"];
const triggerRef: (typeof import("vue"))["triggerRef"];
const unref: (typeof import("vue"))["unref"];
const useAttrs: (typeof import("vue"))["useAttrs"];
const useCssModule: (typeof import("vue"))["useCssModule"];
const useCssVars: (typeof import("vue"))["useCssVars"];
const useLink: (typeof import("vue-router"))["useLink"];
const useRoute: (typeof import("vue-router/auto"))["useRoute"];
const useRouter: (typeof import("vue-router/auto"))["useRouter"];
const useSlots: (typeof import("vue"))["useSlots"];
const watch: (typeof import("vue"))["watch"];
const watchEffect: (typeof import("vue"))["watchEffect"];
const watchPostEffect: (typeof import("vue"))["watchPostEffect"];
const watchSyncEffect: (typeof import("vue"))["watchSyncEffect"];
const EffectScope: typeof import('vue')['EffectScope']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeRouteLeave: (typeof import("vue-router"))["onBeforeRouteLeave"]
const onBeforeRouteUpdate: (typeof import("vue-router"))["onBeforeRouteUpdate"]
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onMounted: typeof import('vue')['onMounted']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useLink: (typeof import("vue-router"))["useLink"]
const useRoute: typeof import('vue-router/auto')['useRoute']
const useRouter: typeof import('vue-router/auto')['useRouter']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
}
// for type re-export
declare global {
// @ts-ignore
export type {
Component,
ComponentPublicInstance,
ComputedRef,
ExtractDefaultPropTypes,
ExtractPropTypes,
ExtractPublicPropTypes,
InjectionKey,
PropType,
Ref,
VNode,
WritableComputedRef,
} from "vue";
import("vue");
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}
// for vue template auto import
import { UnwrapRef } from "vue";
declare module "vue" {
import { UnwrapRef } from 'vue'
declare module 'vue' {
interface GlobalComponents {}
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<(typeof import("vue"))["EffectScope"]>;
readonly computed: UnwrapRef<(typeof import("vue"))["computed"]>;
readonly createApp: UnwrapRef<(typeof import("vue"))["createApp"]>;
readonly customRef: UnwrapRef<(typeof import("vue"))["customRef"]>;
readonly defineAsyncComponent: UnwrapRef<
(typeof import("vue"))["defineAsyncComponent"]
>;
readonly defineComponent: UnwrapRef<
(typeof import("vue"))["defineComponent"]
>;
readonly effectScope: UnwrapRef<(typeof import("vue"))["effectScope"]>;
readonly getCurrentInstance: UnwrapRef<
(typeof import("vue"))["getCurrentInstance"]
>;
readonly getCurrentScope: UnwrapRef<
(typeof import("vue"))["getCurrentScope"]
>;
readonly h: UnwrapRef<(typeof import("vue"))["h"]>;
readonly inject: UnwrapRef<(typeof import("vue"))["inject"]>;
readonly isProxy: UnwrapRef<(typeof import("vue"))["isProxy"]>;
readonly isReactive: UnwrapRef<(typeof import("vue"))["isReactive"]>;
readonly isReadonly: UnwrapRef<(typeof import("vue"))["isReadonly"]>;
readonly isRef: UnwrapRef<(typeof import("vue"))["isRef"]>;
readonly markRaw: UnwrapRef<(typeof import("vue"))["markRaw"]>;
readonly nextTick: UnwrapRef<(typeof import("vue"))["nextTick"]>;
readonly onActivated: UnwrapRef<(typeof import("vue"))["onActivated"]>;
readonly onBeforeMount: UnwrapRef<(typeof import("vue"))["onBeforeMount"]>;
readonly onBeforeUnmount: UnwrapRef<
(typeof import("vue"))["onBeforeUnmount"]
>;
readonly onBeforeUpdate: UnwrapRef<
(typeof import("vue"))["onBeforeUpdate"]
>;
readonly onDeactivated: UnwrapRef<(typeof import("vue"))["onDeactivated"]>;
readonly onErrorCaptured: UnwrapRef<
(typeof import("vue"))["onErrorCaptured"]
>;
readonly onMounted: UnwrapRef<(typeof import("vue"))["onMounted"]>;
readonly onRenderTracked: UnwrapRef<
(typeof import("vue"))["onRenderTracked"]
>;
readonly onRenderTriggered: UnwrapRef<
(typeof import("vue"))["onRenderTriggered"]
>;
readonly onScopeDispose: UnwrapRef<
(typeof import("vue"))["onScopeDispose"]
>;
readonly onServerPrefetch: UnwrapRef<
(typeof import("vue"))["onServerPrefetch"]
>;
readonly onUnmounted: UnwrapRef<(typeof import("vue"))["onUnmounted"]>;
readonly onUpdated: UnwrapRef<(typeof import("vue"))["onUpdated"]>;
readonly provide: UnwrapRef<(typeof import("vue"))["provide"]>;
readonly reactive: UnwrapRef<(typeof import("vue"))["reactive"]>;
readonly readonly: UnwrapRef<(typeof import("vue"))["readonly"]>;
readonly ref: UnwrapRef<(typeof import("vue"))["ref"]>;
readonly resolveComponent: UnwrapRef<
(typeof import("vue"))["resolveComponent"]
>;
readonly shallowReactive: UnwrapRef<
(typeof import("vue"))["shallowReactive"]
>;
readonly shallowReadonly: UnwrapRef<
(typeof import("vue"))["shallowReadonly"]
>;
readonly shallowRef: UnwrapRef<(typeof import("vue"))["shallowRef"]>;
readonly toRaw: UnwrapRef<(typeof import("vue"))["toRaw"]>;
readonly toRef: UnwrapRef<(typeof import("vue"))["toRef"]>;
readonly toRefs: UnwrapRef<(typeof import("vue"))["toRefs"]>;
readonly toValue: UnwrapRef<(typeof import("vue"))["toValue"]>;
readonly triggerRef: UnwrapRef<(typeof import("vue"))["triggerRef"]>;
readonly unref: UnwrapRef<(typeof import("vue"))["unref"]>;
readonly useAttrs: UnwrapRef<(typeof import("vue"))["useAttrs"]>;
readonly useCssModule: UnwrapRef<(typeof import("vue"))["useCssModule"]>;
readonly useCssVars: UnwrapRef<(typeof import("vue"))["useCssVars"]>;
readonly useRoute: UnwrapRef<
(typeof import("vue-router/auto"))["useRoute"]
>;
readonly useRouter: UnwrapRef<
(typeof import("vue-router/auto"))["useRouter"]
>;
readonly useSlots: UnwrapRef<(typeof import("vue"))["useSlots"]>;
readonly watch: UnwrapRef<(typeof import("vue"))["watch"]>;
readonly watchEffect: UnwrapRef<(typeof import("vue"))["watchEffect"]>;
readonly watchPostEffect: UnwrapRef<
(typeof import("vue"))["watchPostEffect"]
>;
readonly watchSyncEffect: UnwrapRef<
(typeof import("vue"))["watchSyncEffect"]
>;
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']>
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']>
readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']>
readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']>
readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']>
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
readonly ref: UnwrapRef<typeof import('vue')['ref']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
readonly toValue: UnwrapRef<typeof import('vue')['toValue']>
readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']>
readonly unref: UnwrapRef<typeof import('vue')['unref']>
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>
readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']>
}
}
declare module "@vue/runtime-core" {
declare module '@vue/runtime-core' {
interface GlobalComponents {}
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<(typeof import("vue"))["EffectScope"]>;
readonly computed: UnwrapRef<(typeof import("vue"))["computed"]>;
readonly createApp: UnwrapRef<(typeof import("vue"))["createApp"]>;
readonly customRef: UnwrapRef<(typeof import("vue"))["customRef"]>;
readonly defineAsyncComponent: UnwrapRef<
(typeof import("vue"))["defineAsyncComponent"]
>;
readonly defineComponent: UnwrapRef<
(typeof import("vue"))["defineComponent"]
>;
readonly effectScope: UnwrapRef<(typeof import("vue"))["effectScope"]>;
readonly getCurrentInstance: UnwrapRef<
(typeof import("vue"))["getCurrentInstance"]
>;
readonly getCurrentScope: UnwrapRef<
(typeof import("vue"))["getCurrentScope"]
>;
readonly h: UnwrapRef<(typeof import("vue"))["h"]>;
readonly inject: UnwrapRef<(typeof import("vue"))["inject"]>;
readonly isProxy: UnwrapRef<(typeof import("vue"))["isProxy"]>;
readonly isReactive: UnwrapRef<(typeof import("vue"))["isReactive"]>;
readonly isReadonly: UnwrapRef<(typeof import("vue"))["isReadonly"]>;
readonly isRef: UnwrapRef<(typeof import("vue"))["isRef"]>;
readonly markRaw: UnwrapRef<(typeof import("vue"))["markRaw"]>;
readonly nextTick: UnwrapRef<(typeof import("vue"))["nextTick"]>;
readonly onActivated: UnwrapRef<(typeof import("vue"))["onActivated"]>;
readonly onBeforeMount: UnwrapRef<(typeof import("vue"))["onBeforeMount"]>;
readonly onBeforeUnmount: UnwrapRef<
(typeof import("vue"))["onBeforeUnmount"]
>;
readonly onBeforeUpdate: UnwrapRef<
(typeof import("vue"))["onBeforeUpdate"]
>;
readonly onDeactivated: UnwrapRef<(typeof import("vue"))["onDeactivated"]>;
readonly onErrorCaptured: UnwrapRef<
(typeof import("vue"))["onErrorCaptured"]
>;
readonly onMounted: UnwrapRef<(typeof import("vue"))["onMounted"]>;
readonly onRenderTracked: UnwrapRef<
(typeof import("vue"))["onRenderTracked"]
>;
readonly onRenderTriggered: UnwrapRef<
(typeof import("vue"))["onRenderTriggered"]
>;
readonly onScopeDispose: UnwrapRef<
(typeof import("vue"))["onScopeDispose"]
>;
readonly onServerPrefetch: UnwrapRef<
(typeof import("vue"))["onServerPrefetch"]
>;
readonly onUnmounted: UnwrapRef<(typeof import("vue"))["onUnmounted"]>;
readonly onUpdated: UnwrapRef<(typeof import("vue"))["onUpdated"]>;
readonly provide: UnwrapRef<(typeof import("vue"))["provide"]>;
readonly reactive: UnwrapRef<(typeof import("vue"))["reactive"]>;
readonly readonly: UnwrapRef<(typeof import("vue"))["readonly"]>;
readonly ref: UnwrapRef<(typeof import("vue"))["ref"]>;
readonly resolveComponent: UnwrapRef<
(typeof import("vue"))["resolveComponent"]
>;
readonly shallowReactive: UnwrapRef<
(typeof import("vue"))["shallowReactive"]
>;
readonly shallowReadonly: UnwrapRef<
(typeof import("vue"))["shallowReadonly"]
>;
readonly shallowRef: UnwrapRef<(typeof import("vue"))["shallowRef"]>;
readonly toRaw: UnwrapRef<(typeof import("vue"))["toRaw"]>;
readonly toRef: UnwrapRef<(typeof import("vue"))["toRef"]>;
readonly toRefs: UnwrapRef<(typeof import("vue"))["toRefs"]>;
readonly toValue: UnwrapRef<(typeof import("vue"))["toValue"]>;
readonly triggerRef: UnwrapRef<(typeof import("vue"))["triggerRef"]>;
readonly unref: UnwrapRef<(typeof import("vue"))["unref"]>;
readonly useAttrs: UnwrapRef<(typeof import("vue"))["useAttrs"]>;
readonly useCssModule: UnwrapRef<(typeof import("vue"))["useCssModule"]>;
readonly useCssVars: UnwrapRef<(typeof import("vue"))["useCssVars"]>;
readonly useRoute: UnwrapRef<
(typeof import("vue-router/auto"))["useRoute"]
>;
readonly useRouter: UnwrapRef<
(typeof import("vue-router/auto"))["useRouter"]
>;
readonly useSlots: UnwrapRef<(typeof import("vue"))["useSlots"]>;
readonly watch: UnwrapRef<(typeof import("vue"))["watch"]>;
readonly watchEffect: UnwrapRef<(typeof import("vue"))["watchEffect"]>;
readonly watchPostEffect: UnwrapRef<
(typeof import("vue"))["watchPostEffect"]
>;
readonly watchSyncEffect: UnwrapRef<
(typeof import("vue"))["watchSyncEffect"]
>;
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']>
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']>
readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']>
readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']>
readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']>
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
readonly ref: UnwrapRef<typeof import('vue')['ref']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
readonly toValue: UnwrapRef<typeof import('vue')['toValue']>
readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']>
readonly unref: UnwrapRef<typeof import('vue')['unref']>
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>
readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']>
}
}

5
src/components.d.ts vendored
View File

@ -2,15 +2,12 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {};
export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
AppBar: typeof import('./components/AppBar.vue')['default']
AppFooter: typeof import('./components/AppFooter.vue')['default']
copy: typeof import('./components/default copy.vue')['default']
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
View: typeof import('./components/View.vue')['default']

View File

@ -16,7 +16,7 @@
<!-- <v-divider></v-divider> -->
<v-list density="compact" nav>
<template v-for="item in appStore.navigation_items">
<template v-for="item in appStore.navigation_items" :key="item.to">
<v-list-item
:prepend-icon="item.icon"
rounded="lg"
@ -33,11 +33,8 @@
to="/auth/login"
/>
<template
v-if="chats.data != null"
v-for="chat in chats.data"
:key="chat.id"
>
<template v-if="chats.data != null">
<template v-for="chat in chats.data" :key="chat.id">
<v-list-item
prepend-icon="mdi-chat"
rounded="lg"
@ -45,6 +42,7 @@
:to="'/chats/' + chat.id"
/>
</template>
</template>
</v-list>
</v-navigation-drawer>
@ -53,20 +51,19 @@
@click="appStore.navigation_drawer = !appStore.navigation_drawer"
/>
<v-app-bar-title>{{ configStore.app_name }}</v-app-bar-title>
<v-app-bar-title>{{ config.app_name }}</v-app-bar-title>
</v-app-bar>
<!-- </v-app> -->
</template>
<script lang="ts" setup>
import { useConfigStore } from "@/stores/config";
import { useUserStore } from "@/stores/user";
import { useAppStore } from "@/stores/app";
import { useChatStore } from "@/stores/chat";
import { computed } from "vue";
import { ApiV1ChatsGet200Response } from "@/api";
import config from "@/config/config";
const chatStore = useChatStore();
const configStore = useConfigStore();
const userStore = useUserStore();
const appStore = useAppStore();

20
src/config/config.ts Normal file
View File

@ -0,0 +1,20 @@
const config = {
app_name: "Amber",
oauth_discovery_url:
"https://auth.leaflow.cn/.well-known/openid-configuration",
oauth_client_id: "14",
oauth_callback_url: "http://localhost:3000/auth/callback",
oauth_storage_key: "code_verifier",
oauth_scope: "openid profile",
backend: "http://localhost:8080",
};
// @ts-ignore
if (process.env.NODE_ENV === "production") {
config.backend = "https://amber-api.leaflow.cn";
config.oauth_callback_url = "https://amber.leaflow.cn/auth/callback";
}
console.log("api endpoint: " + config.backend);
export default config;

View File

@ -4,7 +4,6 @@
</template>
<script lang="ts" setup>
// import { ref } from "vue";
// import { useConfigStore } from "@/stores/config";
import AppBar from "@/components/AppBar.vue";
import View from "@/components/View.vue";
import { useTheme } from "vuetify";

View File

@ -4,25 +4,24 @@
</div>
</template>
<script lang="ts">
<script setup lang="ts">
import axios from "axios";
import { useConfigStore } from "@/stores/config";
import { useUserStore } from "@/stores/user";
import router from "@/router";
const configStore = useConfigStore();
import config from "@/config/config";
const userStore = useUserStore();
const discovery = await axios.get(configStore.oauth_discovery_url);
const discovery = await axios.get(config.oauth_discovery_url);
const localCodeVerifier = localStorage.getItem(configStore.oauth_storage_key);
const localCodeVerifier = localStorage.getItem(config.oauth_storage_key);
// code
const code = new URLSearchParams(window.location.search).get("code");
const q = new URLSearchParams({
client_id: configStore.oauth_client_id,
client_id: config.oauth_client_id,
grant_type: "authorization_code",
redirect_uri: configStore.oauth_callback_url,
redirect_uri: config.oauth_callback_url,
code_verifier: localCodeVerifier || "",
code: code || "",
});

View File

@ -4,12 +4,11 @@
</div>
</template>
<script lang="ts">
<script setup lang="ts">
import config from "@/config/config";
import axios from "axios";
import { useConfigStore } from "@/stores/config";
const configStore = useConfigStore();
const discovery = await axios.get(configStore.oauth_discovery_url);
const discovery = await axios.get(config.oauth_discovery_url);
function generateRandomString(length: number) {
let text = "";
@ -39,13 +38,13 @@ const codeVerifier = generateRandomString(128);
const codeChallenge = await generateCodeChallenge(codeVerifier);
// save code_verifier to localStorage
localStorage.setItem(configStore.oauth_storage_key, codeVerifier);
localStorage.setItem(config.oauth_storage_key, codeVerifier);
const query = new URLSearchParams({
client_id: configStore.oauth_client_id,
redirect_uri: configStore.oauth_callback_url,
client_id: config.oauth_client_id,
redirect_uri: config.oauth_callback_url,
response_type: "code",
scope: configStore.oauth_scope,
scope: config.oauth_scope,
code_challenge: codeChallenge,
code_challenge_method: "S256",
}).toString();

View File

@ -3,12 +3,12 @@
<h3 class="mb-3">聊天记录</h3>
<v-card
class="mx-auto mt-3"
width="100%"
v-for="message in messages.data"
:key="message.id"
class="mx-auto mt-3"
width="100%"
>
<template v-slot:title>
<template #title>
<span class="font-weight-black">
<span v-if="message.role == 'assistant'"> AI </span>
<span v-else-if="message.role == 'system'"> 系统 </span>
@ -30,9 +30,9 @@
<div class="mt-3">
<div v-show="toolName != ''">
<v-progress-circular
:size="16"
color="primary"
indeterminate
:size="16"
></v-progress-circular>
{{ toolName }}
</div>
@ -62,7 +62,7 @@ const input = ref("");
const toolName = ref("");
function sendMessage() {
if (input.value != "") {
if (input.value !== "") {
api.ChatMessage.apiV1ChatsIdMessagesPost(chatId, {
message: input.value,
})
@ -86,7 +86,7 @@ function sendMessage() {
})
.catch((err) => {
// if 409
if (err.response.status == 409) {
if (err.response.status === 409) {
const streamId = err.response.data.data?.stream_id;
if (streamId) {
@ -118,15 +118,15 @@ function streamChat(streamId: String) {
window.scrollTo(0, document.body.scrollHeight);
// set index
let i = (messages.value.data?.length ?? 1) - 1;
const i = (messages.value.data?.length ?? 1) - 1;
console.log(i);
evtSource.addEventListener("data", (e) => {
const data = JSON.parse(e.data);
if (data.state == "tool_calling") {
if (data.state === "tool_calling") {
toolName.value = data.tool_call_message.name;
} else if (data.state == "tool_response") {
} else if (data.state === "tool_response") {
setTimeout(() => {
toolName.value = "";
}, 300);
@ -137,12 +137,12 @@ function streamChat(streamId: String) {
});
// close
evtSource.addEventListener("close", (e) => {
evtSource.addEventListener("close", () => {
evtSource.close();
});
}
let getMessages = () => {
const getMessages = () => {
api.ChatMessage.apiV1ChatsIdMessagesGet(chatId).then((res) => {
messages.value = res.data;
});

View File

@ -14,7 +14,7 @@ const response = ref("");
function greet() {
api.Ping.apiV1PingGet().then((res) => {
response.value = "用户 ID" + String(res.data.data?.userId) ?? "未登录";
response.value = "用户 ID" + String(res.data.data?.userId);
});
}
</script>

View File

@ -42,7 +42,7 @@ function createTool() {
url: toolUrl.value,
api_key: toolApiKey.value,
})
.then((r) => {
.then(() => {
router.push("/tools");
})
.catch((e) => {

View File

@ -1,7 +1,7 @@
<template>
<h3>工具</h3>
<v-btn color="primary" @click="to('/tools/create')" class="mt-3 mb-3"
<v-btn class="mt-3 mb-3" color="primary" @click="to('/tools/create')"
>创建工具</v-btn
>

View File

@ -6,15 +6,14 @@ import {
PingApi,
ToolApi,
} from "@/api";
import { useConfigStore } from "@/stores/config";
import config from "@/config/config";
import { useUserStore } from "@/stores/user";
const configStore = useConfigStore();
const userStore = useUserStore();
const conf = new Configuration();
conf.basePath = configStore.backend;
conf.basePath = config.backend;
conf.apiKey = () => {
return "Bearer " + userStore.id_token;
};

View File

@ -2,14 +2,5 @@
import { defineStore } from "pinia";
export const useConfigStore = defineStore("config", {
state: () => ({
app_name: "Amber",
oauth_discovery_url:
"https://auth.leaflow.cn/.well-known/openid-configuration",
oauth_client_id: "14",
oauth_callback_url: "http://localhost:3000/auth/callback",
oauth_storage_key: "code_verifier",
oauth_scope: "openid profile",
backend: "http://localhost:8080",
}),
state: () => ({}),
});

View File

@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import { useConfigStore } from "@/stores/config";
import axios from "axios";
import config from "@/config/config";
let timer: any = null;
@ -58,17 +58,15 @@ export const useUserStore = defineStore("user", {
}, 10 * 1000);
},
async refresh() {
const configStore = useConfigStore();
const discovery = await axios.get(configStore.oauth_discovery_url);
const discovery = await axios.get(config.oauth_discovery_url);
// post /oauth/token to refresh
// 构建 form 参数
const data = new URLSearchParams();
data.set("grant_type", "refresh_token");
data.set("refresh_token", this.refresh_token);
data.set("client_id", configStore.oauth_client_id);
data.set("scope", configStore.oauth_scope);
data.set("client_id", config.oauth_client_id);
data.set("scope", config.oauth_scope);
axios
.post(discovery.data.token_endpoint, data)

View File

@ -22,11 +22,9 @@ declare module 'vue-router/auto-routes' {
'/assistants/': RouteRecordInfo<'/assistants/', '/assistants', Record<never, never>, Record<never, never>>,
'/assistants/[id]/chats': RouteRecordInfo<'/assistants/[id]/chats', '/assistants/:id/chats', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/assistants/[id]/tools': RouteRecordInfo<'/assistants/[id]/tools', '/assistants/:id/tools', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/assistants/binds': RouteRecordInfo<'/assistants/binds', '/assistants/binds', Record<never, never>, Record<never, never>>,
'/assistants/create': RouteRecordInfo<'/assistants/create', '/assistants/create', Record<never, never>, Record<never, never>>,
'/auth/callback': RouteRecordInfo<'/auth/callback', '/auth/callback', Record<never, never>, Record<never, never>>,
'/auth/login': RouteRecordInfo<'/auth/login', '/auth/login', Record<never, never>, Record<never, never>>,
'/chats/': RouteRecordInfo<'/chats/', '/chats', Record<never, never>, Record<never, never>>,
'/chats/[id]/': RouteRecordInfo<'/chats/[id]/', '/chats/:id', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/ping/': RouteRecordInfo<'/ping/', '/ping', Record<never, never>, Record<never, never>>,
'/tools/': RouteRecordInfo<'/tools/', '/tools', Record<never, never>, Record<never, never>>,