@neatui/vue 2.9.1 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/vue",
3
- "version": "2.9.1",
3
+ "version": "2.10.0",
4
4
  "description": "basic component ui",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -75,13 +75,13 @@
75
75
  <script setup lang="ts">
76
76
  import { nextTick, reactive, ref, watch, onMounted } from 'vue';
77
77
  import LayerLoader from './LayerLoader.vue';
78
- import { useBaseStore, useWorksStore, storeToRefs } from '@/store';
78
+ import { useBasicStore, useWorksStore, storeToRefs } from '@/store';
79
79
  import { deepcopy } from '@fekit/utils';
80
80
  import scrollto from '@fekit/scrollto';
81
81
 
82
82
  // 事件定义
83
83
  const store: any = useWorksStore();
84
- const base: any = useBaseStore();
84
+ const base: any = useBasicStore();
85
85
  const { word } = base;
86
86
 
87
87
  // 类型定义
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // 数据
2
- export * from './store/myui';
2
+ export * from './store/frame';
3
+ export * from './utils/theme';
3
4
 
4
5
  // 组件
5
6
  export * from './components/basic';
@@ -1,7 +1,7 @@
1
1
  import { defineStore } from 'pinia';
2
2
 
3
3
  // 基础数据
4
- export const useMyuiStore = defineStore('myui', {
4
+ export const useFrameStore = defineStore('frame', {
5
5
  state: () => {
6
6
  return {
7
7
  full: localStorage.getItem('neatui_full') || 0,
@@ -10,7 +10,7 @@ export const useMyuiStore = defineStore('myui', {
10
10
  // 主题
11
11
  theme: localStorage.getItem('neatui_theme') || document?.documentElement?.getAttribute('theme') || 'auto',
12
12
  // 侧边
13
- side: 1
13
+ side: 1,
14
14
  };
15
15
  },
16
16
  getters: {},
@@ -45,6 +45,6 @@ export const useMyuiStore = defineStore('myui', {
45
45
  document.documentElement.setAttribute('size', this.size);
46
46
  then(this.size);
47
47
  }
48
- }
49
- }
48
+ },
49
+ },
50
50
  });
@@ -0,0 +1,14 @@
1
+ // 主题
2
+ export const theme = (then = (_theme: any) => {}) => {
3
+ // 自动设置主题
4
+ const auto = (scheme: any) => {
5
+ const _theme = window.localStorage.getItem('theme') || (scheme.matches ? 'dark' : 'light');
6
+ document.documentElement.setAttribute('theme', _theme);
7
+ then(_theme);
8
+ };
9
+ // 监听系统主题
10
+ const scheme: any = window.matchMedia('(prefers-color-scheme: dark)');
11
+ auto(scheme);
12
+ // 监控主题事件
13
+ scheme.addListener(auto);
14
+ };