Skip to content

Commit da04913

Browse files
committed
feat: added settingButtonPosition configuration close #275
1 parent 7d9b521 commit da04913

File tree

25 files changed

+168
-68
lines changed

25 files changed

+168
-68
lines changed

CHANGELOG.zh_CN.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Wip
2+
3+
### ✨ Features
4+
5+
- 新增 `settingButtonPosition`配置项,用于配置`设置`按钮位置
6+
17
## 2.0.0 (2021-02-18)
28

39
## (破坏性更新) Breaking changes

build/vite/plugin/compress.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Used to package and output gzip. Note that this does not work properly in Vite, the specific reason is still being investigated
3+
* https://github.com/anncwb/vite-plugin-compression
34
*/
45
import type { Plugin } from 'vite';
56

build/vite/plugin/imagemin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Image resource files used to compress the output of the production environment
2+
// https://github.com/anncwb/vite-plugin-imagemin
23

34
import viteImagemin from 'vite-plugin-imagemin';
45

build/vite/plugin/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import vue from '@vitejs/plugin-vue';
44
import vueJsx from '@vitejs/plugin-vue-jsx';
55
import legacy from '@vitejs/plugin-legacy';
66

7-
import windiCSS from 'vite-plugin-windicss';
87
import PurgeIcons from 'vite-plugin-purge-icons';
98

109
import { ViteEnv } from '../../utils';
@@ -16,6 +15,7 @@ import { configStyleImportPlugin } from './styleImport';
1615
import { configVisualizerConfig } from './visualizer';
1716
import { configThemePlugin } from './theme';
1817
import { configImageminPlugin } from './imagemin';
18+
import { configWindiCssPlugin } from './windicss';
1919

2020
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
2121
const { VITE_USE_IMAGEMIN, VITE_USE_MOCK, VITE_LEGACY, VITE_BUILD_COMPRESS } = viteEnv;
@@ -25,7 +25,6 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
2525
vue(),
2626
// have to
2727
vueJsx(),
28-
...windiCSS(),
2928
];
3029

3130
// @vitejs/plugin-legacy
@@ -34,6 +33,9 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
3433
// vite-plugin-html
3534
vitePlugins.push(configHtmlPlugin(viteEnv, isBuild));
3635

36+
// vite-plugin-windicss
37+
vitePlugins.push(configWindiCssPlugin());
38+
3739
// vite-plugin-mock
3840
VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild));
3941

build/vite/plugin/windicss.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import windiCSS from 'vite-plugin-windicss';
2+
3+
import type { Plugin } from 'vite';
4+
5+
export function configWindiCssPlugin(): Plugin[] {
6+
return windiCSS({
7+
safelist: 'shadow shadow-xl',
8+
preflight: {
9+
enableAll: true,
10+
},
11+
});
12+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"vite-plugin-pwa": "^0.4.7",
108108
"vite-plugin-style-import": "^0.7.2",
109109
"vite-plugin-theme": "^0.4.3",
110-
"vite-plugin-windicss": "0.2.2",
110+
"vite-plugin-windicss": "0.3.3",
111111
"vue-eslint-parser": "^7.5.0",
112112
"yargs": "^16.2.0"
113113
},

src/enums/appEnum.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export enum ThemeEnum {
2222
LIGHT = 'light',
2323
}
2424

25+
export enum SettingButtonPositionEnum {
26+
AUTO = 'auto',
27+
HEADER = 'header',
28+
FIXED = 'fixed',
29+
}
30+
2531
/**
2632
* 权限模式
2733
*/

src/hooks/event/useKeyPress.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,5 @@ export function getTargetElement(
160160
if (!target) {
161161
return defaultElement;
162162
}
163-
164-
let targetElement: TargetElement | undefined | null;
165-
166-
if (isFunction(target)) {
167-
targetElement = target();
168-
} else {
169-
targetElement = unref(target);
170-
}
171-
return targetElement;
163+
return isFunction(target) ? target() : unref(target);
172164
}

src/hooks/setting/useRootSetting.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const getPageLoading = computed(() => appStore.getPageLoading);
1616

1717
const getOpenKeepAlive = computed(() => unref(getRootSetting).openKeepAlive);
1818

19+
const getSettingButtonPosition = computed(() => unref(getRootSetting).settingButtonPosition);
20+
1921
const getCanEmbedIFramePage = computed(() => unref(getRootSetting).canEmbedIFramePage);
2022

2123
const getPermissionMode = computed(() => unref(getRootSetting).permissionMode);
@@ -58,6 +60,7 @@ export function useRootSetting() {
5860
return {
5961
setRootSetting,
6062

63+
getSettingButtonPosition,
6164
getFullContent,
6265
getColorWeak,
6366
getGrayMode,

src/hooks/web/useFullScreen.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ export function useFullscreen(
5757

5858
async function toggleFullscreen(): Promise<void> {
5959
if (!unref(target)) return;
60-
61-
if (isFullscreen()) {
62-
return exitFullscreen();
63-
} else {
64-
return enterFullscreen();
65-
}
60+
return isFullscreen() ? exitFullscreen() : enterFullscreen();
6661
}
6762

6863
return {

0 commit comments

Comments
 (0)