zhuf 1 year ago
parent
commit
3a28bf467f
5 changed files with 38 additions and 12 deletions
  1. 6 0
      auto-imports.d.ts
  2. 6 1
      components.d.ts
  3. 1 1
      src/App.vue
  4. 24 10
      src/components/TheHeader.vue
  5. 1 0
      vite.config.ts

+ 6 - 0
auto-imports.d.ts

@@ -5,6 +5,7 @@
 export {}
 declare global {
   const EffectScope: typeof import('vue')['EffectScope']
+  const REQUEST: typeof import('./src/utils/request')['REQUEST']
   const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
   const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
   const computed: typeof import('vue')['computed']
@@ -79,6 +80,7 @@ declare global {
   const refDefault: typeof import('@vueuse/core')['refDefault']
   const refThrottled: typeof import('@vueuse/core')['refThrottled']
   const refWithControl: typeof import('@vueuse/core')['refWithControl']
+  const request: typeof import('./src/utils/request')['default']
   const resolveComponent: typeof import('vue')['resolveComponent']
   const resolveRef: typeof import('@vueuse/core')['resolveRef']
   const resolveUnref: typeof import('@vueuse/core')['resolveUnref']
@@ -292,6 +294,7 @@ import { UnwrapRef } from 'vue'
 declare module 'vue' {
   interface ComponentCustomProperties {
     readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
+    readonly REQUEST: UnwrapRef<typeof import('./src/utils/request')['REQUEST']>
     readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
     readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
     readonly computed: UnwrapRef<typeof import('vue')['computed']>
@@ -366,6 +369,7 @@ declare module 'vue' {
     readonly refDefault: UnwrapRef<typeof import('@vueuse/core')['refDefault']>
     readonly refThrottled: UnwrapRef<typeof import('@vueuse/core')['refThrottled']>
     readonly refWithControl: UnwrapRef<typeof import('@vueuse/core')['refWithControl']>
+    readonly request: UnwrapRef<typeof import('./src/utils/request')['default']>
     readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
     readonly resolveRef: UnwrapRef<typeof import('@vueuse/core')['resolveRef']>
     readonly resolveUnref: UnwrapRef<typeof import('@vueuse/core')['resolveUnref']>
@@ -573,6 +577,7 @@ declare module 'vue' {
 declare module '@vue/runtime-core' {
   interface ComponentCustomProperties {
     readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
+    readonly REQUEST: UnwrapRef<typeof import('./src/utils/request')['REQUEST']>
     readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
     readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
     readonly computed: UnwrapRef<typeof import('vue')['computed']>
@@ -647,6 +652,7 @@ declare module '@vue/runtime-core' {
     readonly refDefault: UnwrapRef<typeof import('@vueuse/core')['refDefault']>
     readonly refThrottled: UnwrapRef<typeof import('@vueuse/core')['refThrottled']>
     readonly refWithControl: UnwrapRef<typeof import('@vueuse/core')['refWithControl']>
+    readonly request: UnwrapRef<typeof import('./src/utils/request')['default']>
     readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
     readonly resolveRef: UnwrapRef<typeof import('@vueuse/core')['resolveRef']>
     readonly resolveUnref: UnwrapRef<typeof import('@vueuse/core')['resolveUnref']>

+ 6 - 1
components.d.ts

@@ -3,11 +3,16 @@
 // @ts-nocheck
 // Generated by unplugin-vue-components
 // Read more: https://github.com/vuejs/core/pull/3399
+import '@vue/runtime-core'
+
 export {}
 
-declare module 'vue' {
+declare module '@vue/runtime-core' {
   export interface GlobalComponents {
     CheckRow: typeof import('./src/components/CheckRow/index.vue')['default']
+    ElDropdown: typeof import('element-plus/es')['ElDropdown']
+    ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
+    ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
     ElIcon: typeof import('element-plus/es')['ElIcon']
     ElInput: typeof import('element-plus/es')['ElInput']
     ElPagination: typeof import('element-plus/es')['ElPagination']

+ 1 - 1
src/App.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="min-h-screen w-screen flex flex-col">
+  <div class="min-h-screen w-full flex flex-col">
     <TheHeader />
     <div class="flex flex-auto flex-col items-center justify-start py-12">
       <RouterView class="w-1200px" />

+ 24 - 10
src/components/TheHeader.vue

@@ -32,6 +32,7 @@ function browserOpen(path: string) {
   else
     router.push(path)
 }
+// @click="browserOpen(`https://openapi.bozedu.net/login.html?token=${user.token}`)"
 </script>
 
 <template>
@@ -40,20 +41,33 @@ function browserOpen(path: string) {
       <div class="text-3xl">
         宜昌市乡村教育振兴网络扶智课堂
       </div>
-      <div class="cursor-pointer">
-        <img
-          class="inline-block h-40px w-40px rounded-1/2 align-middle hover:bg-hex-1259A110 hover:text-hex-1259A1"
-          :src="user.user_avatar" alt=""
-        >
-        <span class="ml-10px inline-block align-middle">
-          {{ user.user_realname }}
-        </span>
-      </div>
+
+      <el-dropdown trigger="click">
+        <div class="cursor-pointer">
+          <img
+            class="inline-block h-40px w-40px rounded-1/2 align-middle hover:bg-hex-1259A110 hover:text-hex-1259A1"
+            :src="user?.user_avatar?.small || undefined" alt=""
+          >
+          <span class="ml-10px inline-block align-middle">
+            {{ user.user_realname }}
+          </span>
+        </div>
+        <template #dropdown>
+          <el-dropdown-menu>
+            <el-dropdown-item @click="browserOpen(`https://openapi.bozedu.net/login.html?token=${user.token}`)">
+              后台管理
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </template>
+      </el-dropdown>
     </div>
   </div>
   <div class="flex items-center justify-center bg-blue-600 text-lg text-light-50">
     <div class="w-1200px flex">
-      <div v-for="item in NavList" :key="item.id" class="h-64px w-120px cursor-pointer text-center leading-64px hover:bg-blue-500" @click="browserOpen(item.id)">
+      <div
+        v-for="item in NavList" :key="item.id"
+        class="h-64px w-120px cursor-pointer text-center leading-64px hover:bg-blue-500" @click="browserOpen(item.id)"
+      >
         {{ item.label }}
       </div>
     </div>

+ 1 - 0
vite.config.ts

@@ -45,6 +45,7 @@ export default defineConfig({
       dts: true,
       dirs: [
         './src/composables',
+        './src/utils',
       ],
       vueTemplate: true,
     }),