@peng_kai/kit 0.1.0 → 0.1.2

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.
@@ -1,13 +1,15 @@
1
1
  import type { AxiosInterceptorManager } from 'axios';
2
2
 
3
- export function toLogin(path = '/auth/login', code = 15001): Parameters<AxiosInterceptorManager<any>['use']> {
3
+ export function toLogin(authPath = `${window.location.origin}/auth/login`, code = 15001): Parameters<AxiosInterceptorManager<any>['use']> {
4
4
  return [
5
5
  undefined,
6
6
  (err) => {
7
- if (err.code === code)
8
- window.location.href = path;
7
+ if (err.code !== code)
8
+ throw err;
9
9
 
10
- throw err;
10
+ const url = new URL(authPath);
11
+ url.searchParams.set('redirect', window.location.href);
12
+ window.location.href = url.toString();
11
13
  },
12
14
  ];
13
15
  }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ // root: true,
3
+ extends: ['@peng_kai/lint/vue/stylelint_v2'],
4
+ rules: {
5
+ 'custom-property-pattern': '(antd-([a-z][a-zA-Z0-9]+)*)|(([a-z][a-z0-9]*)(-[a-z0-9]+)*)',
6
+ },
7
+ };
package/utils/index.ts CHANGED
@@ -30,6 +30,11 @@ export function hasToken() {
30
30
  return document.cookie.includes('has_token=1');
31
31
  }
32
32
 
33
+ export function fixed() {
34
+
35
+ // return (12).toFixed
36
+ }
37
+
33
38
  /**
34
39
  * 字符串脱敏,省略中间字符串
35
40
  * @param str 字符串
@@ -0,0 +1,21 @@
1
+ import { ref } from 'vue';
2
+ import { createSharedComposable, useMutationObserver } from '@vueuse/core';
3
+
4
+ export { useIsDark };
5
+
6
+ function _useIsDark() {
7
+ const isDarkFn = () => document.documentElement.classList.contains('dark');
8
+ const isDark = ref(isDarkFn());
9
+
10
+ useMutationObserver(
11
+ document.documentElement,
12
+ () => {
13
+ isDark.value = isDarkFn();
14
+ },
15
+ { attributeFilter: ['class'] },
16
+ );
17
+
18
+ return isDark;
19
+ }
20
+
21
+ const useIsDark = createSharedComposable(_useIsDark);
package/vue/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { useComponentRef } from './hooks/useComponentRef';
2
2
  export { useTeleportTarget } from './hooks/useTeleportTarget';
3
3
  export { useIsMounted } from './hooks/useIsMounted';
4
+ export { useIsDark } from './hooks/useIsDark';
4
5
  export { InfiniteQuery } from './components/infinite-query';