@peng_kai/kit 0.2.0-beta.3 → 0.2.0-beta.30
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/admin/adminPlugin.ts +11 -1
- package/admin/components/filter/src/FilterDrawer.vue +153 -153
- package/admin/components/filter/src/FilterParam.vue +1 -1
- package/admin/components/filter/src/FilterReset.vue +12 -9
- package/admin/components/rich-text/index.ts +1 -1
- package/admin/components/rich-text/src/RichText.new.vue +164 -0
- package/admin/components/rich-text/src/RichText.vue +3 -6
- package/admin/components/rich-text/src/editorConfig.ts +126 -0
- package/admin/components/rich-text/src/imageUploader.ts +20 -18
- package/admin/components/scroll-nav/index.ts +1 -1
- package/admin/components/scroll-nav/src/ScrollNav.vue +1 -1
- package/admin/components/settings/index.ts +1 -0
- package/admin/components/settings/src/Settings.vue +333 -0
- package/admin/components/text/index.ts +13 -13
- package/admin/components/text/src/Amount.vue +121 -121
- package/admin/components/text/src/Datetime.vue +1 -1
- package/admin/components/text/src/Duration.vue +26 -26
- package/admin/components/text/src/Hash.vue +51 -51
- package/admin/components/text/src/createTagGetter.ts +13 -13
- package/admin/components/upload/index.ts +1 -0
- package/admin/components/upload/src/PictureCardUpload.vue +1 -1
- package/admin/components/upload/src/helpers.ts +37 -0
- package/admin/defines/route/defineRoute.ts +2 -4
- package/admin/defines/route/getRoutes.ts +4 -4
- package/admin/defines/route/index.ts +1 -1
- package/admin/defines/route-guard/defineRouteGuard.ts +1 -4
- package/admin/defines/route-guard/getRouteGuards.ts +5 -7
- package/admin/defines/startup/defineStartup.ts +1 -3
- package/admin/defines/startup/runStartup.ts +4 -6
- package/admin/layout/large/Breadcrumb.vue +2 -2
- package/admin/layout/large/Content.vue +2 -2
- package/admin/layout/large/Menu.vue +2 -2
- package/admin/layout/large/PageTab.vue +2 -2
- package/admin/permission/routerGuard.ts +1 -1
- package/admin/permission/vuePlugin.ts +1 -0
- package/admin/route-guards/index.ts +3 -3
- package/admin/route-guards/pageProgress.ts +27 -27
- package/admin/stores/createUsePageStore.ts +1 -3
- package/admin/styles/classCover.scss +107 -0
- package/admin/styles/globalCover.scss +54 -54
- package/admin/styles/index.scss +14 -12
- package/antd/components/InputNumberRange.vue +59 -59
- package/antd/directives/formLabelAlign.ts +36 -36
- package/antd/hooks/useAntdDrawer.ts +73 -73
- package/antd/hooks/useAntdForm.ts +1 -1
- package/antd/hooks/useAntdModal.ts +4 -1
- package/antd/hooks/useAntdTable.ts +2 -1
- package/libs/dayjs.ts +7 -0
- package/libs/echarts.ts +1 -1
- package/libs/vue-i18n.ts +21 -0
- package/package.json +36 -35
- package/request/helpers.ts +68 -68
- package/request/interceptors/returnResultType.ts +3 -3
- package/request/interceptors/toLogin.ts +43 -26
- package/request/request.ts +0 -3
- package/request/type.d.ts +92 -92
- package/stylelint.config.cjs +7 -7
- package/tsconfig.json +50 -50
- package/utils/LocaleManager.ts +125 -0
- package/utils/date.ts +1 -9
- package/vite/index.mjs +34 -8
- package/vue/components/infinite-query/index.ts +1 -1
- package/vue/components/infinite-query/src/InfiniteQuery.vue +199 -199
- package/vue/components/infinite-query/src/useCreateTrigger.ts +39 -39
package/request/type.d.ts
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
declare namespace Api {
|
|
2
|
-
type Request = ((reqData: any, options?: Options) => Promise<any>) & {
|
|
3
|
-
id: string
|
|
4
|
-
setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
|
|
5
|
-
};
|
|
6
|
-
// type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
|
|
7
|
-
interface PageParam {
|
|
8
|
-
page: number
|
|
9
|
-
page_size: number
|
|
10
|
-
}
|
|
11
|
-
interface PageInfo {
|
|
12
|
-
has_more: boolean
|
|
13
|
-
page: number
|
|
14
|
-
page_size: number
|
|
15
|
-
total: number
|
|
16
|
-
}
|
|
17
|
-
interface PageData<T = any> {
|
|
18
|
-
list: T[] | null
|
|
19
|
-
pagination: PaginationInfo
|
|
20
|
-
[k in string]: any
|
|
21
|
-
}
|
|
22
|
-
interface Result<T = any | PageData<any>> {
|
|
23
|
-
code: number
|
|
24
|
-
msg: string
|
|
25
|
-
data: T
|
|
26
|
-
}
|
|
27
|
-
type GetParam<A extends Request> = A extends (reqData: infer R) => any ? R : any;
|
|
28
|
-
type GetData<A extends Request> = ReturnType<A> extends Promise<infer D> ? D : any;
|
|
29
|
-
type GetDataItem<A extends Request> = NonNullable<GetData<A>> extends { list: infer L }
|
|
30
|
-
? NonNullable<L> extends Array<infer I>
|
|
31
|
-
? I
|
|
32
|
-
: any
|
|
33
|
-
: any;
|
|
34
|
-
type GetDataField<R> = R extends { data: infer D } ? (D extends { list: any, pagination: any } ? D : D) : any;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 将api返回的分页数据转换成前端使用的分页数据格式,将分页数据格式统一
|
|
38
|
-
*
|
|
39
|
-
* ```
|
|
40
|
-
* {
|
|
41
|
-
* code: number,
|
|
42
|
-
* msg: string,
|
|
43
|
-
* data: {
|
|
44
|
-
* list: [],
|
|
45
|
-
* pagination: {},
|
|
46
|
-
* ...
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
type TransformPageResult<R> = R extends { pagination: infer P, data: infer D }
|
|
52
|
-
? D extends Record<string, any>
|
|
53
|
-
? D extends { list: any }
|
|
54
|
-
|
|
55
|
-
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
56
|
-
} & {
|
|
57
|
-
data: D & { pagination: P }
|
|
58
|
-
}
|
|
59
|
-
: {
|
|
60
|
-
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
61
|
-
} & {
|
|
62
|
-
data: {
|
|
63
|
-
list: D
|
|
64
|
-
pagination: P
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
: R
|
|
68
|
-
: R;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 测试用例 ----------------------------
|
|
72
|
-
// type DDD1 = Api.TransformPageResult<{
|
|
73
|
-
// code: number
|
|
74
|
-
// msg: string
|
|
75
|
-
// data: {
|
|
76
|
-
// name: string
|
|
77
|
-
// }[]
|
|
78
|
-
// pagination: {
|
|
79
|
-
// page: number
|
|
80
|
-
// }
|
|
81
|
-
// }>
|
|
82
|
-
// type DDD2 = Api.TransformPageResult<{
|
|
83
|
-
// code: number
|
|
84
|
-
// msg: string
|
|
85
|
-
// data: {
|
|
86
|
-
// list: { name: string }[]
|
|
87
|
-
// total: {}
|
|
88
|
-
// }
|
|
89
|
-
// pagination: {
|
|
90
|
-
// page: number
|
|
91
|
-
// }
|
|
92
|
-
// }>
|
|
1
|
+
declare namespace Api {
|
|
2
|
+
type Request = ((reqData: any, options?: Options) => Promise<any>) & {
|
|
3
|
+
id: string
|
|
4
|
+
setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
|
|
5
|
+
};
|
|
6
|
+
// type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
|
|
7
|
+
interface PageParam {
|
|
8
|
+
page: number
|
|
9
|
+
page_size: number
|
|
10
|
+
}
|
|
11
|
+
interface PageInfo {
|
|
12
|
+
has_more: boolean
|
|
13
|
+
page: number
|
|
14
|
+
page_size: number
|
|
15
|
+
total: number
|
|
16
|
+
}
|
|
17
|
+
interface PageData<T = any> {
|
|
18
|
+
list: T[] | null
|
|
19
|
+
pagination: PaginationInfo
|
|
20
|
+
[k in string]: any
|
|
21
|
+
}
|
|
22
|
+
interface Result<T = any | PageData<any>> {
|
|
23
|
+
code: number
|
|
24
|
+
msg: string
|
|
25
|
+
data: T
|
|
26
|
+
}
|
|
27
|
+
type GetParam<A extends Request> = A extends (reqData: infer R) => any ? R : any;
|
|
28
|
+
type GetData<A extends Request> = ReturnType<A> extends Promise<infer D> ? D : any;
|
|
29
|
+
type GetDataItem<A extends Request> = NonNullable<GetData<A>> extends { list: infer L }
|
|
30
|
+
? NonNullable<L> extends Array<infer I>
|
|
31
|
+
? I
|
|
32
|
+
: any
|
|
33
|
+
: any;
|
|
34
|
+
type GetDataField<R> = R extends { data: infer D } ? (D extends { list: any, pagination: any } ? D : D) : any;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 将api返回的分页数据转换成前端使用的分页数据格式,将分页数据格式统一
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* {
|
|
41
|
+
* code: number,
|
|
42
|
+
* msg: string,
|
|
43
|
+
* data: {
|
|
44
|
+
* list: [],
|
|
45
|
+
* pagination: {},
|
|
46
|
+
* ...
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
type TransformPageResult<R> = R extends { pagination: infer P, data: infer D }
|
|
52
|
+
? D extends Record<string, any>
|
|
53
|
+
? D extends { list: any }
|
|
54
|
+
? import('type-fest').Simplify<{
|
|
55
|
+
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
56
|
+
} & {
|
|
57
|
+
data: D & { pagination: P }
|
|
58
|
+
}>
|
|
59
|
+
: import('type-fest').Simplify<{
|
|
60
|
+
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
61
|
+
} & {
|
|
62
|
+
data: {
|
|
63
|
+
list: D
|
|
64
|
+
pagination: P
|
|
65
|
+
}
|
|
66
|
+
}>
|
|
67
|
+
: R
|
|
68
|
+
: R;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 测试用例 ----------------------------
|
|
72
|
+
// type DDD1 = Api.TransformPageResult<{
|
|
73
|
+
// code: number
|
|
74
|
+
// msg: string
|
|
75
|
+
// data: {
|
|
76
|
+
// name: string
|
|
77
|
+
// }[]
|
|
78
|
+
// pagination: {
|
|
79
|
+
// page: number
|
|
80
|
+
// }
|
|
81
|
+
// }>
|
|
82
|
+
// type DDD2 = Api.TransformPageResult<{
|
|
83
|
+
// code: number
|
|
84
|
+
// msg: string
|
|
85
|
+
// data: {
|
|
86
|
+
// list: { name: string }[]
|
|
87
|
+
// total: {}
|
|
88
|
+
// }
|
|
89
|
+
// pagination: {
|
|
90
|
+
// page: number
|
|
91
|
+
// }
|
|
92
|
+
// }>
|
package/stylelint.config.cjs
CHANGED
|
@@ -1,7 +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
|
-
};
|
|
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/tsconfig.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"jsx": "preserve",
|
|
5
|
-
"jsxFactory": "h",
|
|
6
|
-
"jsxFragmentFactory": "Fragment",
|
|
7
|
-
"lib": [
|
|
8
|
-
"ESNext",
|
|
9
|
-
"DOM",
|
|
10
|
-
"DOM.Iterable"
|
|
11
|
-
],
|
|
12
|
-
"useDefineForClassFields": true,
|
|
13
|
-
"module": "ESNext",
|
|
14
|
-
|
|
15
|
-
/* Bundler mode */
|
|
16
|
-
"moduleResolution": "bundler",
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"allowImportingTsExtensions": true,
|
|
19
|
-
|
|
20
|
-
/* Linting */
|
|
21
|
-
"strict": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noImplicitAny": false,
|
|
24
|
-
"noUnusedLocals": true,
|
|
25
|
-
"noUnusedParameters": true,
|
|
26
|
-
"noEmit": true,
|
|
27
|
-
"allowSyntheticDefaultImports": true,
|
|
28
|
-
"esModuleInterop": true,
|
|
29
|
-
"isolatedModules": true,
|
|
30
|
-
"skipLibCheck": true
|
|
31
|
-
},
|
|
32
|
-
"include": [
|
|
33
|
-
"admin/**/*.ts",
|
|
34
|
-
"admin/**/*.d.ts",
|
|
35
|
-
"admin/**/*.tsx",
|
|
36
|
-
"admin/**/*.vue",
|
|
37
|
-
"antd/**/*.ts",
|
|
38
|
-
"antd/**/*.d.ts",
|
|
39
|
-
"antd/**/*.tsx",
|
|
40
|
-
"antd/**/*.vue",
|
|
41
|
-
"request/**/*.ts",
|
|
42
|
-
"request/**/*.d.ts",
|
|
43
|
-
"utils/**/*.ts",
|
|
44
|
-
"utils/**/*.d.ts",
|
|
45
|
-
"vue/**/*.ts",
|
|
46
|
-
"vue/**/*.d.ts",
|
|
47
|
-
"vue/**/*.tsx",
|
|
48
|
-
"vue/**/*.vue"
|
|
49
|
-
]
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"jsxFactory": "h",
|
|
6
|
+
"jsxFragmentFactory": "Fragment",
|
|
7
|
+
"lib": [
|
|
8
|
+
"ESNext",
|
|
9
|
+
"DOM",
|
|
10
|
+
"DOM.Iterable"
|
|
11
|
+
],
|
|
12
|
+
"useDefineForClassFields": true,
|
|
13
|
+
"module": "ESNext",
|
|
14
|
+
|
|
15
|
+
/* Bundler mode */
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
|
|
20
|
+
/* Linting */
|
|
21
|
+
"strict": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noImplicitAny": false,
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"noUnusedParameters": true,
|
|
26
|
+
"noEmit": true,
|
|
27
|
+
"allowSyntheticDefaultImports": true,
|
|
28
|
+
"esModuleInterop": true,
|
|
29
|
+
"isolatedModules": true,
|
|
30
|
+
"skipLibCheck": true
|
|
31
|
+
},
|
|
32
|
+
"include": [
|
|
33
|
+
"admin/**/*.ts",
|
|
34
|
+
"admin/**/*.d.ts",
|
|
35
|
+
"admin/**/*.tsx",
|
|
36
|
+
"admin/**/*.vue",
|
|
37
|
+
"antd/**/*.ts",
|
|
38
|
+
"antd/**/*.d.ts",
|
|
39
|
+
"antd/**/*.tsx",
|
|
40
|
+
"antd/**/*.vue",
|
|
41
|
+
"request/**/*.ts",
|
|
42
|
+
"request/**/*.d.ts",
|
|
43
|
+
"utils/**/*.ts",
|
|
44
|
+
"utils/**/*.d.ts",
|
|
45
|
+
"vue/**/*.ts",
|
|
46
|
+
"vue/**/*.d.ts",
|
|
47
|
+
"vue/**/*.tsx",
|
|
48
|
+
"vue/**/*.vue"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { mapKeys } from 'lodash-es';
|
|
2
|
+
|
|
3
|
+
interface ILocaleMeta {
|
|
4
|
+
label: string
|
|
5
|
+
codes: string[]
|
|
6
|
+
icon?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ILoaders {
|
|
10
|
+
meta: Record<string, ILocaleMeta>
|
|
11
|
+
message: Record<string, () => Promise<Record<string, string>>>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const metaPathRE = /\/([-\w]*)\/(meta)\.ts$/;
|
|
15
|
+
const messagePathRE = /\/([-\w]*)\/(index)\.ts$/;
|
|
16
|
+
|
|
17
|
+
export class LocaleManager {
|
|
18
|
+
public localesLoaded: string[] = [];
|
|
19
|
+
|
|
20
|
+
private metaLoaders: ILoaders['meta'];
|
|
21
|
+
private messageLoaders: ILoaders['message'];
|
|
22
|
+
private localeStorageKey = 'LOCALE';
|
|
23
|
+
private _locale = '';
|
|
24
|
+
|
|
25
|
+
public constructor(loaders: ILoaders) {
|
|
26
|
+
this.metaLoaders = mapKeys(loaders.meta, (_, path) => path.match(metaPathRE)?.[1] ?? path);
|
|
27
|
+
this.messageLoaders = mapKeys(loaders.message, (_, path) => path.match(messagePathRE)?.[1] ?? path);
|
|
28
|
+
this._locale = this.defaultLocale;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 当前区域 */
|
|
32
|
+
public get locale() {
|
|
33
|
+
return this._locale;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** 当前区域 */
|
|
37
|
+
public set locale(value: string) {
|
|
38
|
+
if (this.localesAvailable.includes(value)) {
|
|
39
|
+
document.documentElement.lang = value;
|
|
40
|
+
this.setStorageLocale(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 可用的区域列表 */
|
|
45
|
+
public get localesAvailable() {
|
|
46
|
+
return Object.keys(this.metaLoaders);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 所有区域元数据 */
|
|
50
|
+
public get localeMetas() {
|
|
51
|
+
return this.metaLoaders;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 获取默认区域 */
|
|
55
|
+
public get defaultLocale() {
|
|
56
|
+
const searchParams = new URLSearchParams(location.search);
|
|
57
|
+
// 获取区域的优先级
|
|
58
|
+
const localeTargets = [searchParams.get('locale'), searchParams.get('lang'), this.getStorageLocale(), navigator.language]
|
|
59
|
+
.filter(locale => !!locale)
|
|
60
|
+
.map(locale => locale!.replace('_', '-'));
|
|
61
|
+
const codeMatrix = this.localesAvailable.map(locale => [locale, ...this.localeMetas[locale].codes]);
|
|
62
|
+
let localeFinal = '';
|
|
63
|
+
|
|
64
|
+
for (const target of localeTargets) {
|
|
65
|
+
for (const codes of codeMatrix) {
|
|
66
|
+
const matched = codes.some(code => code.toUpperCase().startsWith(target.toUpperCase()));
|
|
67
|
+
|
|
68
|
+
if (matched) {
|
|
69
|
+
localeFinal = codes[0];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (localeFinal)
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
localeFinal = localeFinal || 'en-US';
|
|
79
|
+
this.clearUrlLocale();
|
|
80
|
+
|
|
81
|
+
return localeFinal;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 加载区域消息
|
|
86
|
+
* @param locale 区域
|
|
87
|
+
* @returns 返回加载的消息,如果加载失败则返回 undefined
|
|
88
|
+
*/
|
|
89
|
+
public async loadLocaleMessage(locale: string) {
|
|
90
|
+
if (!this.localesAvailable.includes(locale))
|
|
91
|
+
return;
|
|
92
|
+
|
|
93
|
+
const message = await this.messageLoaders[locale]?.().catch(() => undefined);
|
|
94
|
+
|
|
95
|
+
if (message)
|
|
96
|
+
this.localesLoaded.push(locale);
|
|
97
|
+
|
|
98
|
+
return message;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 定义区域元数据
|
|
103
|
+
* @param meta 区域元数据对象
|
|
104
|
+
* @returns 区域元数据对象
|
|
105
|
+
*/
|
|
106
|
+
public static defineMeta(meta: ILocaleMeta) {
|
|
107
|
+
return meta;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private clearUrlLocale() {
|
|
111
|
+
const url = new URL(location.href);
|
|
112
|
+
url.searchParams.delete('locale');
|
|
113
|
+
url.searchParams.delete('lang');
|
|
114
|
+
|
|
115
|
+
history.replaceState(null, '', url.toString());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private getStorageLocale() {
|
|
119
|
+
return localStorage.getItem(this.localeStorageKey);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private setStorageLocale(locale: string) {
|
|
123
|
+
return localStorage.setItem(this.localeStorageKey, locale);
|
|
124
|
+
}
|
|
125
|
+
}
|
package/utils/date.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { default as relativeTime } from 'dayjs/plugin/relativeTime';
|
|
3
|
-
import 'dayjs/locale/zh';
|
|
4
|
-
import 'dayjs/locale/en';
|
|
5
|
-
|
|
6
|
-
export { default as dayjs } from 'dayjs';
|
|
7
|
-
|
|
8
|
-
dayjs.locale('zh');
|
|
9
|
-
dayjs.extend(relativeTime);
|
|
1
|
+
import dayjs from '../libs/dayjs';
|
|
10
2
|
|
|
11
3
|
/**
|
|
12
4
|
* 返回给定日期的一天的开始时间。
|
package/vite/index.mjs
CHANGED
|
@@ -3,22 +3,48 @@
|
|
|
3
3
|
* @param env 环境变量对象
|
|
4
4
|
* @returns 代理配置对象
|
|
5
5
|
*/
|
|
6
|
+
// export function getProxy(env) {
|
|
7
|
+
// const keyRE = /^VITE_(HTTP|WS)_PREFIX/;
|
|
8
|
+
// const valueRE = /^.+? => .+?$/;
|
|
9
|
+
// const proxys = {};
|
|
10
|
+
|
|
11
|
+
// for (const [k, v] of Object.entries(env)) {
|
|
12
|
+
// if (!(keyRE.test(k) && valueRE.test(v)))
|
|
13
|
+
// continue;
|
|
14
|
+
|
|
15
|
+
// const isWs = k.includes('_WS');
|
|
16
|
+
// const [prefix, target] = v.split(' => ').map(i => i.trim());
|
|
17
|
+
|
|
18
|
+
// proxys[prefix] = {
|
|
19
|
+
// target,
|
|
20
|
+
// changeOrigin: true,
|
|
21
|
+
// ws: isWs,
|
|
22
|
+
// rewrite: path => path.replace(new RegExp(`^${prefix}`), ''),
|
|
23
|
+
// };
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
// return proxys;
|
|
27
|
+
// }
|
|
28
|
+
|
|
6
29
|
export function getProxy(env) {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
30
|
+
const prefixKeyRE = /^VITE_URL_PREFIX_(.*)$/;
|
|
31
|
+
const socketUrlRE = /^wss?:\/\//;
|
|
32
|
+
const keys = Object.keys(env).filter(k => prefixKeyRE.test(k));
|
|
9
33
|
const proxys = {};
|
|
10
34
|
|
|
11
|
-
for (const
|
|
12
|
-
|
|
13
|
-
|
|
35
|
+
for (const k of keys) {
|
|
36
|
+
const name = k.match(prefixKeyRE)?.[1] ?? '';
|
|
37
|
+
const prefix = env[`VITE_URL_PREFIX_${name}`];
|
|
38
|
+
const target = env[`VITE_URL_PROXY_${name}`];
|
|
39
|
+
const proxyable = prefix && target;
|
|
14
40
|
|
|
15
|
-
|
|
16
|
-
|
|
41
|
+
if (!proxyable)
|
|
42
|
+
continue;
|
|
17
43
|
|
|
18
44
|
proxys[prefix] = {
|
|
19
45
|
target,
|
|
20
46
|
changeOrigin: true,
|
|
21
|
-
ws:
|
|
47
|
+
ws: socketUrlRE.test(target),
|
|
22
48
|
rewrite: path => path.replace(new RegExp(`^${prefix}`), ''),
|
|
23
49
|
};
|
|
24
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
|
|
1
|
+
export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
|