办学质量监测教学评价系统
shenrongliang
2025-06-13 11d86cc6c26bb4f709e407acadf4805c2024e79f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<script setup lang="ts">
import { computed, defineAsyncComponent, ref, onMounted, Component, h } from "vue";
import { PromptStore, SvgIcon } from '@/components/common'
import { useBasicLayout } from '@/hooks/useBasicLayout'
const { isMobile } = useBasicLayout()
import { removeToken } from '@/store/modules/auth/helper'
import { NTooltip, NAvatar, NPopover, NMenu, NIcon } from 'naive-ui'
 
import { loginOut, getUserInfo } from '@/api/user'
 
import { defaultSetting, UserInfo } from '@/store/modules/user/helper'
import { useRouter } from 'vue-router'
import { getToken } from "@/store/modules/auth/helper";
import to from "await-to-js";
import {
  Settings as settings,
  Storefront as storefront,
  LogOut as out
} from '@vicons/ionicons5'
 
 
const Setting = defineAsyncComponent(() => import('@/components/common/Setting/index.vue'))
 
const st = ref({ 'show': false, showImg: false, menu: [], active: 'chat' })
const router1 = useRouter()
const userInfo = ref<UserInfo>(defaultSetting().userInfo)
 
const show = ref(false)
const urouter = useRouter() //
const isLogin = computed(() => {
  return localStorage.getItem('TOKEN')
});
 
import { router } from '@/router'
 
const goHome = computed(() => {
  return router.currentRoute.value.name
});
 
onMounted(() => {
  getLoginUserInfo();
});
 
 
/**
 * 获取当前登录用户信息
 */
async function getLoginUserInfo() {
  // 用户未登录,不需要获取用户信息
  if (!getToken()) {
    return
  }
  const [err, newUserInfo] = await to(getUserInfo());
  if (err) {
    // message.error(err.toString())
    console.log(err.toString())
  }
  if (newUserInfo) {
    if (newUserInfo.data.user.avatar) {
      userInfo.value.avatar = newUserInfo.data.user.avatar;
    }
    userInfo.value.name = newUserInfo.data.user.nickName;
    userInfo.value.userBalance = newUserInfo.data.user.userBalance;
    userInfo.value.userName = newUserInfo.data.user.userName;
    isLogin.value = true
  }
}
 
async function handleReset() {
  await loginOut()
  // 删除用户token
  removeToken();
  // 跳转到登录页面
  router1.push('/login')
}
 
async function longin() {
  // 跳转到登录页面
  router1.push('/login')
}
 
function renderIcon(icon: Component) {
  return () => h(NIcon, null, { default: () => h(icon) })
}
 
const menuOptions = ref([
  {
    label: '账号设置',
    key: 'accountSettings',
    icon: renderIcon(settings)
  },
  {
    label: '立即充值',
    key: 'buy',
    icon: renderIcon(storefront)
  },
  {
    label: '退出账号',
    key: 'logout',
    icon: renderIcon(out)
  }
])
 
const handleSelect = (key: string) => {
  if (key === 'accountSettings') {
    st.value.show = true
  } else if (key === 'logout') {
    handleReset()
  } else if (key === 'buy') {
    show.value = true
  }
}
</script>
<template>
 
 
  <div class="flex-shrink-0 w-[70px] z-[1000]  h-full" v-if="!isMobile" data-tauri-drag-region>
    <div
      class="flex h-full select-none flex-col items-center justify-between bg-[#e8eaf1] px-2 pt-4 pb-8 dark:bg-[#25272d]">
      <div class="flex flex-col space-y-4 flex-1 " data-tauri-drag-region>
        <a @click="st.active = 'chat'; urouter.push(`/chat`)"
          class="router-link-active router-link-exact-active h-10 w-10 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
          <n-tooltip placement="right" trigger="hover">
            <template #trigger>
              <div class="flex h-full justify-center items-center py-1 flex-col "
                :class="[goHome == 'Chat' ? 'active' : '']">
                <SvgIcon icon="ri:wechat-line" class="text-2xl  flex-1"></SvgIcon>
              </div>
            </template>
            对话
          </n-tooltip>
        </a>
 
        <a @click="urouter.push(`/knowledge`)"
          class=" router-link-exact-active h-10 w-10 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
          <n-tooltip placement="right" trigger="hover">
            <template #trigger>
              <div class="flex h-full justify-center items-center   py-1 flex-col">
                <SvgIcon icon="garden:knowledge-base-26" class="text-2xl flex-1"></SvgIcon>
              </div>
            </template>
            知识库
          </n-tooltip>
        </a>
 
        <a @click="urouter.push(`/draw`)"
          class=" router-link-exact-active h-10 w-10 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
          <n-tooltip placement="right" trigger="hover">
            <template #trigger>
              <div class="flex h-full justify-center items-center   py-1 flex-col">
                <SvgIcon icon="material-symbols:draw-rounded" class="text-2xl flex-1"></SvgIcon>
              </div>
            </template>
            绘画
          </n-tooltip>
        </a>
 
        <a @click="urouter.push(`/music`)"
          class=" router-link-exact-active h-10 w-10 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
          <n-tooltip placement="right" trigger="hover">
            <template #trigger>
              <div class="flex h-full justify-center items-center   py-1 flex-col">
                <SvgIcon icon="mingcute:music-line" class="text-2xl flex-1"></SvgIcon>
              </div>
            </template>
            音乐
          </n-tooltip>
        </a>
 
        <a @click="urouter.push(`/video`)"
          class=" router-link-exact-active h-10 w-10 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
          <n-tooltip placement="right" trigger="hover">
            <template #trigger>
              <div class="flex h-full justify-center items-center   py-1 flex-col">
                <SvgIcon icon="mynaui:video" class="text-2xl flex-1"></SvgIcon>
              </div>
            </template>
            视频
          </n-tooltip>
        </a>
 
 
        <a @click="urouter.push(`/ppt`)"
          class=" router-link-exact-active h-10 w-10 cursor-pointer rounded-xl bg-white duration-300 dark:bg-[#34373c] hover:bg-[#bbb] dark:hover:bg-[#555]">
          <n-tooltip placement="right" trigger="hover">
            <template #trigger>
              <div class="flex h-full justify-center items-center   py-1 flex-col">
                <SvgIcon icon="icon-park-outline:ppt" class="text-2xl flex-1"></SvgIcon>
              </div>
            </template>
            PPT
          </n-tooltip>
        </a>
      </div>
 
      <div class="flex flex-col  space-y-2 ">
 
 
        <n-popover trigger="click" :show-arrow="false">
          <template #trigger>
            <n-avatar v-show="isLogin" size="large" round :src="userInfo.avatar" />
          </template>
          <n-menu :options="menuOptions" @select="handleSelect" />
        </n-popover>
 
        <div v-show="!isLogin" class="user-bottom" @click="longin">
          <n-button tertiary type="info">
            登录
          </n-button>
        </div>
 
      </div>
 
      
    </div>
    
  </div>
  <Setting v-if="st.show" v-model:visible="st.show" />
  <PromptStore v-model:visible="show"></PromptStore>
  
</template>