打包分析工具命令修正

This commit is contained in:
chuan_wuhao 2022-12-29 16:31:59 +08:00
parent 2a0da111ec
commit adad70c811
5 changed files with 128 additions and 58 deletions

View File

@ -9,7 +9,7 @@
"preview": "vite preview", "preview": "vite preview",
"test": "vue-tsc --noEmit && vite build --mode test", "test": "vue-tsc --noEmit && vite build --mode test",
"dev-build": "vue-tsc --noEmit && vite build --mode development", "dev-build": "vue-tsc --noEmit && vite build --mode development",
"report": "vue-tsc --noEmit && vite build" "report": "vue-tsc --noEmit && vite build --mode report"
}, },
"dependencies": { "dependencies": {
"@vueuse/core": "^9.1.0", "@vueuse/core": "^9.1.0",

View File

@ -0,0 +1,5 @@
.ray-tooltip-text__icon {
cursor: pointer;
outline: none;
border: none;
}

View File

@ -0,0 +1,65 @@
/**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2022-12-29
*
* @workspace ray-template
*
* @remark
*/
import './index.scss'
import { NTooltip } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index'
import { tooltipProps } from 'naive-ui'
const RayTooltipIcon = defineComponent({
name: 'RayTooltipIcon',
props: {
...tooltipProps,
iconName: {
type: String,
required: true,
},
customClassName: {
type: String,
default: '',
},
tooltipText: {
type: String,
default: '',
},
},
emits: ['click'],
setup(_, { emit }) {
const handleClick = (e?: MouseEvent) => {
emit('click', e)
}
return {
handleClick,
}
},
render() {
return (
<NTooltip {...this.$props}>
{{
trigger: () => (
<RayIcon
name={this.iconName}
size="18"
customClassName={`ray-tooltip-text__icon ${this.customClassName}`}
onClick={this.handleClick.bind(this)}
/>
),
default: () => this.tooltipText,
}}
</NTooltip>
)
},
})
export default RayTooltipIcon

View File

@ -1,9 +1,12 @@
import './index.scss' import './index.scss'
import { NLayoutHeader, NSpace, NTooltip, NDropdown } from 'naive-ui' import { NLayoutHeader, NSpace, NTooltip, NDropdown } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RayIcon/index'
import RayTooltipIcon from '@/components/RayTooltipIcon/index'
import SettingDrawer from './components/SettingDrawer/index'
import { useSetting } from '@/store' import { useSetting } from '@/store'
import { useLanguageOptions } from '@/language/index' import { useLanguageOptions } from '@/language/index'
import SettingDrawer from './Components/SettingDrawer/index'
import { useAvatarOptions } from './hook' import { useAvatarOptions } from './hook'
import { removeCache } from '@/utils/cache' import { removeCache } from '@/utils/cache'
import screenfull from 'screenfull' import screenfull from 'screenfull'
@ -26,6 +29,10 @@ const SiderBar = defineComponent({
const modelDrawerPlacement = ref(settingStore.drawerPlacement) const modelDrawerPlacement = ref(settingStore.drawerPlacement)
const showSettings = ref(false) const showSettings = ref(false)
/**
*
*
*/
const leftIconOptions = [ const leftIconOptions = [
{ {
name: 'reload', name: 'reload',
@ -33,24 +40,17 @@ const SiderBar = defineComponent({
tooltip: 'LayoutHeaderTooltipOptions.Reload', tooltip: 'LayoutHeaderTooltipOptions.Reload',
}, },
] ]
const rightIconOptions = [ /**
*
*
*/
const rightTooltipIconOptions = [
{ {
name: 'fullscreen', name: 'fullscreen',
size: 18, size: 18,
tooltip: '', tooltip: 'LayoutHeaderTooltipOptions.FullScreen',
eventKey: 'screen', eventKey: 'screen',
}, },
{
name: 'language',
size: 18,
tooltip: '',
dropdown: {
eventKey: 'handleSelect', // 默认为 `handleSelect`
switch: true,
options: useLanguageOptions(),
handleSelect: (key: string | number) => updateLocale(String(key)),
},
},
{ {
name: 'github', name: 'github',
size: 18, size: 18,
@ -63,9 +63,26 @@ const SiderBar = defineComponent({
tooltip: 'LayoutHeaderTooltipOptions.Setting', tooltip: 'LayoutHeaderTooltipOptions.Setting',
eventKey: 'setting', eventKey: 'setting',
}, },
]
/**
*
*
*/
const rightDropdownIconOptions = [
{
name: 'language',
size: 18,
tooltip: '',
dropdown: {
eventKey: 'handleSelect', // 默认为 `handleSelect`
switch: true,
options: useLanguageOptions(),
handleSelect: (key: string | number) => updateLocale(String(key)),
},
},
{ {
name: 'ray', name: 'ray',
size: 22, size: 18,
tooltip: '', tooltip: '',
dropdown: { dropdown: {
eventKey: 'handleSelect', // 默认为 `handleSelect` eventKey: 'handleSelect', // 默认为 `handleSelect`
@ -80,9 +97,7 @@ const SiderBar = defineComponent({
negativeText: '不确定', negativeText: '不确定',
onPositiveClick: () => { onPositiveClick: () => {
window.$message.info('账号退出中...') window.$message.info('账号退出中...')
removeCache('all-sessionStorage') removeCache('all-sessionStorage')
setTimeout(() => window.location.reload(), 2 * 1000) setTimeout(() => window.location.reload(), 2 * 1000)
}, },
}) })
@ -105,7 +120,7 @@ const SiderBar = defineComponent({
github: () => { github: () => {
window.open('https://github.com/XiaoDaiGua-Ray/ray-template') window.open('https://github.com/XiaoDaiGua-Ray/ray-template')
}, },
screen: () => { fullscreen: () => {
if (screenfull.isEnabled) { if (screenfull.isEnabled) {
screenfull.toggle() screenfull.toggle()
} else { } else {
@ -118,36 +133,14 @@ const SiderBar = defineComponent({
iconEventMap[key]?.() iconEventMap[key]?.()
} }
const Icon = (curr: IconOptions) => (
<RayIcon
customClassName="layout-header__method--icon"
name={curr.name}
size={curr.size}
onClick={handleIconClick.bind(this, curr.eventKey ?? '')}
/>
)
const TooltipIcon = (curr: IconOptions) =>
curr.tooltip ? (
<NTooltip>
{{
trigger: () => Icon(curr),
default: () => t(curr.tooltip ?? ''),
}}
</NTooltip>
) : (
Icon(curr)
)
return { return {
leftIconOptions, leftIconOptions,
rightIconOptions, rightTooltipIconOptions,
t, t,
handleIconClick, handleIconClick,
modelDrawerPlacement, modelDrawerPlacement,
showSettings, showSettings,
TooltipIcon, rightDropdownIconOptions,
Icon,
} }
}, },
render() { render() {
@ -176,20 +169,27 @@ const SiderBar = defineComponent({
))} ))}
</NSpace> </NSpace>
<NSpace align="center"> <NSpace align="center">
{this.rightIconOptions.map((curr) => {this.rightTooltipIconOptions.map((curr) => (
curr.dropdown?.switch ? ( <RayTooltipIcon
<NDropdown iconName={curr.name}
options={curr.dropdown.options} tooltipText={this.t(curr.tooltip)}
onSelect={ onClick={this.handleIconClick.bind(this, curr.name)}
curr.dropdown[curr.dropdown.eventKey ?? 'handleSelect'] />
} ))}
> {this.rightDropdownIconOptions.map((curr) => (
{this.Icon(curr)} <NDropdown
</NDropdown> options={curr.dropdown.options}
) : ( onSelect={
this.TooltipIcon(curr) curr.dropdown[curr.dropdown.eventKey ?? 'handleSelect']
), }
)} >
<RayIcon
customClassName="layout-header__method--icon"
name={curr.name}
size={curr.size}
/>
</NDropdown>
))}
</NSpace> </NSpace>
</NSpace> </NSpace>
<SettingDrawer <SettingDrawer

View File

@ -95,7 +95,7 @@ export default defineConfig(async ({ mode }) => {
brotliSize: true, // 搜集 `brotli` 压缩包 brotliSize: true, // 搜集 `brotli` 压缩包
emitFile: false, // 生成文件在根目录下 emitFile: false, // 生成文件在根目录下
filename: 'visualizer.html', filename: 'visualizer.html',
open: true, // 以默认服务器代理打开文件 open: mode === 'report' ? true : false, // 以默认服务器代理打开文件
}), }),
], ],
optimizeDeps: { optimizeDeps: {