From d4ad3573df5f16cc0144ff20de8257f7e5bc3e44 Mon Sep 17 00:00:00 2001
From: chuan_wuhao <443547225@qq.com>
Date: Tue, 3 Jan 2023 13:02:22 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=B0=8F=E7=BB=86=E8=8A=82?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
cfg.ts | 26 ++-------------
src/layout/components/Menu/index.scss | 2 +-
src/layout/components/Menu/index.tsx | 5 +--
src/layout/index.tsx | 2 +-
src/types/cfg.ts | 47 +++++++++++++++++++++++++++
src/types/index.d.ts | 23 ++-----------
tsconfig.node.json | 3 +-
vite-plugin/index.ts | 2 +-
8 files changed, 59 insertions(+), 51 deletions(-)
create mode 100644 src/types/cfg.ts
diff --git a/cfg.ts b/cfg.ts
index 18932305..deb67638 100644
--- a/cfg.ts
+++ b/cfg.ts
@@ -2,31 +2,9 @@ import path from 'node:path'
import { HTMLTitlePlugin, buildOptions } from './vite-plugin/index'
-import type { ServerOptions, BuildOptions, AliasOptions } from 'vite'
-import type { VNodeChild } from 'vue'
+import type { AppConfigExport } from './src/types/cfg'
-export interface HTMLTitle {
- name: string
- transformIndexHtml: (title: string) => string
-}
-
-export interface SideBarLogo {
- icon?: string
- title?: string
- url?: string
- jumpType?: 'station' | 'outsideStation'
-}
-
-export interface Config {
- server: ServerOptions
- buildOptions: (mode: string) => BuildOptions
- alias: AliasOptions
- title: HTMLTitle
- copyright?: string | number | VNodeChild
- sideBarLogo: SideBarLogo
-}
-
-const config: Config = {
+const config: AppConfigExport = {
/**
*
* icon: LOGO 图标, 依赖 `RayIcon` 实现
diff --git a/src/layout/components/Menu/index.scss b/src/layout/components/Menu/index.scss
index 8a4842e2..8293462a 100644
--- a/src/layout/components/Menu/index.scss
+++ b/src/layout/components/Menu/index.scss
@@ -17,7 +17,7 @@
opacity: 0;
display: none;
flex: 1;
- white-space: nowrap;
+ @include overflowEllipsis;
&.ray-menu__logo-title--open {
opacity: 1;
diff --git a/src/layout/components/Menu/index.tsx b/src/layout/components/Menu/index.tsx
index f4ee8526..1a375582 100644
--- a/src/layout/components/Menu/index.tsx
+++ b/src/layout/components/Menu/index.tsx
@@ -1,6 +1,6 @@
import './index.scss'
-import { NMenu, NLayoutSider } from 'naive-ui'
+import { NMenu, NLayoutSider, NEllipsis } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index'
import { useMenu } from '@/store'
@@ -53,6 +53,7 @@ const LayoutMenu = defineComponent({
collapseMode="width"
collapsedWidth={this.collapsedWidth}
onUpdateCollapsed={this.collapsedMenu.bind(this)}
+ nativeScrollbar={false}
>
{this.sideBarLogo ? (
- {this.sideBarLogo.title}
+ {this.sideBarLogo.title}
) : (
diff --git a/src/layout/index.tsx b/src/layout/index.tsx
index bd9696fa..b44d2c57 100644
--- a/src/layout/index.tsx
+++ b/src/layout/index.tsx
@@ -20,7 +20,7 @@ const Layout = defineComponent({
if (menuStore.menuTagSwitch) {
cssVar = {
- '--layout-content-height': 'calc(100% - 109px)',
+ '--layout-content-height': 'calc(100% - 110px)',
}
} else {
cssVar = {
diff --git a/src/types/cfg.ts b/src/types/cfg.ts
new file mode 100644
index 00000000..214c74c2
--- /dev/null
+++ b/src/types/cfg.ts
@@ -0,0 +1,47 @@
+import type { VNodeChild } from 'vue'
+import type {
+ ServerOptions,
+ BuildOptions,
+ AliasOptions,
+ UserConfigExport,
+} from 'vite'
+
+export interface LayoutSideBarLogo {
+ icon?: string
+ title?: string
+ url?: string
+ jumpType?: 'station' | 'outsideStation'
+}
+
+export type LayoutCopyright = string | number | VNodeChild
+
+export interface HTMLTitle {
+ name: string
+ transformIndexHtml: (title: string) => string
+}
+
+export interface Config {
+ server: ServerOptions
+ buildOptions: (mode: string) => BuildOptions
+ alias: AliasOptions
+ title: HTMLTitle
+ copyright?: LayoutCopyright
+ sideBarLogo?: LayoutSideBarLogo
+}
+
+export type Recordable = Record
+
+export interface AppConfig {
+ pkg: {
+ name: string
+ version: string
+ dependencies: Recordable
+ devDependencies: Recordable
+ }
+ layout: {
+ copyright?: LayoutCopyright
+ sideBarLogo?: LayoutSideBarLogo
+ }
+}
+
+export type AppConfigExport = Config & UserConfigExport
diff --git a/src/types/index.d.ts b/src/types/index.d.ts
index 76f4415b..226ac943 100644
--- a/src/types/index.d.ts
+++ b/src/types/index.d.ts
@@ -12,29 +12,10 @@ import type {
} from 'naive-ui'
import type { ECharts } from 'echarts/core'
import type { VNodeChild } from 'vue'
+import type { LayoutSideBarLogo, LayoutCopyright, AppConfig } from './cfg'
export global {
- declare type Recordable = Record
-
- export declare interface SideBarLogo {
- icon?: string
- title?: string
- url?: string
- jumpType?: 'station' | 'outsideStation'
- }
-
- declare const __APP_CFG__: {
- pkg: {
- name: string
- version: string
- dependencies: Recordable
- devDependencies: Recordable
- }
- layout: {
- copyright?: string | number | VNodeChild
- sideBarLogo?: SideBarLogo
- }
- }
+ declare const __APP_CFG__: AppConfig
declare type NaiveMenuOptions =
| MenuOption
diff --git a/tsconfig.node.json b/tsconfig.node.json
index 0e16d425..40886960 100644
--- a/tsconfig.node.json
+++ b/tsconfig.node.json
@@ -9,6 +9,7 @@
"vite.config.ts",
"vite-plugin/index.ts",
"vite-plugin/type.ts",
- "cfg.ts"
+ "cfg.ts",
+ "src/types/cfg.ts"
]
}
diff --git a/vite-plugin/index.ts b/vite-plugin/index.ts
index 3642c64a..90876cc3 100644
--- a/vite-plugin/index.ts
+++ b/vite-plugin/index.ts
@@ -9,7 +9,7 @@ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' // `svg icon`
import type { ComponentResolver, TypeImport } from 'unplugin-vue-components'
import type { VitePluginCompression } from './type'
import type { ImportsMap, PresetName } from 'unplugin-auto-import/types'
-import type { ServerOptions, BuildOptions } from 'vite'
+import type { BuildOptions } from 'vite'
import type { ViteSvgIconsPlugin } from 'vite-plugin-svg-icons'
/**