@farris/cli 2.0.0-beta.7 → 2.0.0-beta.8
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/bin/index.js +2 -2
- package/lib/commands/build-components.js +21 -17
- package/lib/commands/build-components.js.map +1 -0
- package/lib/commands/build-css.js +30 -2
- package/lib/commands/build-css.js.map +1 -0
- package/lib/commands/build-lib.js +16 -6
- package/lib/commands/build-lib.js.map +1 -0
- package/lib/commands/build.js +11 -5
- package/lib/commands/build.js.map +1 -0
- package/lib/commands/create-app.js +2 -1
- package/lib/commands/create-app.js.map +1 -0
- package/lib/commands/dev-serve.js +3 -7
- package/lib/commands/dev-serve.js.map +1 -0
- package/lib/commands/preview-serve.js +1 -0
- package/lib/commands/preview-serve.js.map +1 -0
- package/lib/common/constant.js +1 -0
- package/lib/common/constant.js.map +1 -0
- package/lib/common/generate-app.js +1 -0
- package/lib/common/generate-app.js.map +1 -0
- package/lib/common/get-dependencies.js +1 -0
- package/lib/common/get-dependencies.js.map +1 -0
- package/lib/common/get-farris-config.js +3 -2
- package/lib/common/get-farris-config.js.map +1 -0
- package/lib/common/get-version.js +1 -0
- package/lib/common/get-version.js.map +1 -0
- package/lib/common/get-vite-config.js +16 -8
- package/lib/common/get-vite-config.js.map +1 -0
- package/lib/config/vite-app.js +10 -10
- package/lib/config/vite-app.js.map +1 -0
- package/lib/config/vite-common.js +21 -0
- package/lib/config/vite-common.js.map +1 -0
- package/lib/config/vite-component.js +30 -0
- package/lib/config/vite-component.js.map +1 -0
- package/lib/config/vite-lib.js +12 -20
- package/lib/config/vite-lib.js.map +1 -0
- package/lib/index.js +23 -1
- package/lib/index.js.map +1 -0
- package/lib/plugins/{gen-component-style.js → create-component-style.js} +6 -4
- package/lib/plugins/create-component-style.js.map +1 -0
- package/lib/plugins/create-package-json.js +34 -0
- package/lib/plugins/create-package-json.js.map +1 -0
- package/lib/plugins/dts.js +1 -0
- package/lib/plugins/dts.js.map +1 -0
- package/lib/plugins/html-system.js +1 -0
- package/lib/plugins/html-system.js.map +1 -0
- package/lib/plugins/replace.js +1 -0
- package/lib/plugins/replace.js.map +1 -0
- package/lib/plugins/systemjs-bundle.js +16 -0
- package/lib/plugins/systemjs-bundle.js.map +1 -0
- package/package.json +41 -38
- package/templates/lib/.eslintrc.cjs +15 -15
- package/templates/lib/.prettierrc.json +7 -7
- package/templates/lib/components/button/index.ts +7 -0
- package/templates/lib/components/button/src/button.component.tsx +84 -0
- package/templates/lib/components/button/src/button.props.ts +55 -0
- package/templates/lib/components/button/src/button.scss +179 -0
- package/templates/lib/components/common/index.ts +6 -0
- package/templates/lib/components/common/src/common.scss +4 -0
- package/templates/lib/components/common/src/compositions/index.ts +19 -0
- package/templates/lib/components/common/src/compositions/types.ts +6 -0
- package/templates/lib/components/common/src/compositions/use-bem/index.ts +46 -0
- package/templates/lib/components/common/src/compositions/use-click-away/index.ts +40 -0
- package/templates/lib/components/common/src/compositions/use-context/use-children-contexts.ts +40 -0
- package/templates/lib/components/common/src/compositions/use-context/use-parent-context.ts +24 -0
- package/templates/lib/components/common/src/compositions/use-event-listener/index.ts +45 -0
- package/templates/lib/components/common/src/compositions/use-expose/index.ts +9 -0
- package/templates/lib/components/common/src/compositions/use-lay-render/index.ts +17 -0
- package/templates/lib/components/common/src/compositions/use-link/index.ts +14 -0
- package/templates/lib/components/common/src/compositions/use-lock-scroll/index.ts +25 -0
- package/templates/lib/components/common/src/compositions/use-long-press/index.ts +141 -0
- package/templates/lib/components/common/src/compositions/use-momentum/index.ts +82 -0
- package/templates/lib/components/common/src/compositions/use-mount-component/index.ts +48 -0
- package/templates/lib/components/common/src/compositions/use-rect/index.ts +31 -0
- package/templates/lib/components/common/src/compositions/use-refs/index.ts +21 -0
- package/templates/lib/components/common/src/compositions/use-resize-observer/index.ts +85 -0
- package/templates/lib/components/common/src/compositions/use-resize-observer/utils.ts +37 -0
- package/templates/lib/components/common/src/compositions/use-scroll-parent/index.ts +42 -0
- package/templates/lib/components/common/src/compositions/use-touch/index.ts +82 -0
- package/templates/lib/components/common/src/compositions/use-touch-move/index.ts +120 -0
- package/templates/lib/components/common/src/entity/base-property.ts +129 -0
- package/templates/lib/components/common/src/entity/entity-schema.ts +274 -0
- package/templates/lib/components/common/src/entity/input-base-property.ts +285 -0
- package/templates/lib/components/common/src/style/animation/index.scss +150 -0
- package/templates/lib/components/common/src/style/base.scss +63 -0
- package/templates/lib/components/common/src/style/fonts/farris-mobile-icon.ttf +0 -0
- package/templates/lib/components/common/src/style/icon.scss +6 -0
- package/templates/lib/components/common/src/style/index.scss +4 -0
- package/templates/lib/components/common/src/style/mixins/bem.scss +204 -0
- package/templates/lib/components/common/src/style/mixins/border-radius.scss +13 -0
- package/templates/lib/components/common/src/style/mixins/ellipsis.scss +15 -0
- package/templates/lib/components/common/src/style/mixins/hairline.scss +113 -0
- package/templates/lib/components/common/src/style/mixins/index.scss +6 -0
- package/templates/lib/components/common/src/style/mixins/margin.scss +10 -0
- package/templates/lib/components/common/src/style/mixins/safe-area.scss +9 -0
- package/templates/lib/components/common/src/style/variables.scss +113 -0
- package/templates/lib/components/common/src/utils/index.ts +15 -0
- package/templates/lib/components/common/src/utils/src/common.ts +83 -0
- package/templates/lib/components/common/src/utils/src/date.ts +134 -0
- package/templates/lib/components/common/src/utils/src/dom/event.ts +37 -0
- package/templates/lib/components/common/src/utils/src/hook.ts +18 -0
- package/templates/lib/components/common/src/utils/src/number.ts +26 -0
- package/templates/lib/components/common/src/utils/src/query-filter.ts +40 -0
- package/templates/lib/components/common/src/utils/src/resove-asset.ts +33 -0
- package/templates/lib/components/common/src/utils/src/string.ts +18 -0
- package/templates/lib/components/common/src/utils/src/throttle.ts +41 -0
- package/templates/lib/components/common/src/utils/src/transition.ts +14 -0
- package/templates/lib/components/common/src/utils/src/type.ts +105 -0
- package/templates/lib/components/common/src/utils/src/use-appearance.ts +33 -0
- package/templates/lib/components/common/src/utils/src/with-install.ts +16 -0
- package/templates/lib/components/common/src/utils/src/with-register-designer.ts +16 -0
- package/templates/lib/components/common/src/utils/src/with-register.ts +16 -0
- package/templates/lib/components/common/types.ts +131 -0
- package/templates/lib/components/index.ts +0 -0
- package/templates/lib/farris.config.mjs +37 -16
- package/templates/lib/index.html +12 -12
- package/templates/lib/package.json +28 -28
- package/templates/lib/src/App.vue +80 -5
- package/templates/lib/src/components/TheButton.vue +3 -0
- package/templates/lib/src/main.ts +10 -9
- package/templates/lib/src/router/index.ts +23 -0
- package/templates/lib/src/views/AboutView.vue +15 -0
- package/templates/lib/src/views/HomeView.vue +9 -0
- package/templates/lib/tsconfig.json +19 -17
- package/templates/mobile/.eslintrc.cjs +15 -15
- package/templates/mobile/.prettierrc.json +7 -7
- package/templates/mobile/farris.config.mjs +1 -1
- package/templates/mobile/index.html +12 -12
- package/templates/mobile/package.json +28 -28
- package/templates/mobile/src/App.vue +80 -80
- package/templates/mobile/src/components/TheButton.vue +3 -3
- package/templates/mobile/src/main.ts +12 -12
- package/templates/mobile/src/router/index.ts +23 -23
- package/templates/mobile/src/views/AboutView.vue +15 -15
- package/templates/mobile/src/views/HomeView.vue +9 -9
- package/templates/mobile/tsconfig.json +17 -17
- package/templates/web/.eslintrc.cjs +15 -0
- package/templates/web/.prettierrc.json +8 -0
- package/templates/web/farris.config.mjs +24 -0
- package/templates/web/index.html +12 -0
- package/templates/web/package.json +29 -0
- package/templates/web/src/App.vue +80 -0
- package/templates/web/src/components/TheButton.vue +3 -0
- package/templates/web/src/main.ts +10 -0
- package/templates/web/src/router/index.ts +23 -0
- package/templates/web/src/views/AboutView.vue +15 -0
- package/templates/web/src/views/HomeView.vue +9 -0
- package/templates/web/tsconfig.json +18 -0
- package/templates/lib/packages/button/src/index.vue +0 -4
- package/templates/lib/packages/index.ts +0 -7
@@ -0,0 +1,41 @@
|
|
1
|
+
export const throttle = (
|
2
|
+
fn: (...args: any)=> any,
|
3
|
+
wait: number,
|
4
|
+
options: { leading?: boolean; trailing?: boolean } = {}
|
5
|
+
) => {
|
6
|
+
let timeout: any = null;
|
7
|
+
let previous = 0;
|
8
|
+
|
9
|
+
const throttled = (...args: any) => {
|
10
|
+
const nowDate = +new Date();
|
11
|
+
|
12
|
+
if (!previous && options.leading === false) {
|
13
|
+
previous = nowDate;
|
14
|
+
}
|
15
|
+
|
16
|
+
const remaining = wait - (nowDate - previous);
|
17
|
+
|
18
|
+
if (remaining <= 0 || remaining > wait) {
|
19
|
+
if (timeout) {
|
20
|
+
clearTimeout(timeout);
|
21
|
+
timeout = null;
|
22
|
+
}
|
23
|
+
previous = nowDate;
|
24
|
+
fn(...args);
|
25
|
+
} else if (!timeout && options.trailing !== false) {
|
26
|
+
timeout = setTimeout(() => {
|
27
|
+
previous = options.leading === false ? 0 : +new Date();
|
28
|
+
timeout = null;
|
29
|
+
fn(...args);
|
30
|
+
}, remaining);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
// 手动取消
|
35
|
+
throttled.cancel = function () {
|
36
|
+
clearTimeout(timeout);
|
37
|
+
previous = 0;
|
38
|
+
timeout = null;
|
39
|
+
};
|
40
|
+
return throttled;
|
41
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export const getSlideTransitionName = (position: string | undefined) => {
|
2
|
+
switch (position) {
|
3
|
+
case 'bottom':
|
4
|
+
return 'fm-slide-up';
|
5
|
+
case 'top':
|
6
|
+
return 'fm-slide-down';
|
7
|
+
case 'left':
|
8
|
+
return 'fm-slide-left';
|
9
|
+
case 'right':
|
10
|
+
return 'fm-slide-right';
|
11
|
+
default:
|
12
|
+
return 'fm-fade';
|
13
|
+
}
|
14
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
export const inBrowser = typeof window !== 'undefined';
|
2
|
+
|
3
|
+
export const inIOS = () => /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent);
|
4
|
+
|
5
|
+
export const inAndroid = () => /(Android|Adr)/i.test(navigator.userAgent);
|
6
|
+
|
7
|
+
export function isDef<T>(val: T): val is NonNullable<T> {
|
8
|
+
return val !== undefined && val !== null;
|
9
|
+
}
|
10
|
+
|
11
|
+
export function isNull(val: unknown): val is null {
|
12
|
+
return val === null;
|
13
|
+
}
|
14
|
+
|
15
|
+
export function isUndefined(val: unknown): val is undefined {
|
16
|
+
return val === undefined;
|
17
|
+
}
|
18
|
+
|
19
|
+
export function isString(val: unknown): val is string {
|
20
|
+
return typeof val === 'string';
|
21
|
+
}
|
22
|
+
|
23
|
+
export function isNumber(val: unknown): val is number {
|
24
|
+
return typeof val === 'number';
|
25
|
+
}
|
26
|
+
|
27
|
+
export function isBoolean(val: unknown): val is null {
|
28
|
+
return typeof val === 'boolean';
|
29
|
+
}
|
30
|
+
|
31
|
+
export const { isArray } = Array;
|
32
|
+
|
33
|
+
export function isSymbol(val: unknown): val is symbol {
|
34
|
+
return typeof val === 'symbol';
|
35
|
+
}
|
36
|
+
|
37
|
+
export function isFunction(val: unknown): val is FunctionConstructor {
|
38
|
+
return typeof val === 'function';
|
39
|
+
}
|
40
|
+
|
41
|
+
export function isObject(val: unknown): val is Record<any, any> {
|
42
|
+
return val !== null && typeof val === 'object';
|
43
|
+
}
|
44
|
+
|
45
|
+
export function isPromise<T = any>(val: unknown): val is Promise<T> {
|
46
|
+
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
47
|
+
}
|
48
|
+
|
49
|
+
export function isNumeric(val: string) {
|
50
|
+
return /^-?\d+(\.\d+)?$/.test(val);
|
51
|
+
}
|
52
|
+
|
53
|
+
export function isDate(val: unknown): val is Date {
|
54
|
+
return typeof val === 'object' && val instanceof Date;
|
55
|
+
}
|
56
|
+
|
57
|
+
export function getType(val: unknown) {
|
58
|
+
let type: string;
|
59
|
+
switch (val) {
|
60
|
+
case isString(val):{
|
61
|
+
type = 'string';
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
case isNumber(val):{
|
65
|
+
type = 'number';
|
66
|
+
break;
|
67
|
+
}
|
68
|
+
case isDate(val):{
|
69
|
+
type = 'date';
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
case isNull(val):{
|
73
|
+
type = 'null';
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
case isUndefined(val):{
|
77
|
+
type = 'undefined';
|
78
|
+
break;
|
79
|
+
}
|
80
|
+
case isArray(val):{
|
81
|
+
type = 'array';
|
82
|
+
break;
|
83
|
+
}
|
84
|
+
case isSymbol(val):{
|
85
|
+
type = 'symbol';
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
case isFunction(val):{
|
89
|
+
type = 'function';
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
case isPromise(val):{
|
93
|
+
type = 'promise';
|
94
|
+
break;
|
95
|
+
}
|
96
|
+
case isObject(val):{
|
97
|
+
type = 'object';
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
default:
|
101
|
+
type = typeof val;
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
return type;
|
105
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* 根据传递过来已有的类对象和自定义类名,构造新的样式对象
|
3
|
+
* @param classObject
|
4
|
+
* @param customClass
|
5
|
+
* @returns
|
6
|
+
*/
|
7
|
+
export function getCustomClass(classObject: Record<string, any>, customClass: string) {
|
8
|
+
const customClassArray = customClass?.split(' ') || [];
|
9
|
+
customClassArray.reduce((result: Record<string, boolean>, classString: string) => {
|
10
|
+
if (classString) {
|
11
|
+
result[classString] = true;
|
12
|
+
}
|
13
|
+
return result;
|
14
|
+
}, classObject);
|
15
|
+
return classObject;
|
16
|
+
}
|
17
|
+
/**
|
18
|
+
* 根据传递过来已有的style对象和自定义style,构造新的style对象
|
19
|
+
* @param styleObject
|
20
|
+
* @param customStyle
|
21
|
+
* @returns
|
22
|
+
*/
|
23
|
+
export function getCustomStyle(styleObject: Record<string, any>, customStyle: string) {
|
24
|
+
const styleArray = customStyle?.split(';') || [];
|
25
|
+
styleArray.reduce((result: Record<string, any>, styleString: string) => {
|
26
|
+
if (styleString) {
|
27
|
+
const styles = styleString.split(':');
|
28
|
+
result[styles[0]] = styles[1];
|
29
|
+
}
|
30
|
+
return result;
|
31
|
+
}, styleObject);
|
32
|
+
return styleObject;
|
33
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { App, Component } from 'vue';
|
2
|
+
|
3
|
+
export type WithInstall<T> = T & {
|
4
|
+
install(app: App): void;
|
5
|
+
};
|
6
|
+
|
7
|
+
export function withInstall<T extends Component>(options: T) {
|
8
|
+
(options as Record<string, unknown>).install = (app: App) => {
|
9
|
+
const { name } = options;
|
10
|
+
if (name) {
|
11
|
+
app.component(name, options);
|
12
|
+
}
|
13
|
+
};
|
14
|
+
|
15
|
+
return options as WithInstall<T>;
|
16
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { App, Component } from 'vue';
|
2
|
+
|
3
|
+
export type WithRegisterDesigner<T> = T & {
|
4
|
+
registerDesigner(app: App): void;
|
5
|
+
};
|
6
|
+
|
7
|
+
export function withRegisterDesigner<T extends Component>(component: T, options: { name: string, designerComponent: Component, propsResolver: (schemaValue?: Record<string, any>) => Record<string, any> }) {
|
8
|
+
const { name, designerComponent, propsResolver } = options;
|
9
|
+
|
10
|
+
(component as Record<string, unknown>).registerDesigner = (componentMap: Record<string, any>, propsResolverMap: Record<string, any>, configResolverMap: Record<string, any>, resolverMap: Record<string, any>) => {
|
11
|
+
componentMap[name] = designerComponent;
|
12
|
+
propsResolverMap[name] = propsResolver;
|
13
|
+
};
|
14
|
+
|
15
|
+
return component as WithRegisterDesigner<T>;
|
16
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { App, Component } from 'vue';
|
2
|
+
|
3
|
+
export type WithRegister<T> = T & {
|
4
|
+
register(app: App): void;
|
5
|
+
};
|
6
|
+
|
7
|
+
export function withRegister<T extends Component>(component: T, options: { name: string, propsResolver: (schemaValue?: Record<string, any>) => Record<string, any> }) {
|
8
|
+
const { name, propsResolver } = options;
|
9
|
+
|
10
|
+
(component as Record<string, unknown>).register = (componentMap: Record<string, any>, propsResolverMap: Record<string, any>, configResolverMap: Record<string, any>, resolverMap: Record<string, any>) => {
|
11
|
+
componentMap[name] = component;
|
12
|
+
propsResolverMap[name] = propsResolver;
|
13
|
+
};
|
14
|
+
|
15
|
+
return component as WithRegister<T>;
|
16
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import { ComputedRef, Ref } from "vue";
|
2
|
+
|
3
|
+
export interface TextBoxProps {
|
4
|
+
|
5
|
+
customClass: string;
|
6
|
+
|
7
|
+
disabled: boolean;
|
8
|
+
|
9
|
+
editable: boolean;
|
10
|
+
|
11
|
+
enableClear: boolean;
|
12
|
+
|
13
|
+
enableTitle: boolean;
|
14
|
+
|
15
|
+
forcePlaceholder: boolean;
|
16
|
+
|
17
|
+
modelValue: string;
|
18
|
+
|
19
|
+
placeholder: string;
|
20
|
+
|
21
|
+
readonly: boolean;
|
22
|
+
|
23
|
+
textAlign: string;
|
24
|
+
|
25
|
+
showBorder: boolean;
|
26
|
+
|
27
|
+
updateOn: 'blur' | 'change';
|
28
|
+
}
|
29
|
+
|
30
|
+
export interface UseClear {
|
31
|
+
|
32
|
+
clearButtonClass: ComputedRef<Record<string, boolean>>;
|
33
|
+
|
34
|
+
clearButtonStyle: ComputedRef<Record<string, any>>;
|
35
|
+
|
36
|
+
hasShownClearButton: Ref<boolean>;
|
37
|
+
|
38
|
+
onClearValue: ($event: MouseEvent) => void;
|
39
|
+
|
40
|
+
onMouseEnter: ($event: MouseEvent) => void;
|
41
|
+
|
42
|
+
onMouseLeave: ($event: MouseEvent) => void;
|
43
|
+
|
44
|
+
shouldShowClearButton: ComputedRef<boolean>;
|
45
|
+
}
|
46
|
+
|
47
|
+
export interface UseTextBox {
|
48
|
+
|
49
|
+
changeTextBoxValue: (newValue: string, shouldEmitChangeEvent: boolean) => void;
|
50
|
+
|
51
|
+
disabled?: Ref<boolean>;
|
52
|
+
|
53
|
+
displayText?: Ref<string>;
|
54
|
+
|
55
|
+
editable?: Ref<boolean>;
|
56
|
+
|
57
|
+
hasFocused?: ComputedRef<boolean>;
|
58
|
+
|
59
|
+
inputGroupClass: ComputedRef<Record<string, boolean>>;
|
60
|
+
|
61
|
+
inputType: Ref<string>;
|
62
|
+
|
63
|
+
isEmpty: ComputedRef<boolean>;
|
64
|
+
|
65
|
+
modelValue?: Ref<string>;
|
66
|
+
|
67
|
+
readonly?: ComputedRef<boolean>;
|
68
|
+
|
69
|
+
onBlur?: (payload: FocusEvent) => boolean;
|
70
|
+
|
71
|
+
onClick?: (payload: MouseEvent) => void;
|
72
|
+
|
73
|
+
onFocus?: (payload: FocusEvent) => void;
|
74
|
+
|
75
|
+
onInput?: (payload: Event) => void;
|
76
|
+
|
77
|
+
onKeydown?: (payload: KeyboardEvent) => void;
|
78
|
+
|
79
|
+
onKeyup?: (payload: KeyboardEvent) => void;
|
80
|
+
|
81
|
+
onMousedown?: (payload: MouseEvent) => void;
|
82
|
+
|
83
|
+
onTextBoxValueChange?: (payload: Event) => void;
|
84
|
+
|
85
|
+
placeholder: ComputedRef<string>;
|
86
|
+
|
87
|
+
textBoxClass: ComputedRef<Record<string, boolean>>;
|
88
|
+
|
89
|
+
textBoxTitle: ComputedRef<string>;
|
90
|
+
|
91
|
+
inputGroupStyle: ComputedRef<string>;
|
92
|
+
}
|
93
|
+
|
94
|
+
export interface UseDateFormat {
|
95
|
+
formatTo: (date: string | Date, format: string) => string;
|
96
|
+
}
|
97
|
+
export type NumberType = string | number;
|
98
|
+
export interface NumberOption {
|
99
|
+
prefix?: string;
|
100
|
+
suffix?: string;
|
101
|
+
decimalSeparator?: string;
|
102
|
+
groupSeparator?: string;
|
103
|
+
[key: string]: any;
|
104
|
+
}
|
105
|
+
export interface UseNumberFormat {
|
106
|
+
formatTo: (value: NumberType, opts: any) => string;
|
107
|
+
removeFormat: (value: NumberType | null | undefined, opts: any) => string;
|
108
|
+
convertCurrency: (money: string) => string;
|
109
|
+
toFixed: (value: string, precision: number) => string;
|
110
|
+
toNumber: (value: string) => number;
|
111
|
+
greaterThan: (firstValue: NumberType, secondValue: NumberType) => boolean;
|
112
|
+
lessThan: (firstValue: NumberType, secondValue: NumberType) => boolean;
|
113
|
+
equal: (firstValue: NumberType, secondValue: NumberType) => boolean;
|
114
|
+
minus: (firstValue: NumberType, secondValue: NumberType) => string;
|
115
|
+
multiplied: (firstValue: NumberType, secondValue: NumberType) => string;
|
116
|
+
plus: (firstValue: NumberType, secondValue: NumberType) => string;
|
117
|
+
average: (total: NumberType, len: number) => string;
|
118
|
+
sum: (numberArray: NumberType[]) => string;
|
119
|
+
min: (firstValue: Array<NumberType> | NumberType, secondValue: NumberType | null) => string;
|
120
|
+
max: (firstValue: Array<NumberType> | NumberType, secondValue: NumberType | null) => string;
|
121
|
+
}
|
122
|
+
|
123
|
+
export type TimeAgoDate = Date | string | number;
|
124
|
+
export type TimeAgoOptions = {
|
125
|
+
// 可能后期有其他属性
|
126
|
+
/** 相对的日期 */
|
127
|
+
readonly relativeDate?: TimeAgoDate;
|
128
|
+
};
|
129
|
+
export interface UseTimeAgoFormat {
|
130
|
+
formatTo(date: TimeAgoDate, opts?: TimeAgoOptions): string
|
131
|
+
}
|
File without changes
|
@@ -1,35 +1,56 @@
|
|
1
1
|
import { fileURLToPath, URL } from 'node:url';
|
2
2
|
|
3
|
+
const { BUILD_TYPE } = process.env;
|
4
|
+
const externalDependencies = BUILD_TYPE !== 'app';
|
5
|
+
const externals = [BUILD_TYPE === 'components' ? "@components" : ''];
|
6
|
+
const outDir = BUILD_TYPE === 'app' ? "dist" : 'package';
|
3
7
|
export default {
|
4
|
-
|
5
|
-
lib: {
|
6
|
-
// 入口 默认值 './src/main.ts'
|
7
|
-
entry: './packages/index.ts',
|
8
|
-
// 库名称
|
9
|
-
name: "<%= name %>",
|
10
|
-
// 输出文件名
|
11
|
-
fileName: "index",
|
12
|
-
// 输出文件格式 默认值 ["es", 'systemjs']
|
13
|
-
formats: <%= formats %>,
|
14
|
-
},
|
8
|
+
format: "<%= format %>",
|
15
9
|
// 输出目录 App模式默认值 './dist' Lib模式 './lib'
|
16
10
|
// outDir: fileURLToPath(new URL('./dist', import.meta.url)),
|
17
|
-
//
|
11
|
+
// 压缩代码 默认值 true
|
18
12
|
minify: true,
|
19
13
|
// 外部依赖排除项 默认值 { include: [], exclude: [] }
|
20
14
|
// externals: {
|
21
15
|
// include: [],
|
22
16
|
// exclude: []
|
23
17
|
// },
|
18
|
+
externals: {
|
19
|
+
include: externals,
|
20
|
+
filter: (externals) => {
|
21
|
+
return (id) => {
|
22
|
+
return externals.find((item) => item && id.indexOf(item) === 0);
|
23
|
+
};
|
24
|
+
}
|
25
|
+
},
|
24
26
|
// 是否排除 package.json 中 dependencies和 peerDependencies 依赖的包; App模式默认值 false Lib模式默认值 true
|
25
|
-
externalDependencies
|
27
|
+
externalDependencies,
|
26
28
|
// 路径别名 默认值 null
|
27
29
|
alias: [
|
28
|
-
{ find: '@', replacement: fileURLToPath(new URL('./
|
29
|
-
{ find: '@
|
30
|
+
{ find: '@', replacement: fileURLToPath(new URL('./', import.meta.url)) },
|
31
|
+
{ find: '@components', replacement: fileURLToPath(new URL('./components', import.meta.url)) }
|
30
32
|
],
|
33
|
+
// 打包后产物路径
|
34
|
+
outDir: fileURLToPath(new URL(`./${outDir}`, import.meta.url)),
|
35
|
+
// 开发者模式 本地启动服务
|
36
|
+
server: {
|
37
|
+
proxy: {
|
38
|
+
"/api": {
|
39
|
+
target: "http://localhost:5173",
|
40
|
+
changeOrigin: true,
|
41
|
+
secure: false
|
42
|
+
}
|
43
|
+
}
|
44
|
+
},
|
45
|
+
lib: {
|
46
|
+
entry: fileURLToPath(new URL('./components/index.ts', import.meta.url)),
|
47
|
+
name: "",
|
48
|
+
fileName: "index",
|
49
|
+
formats: ["esm", 'umd', 'systemjs'],
|
50
|
+
},
|
51
|
+
target: 'es2015',
|
31
52
|
// 插件 默认值 [vue(), vueJsx()] 不要重复添加
|
32
53
|
// plugins: [],
|
33
54
|
// viteConfig 配置项
|
34
55
|
viteConfig: {}
|
35
|
-
}
|
56
|
+
};
|
package/templates/lib/index.html
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>Vite App</title>
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id="app"></div>
|
10
|
-
<script type="module" src="/src/main.ts"></script>
|
11
|
-
</body>
|
12
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>Vite App</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id="app"></div>
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
11
|
+
</body>
|
12
|
+
</html>
|
@@ -1,29 +1,29 @@
|
|
1
|
-
{
|
2
|
-
"name": "<%= name %>",
|
3
|
-
"version": "0.0.0",
|
4
|
-
"private": true,
|
5
|
-
"type": "module",
|
6
|
-
"
|
7
|
-
|
8
|
-
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"vue": "^3.
|
17
|
-
},
|
18
|
-
"devDependencies": {
|
19
|
-
"@farris/cli": "<%= cliVersion %>",
|
20
|
-
"@rushstack/eslint-patch": "^1.8.0",
|
21
|
-
"@vue/eslint-config-prettier": "^9.0.0",
|
22
|
-
"@vue/eslint-config-typescript": "^13.0.0",
|
23
|
-
"@vue/tsconfig": "^0.5.1",
|
24
|
-
"eslint": "^8.57.0",
|
25
|
-
"eslint-plugin-vue": "^9.23.0",
|
26
|
-
"prettier": "^3.2.5",
|
27
|
-
"typescript": "~5.4.0"
|
28
|
-
}
|
1
|
+
{
|
2
|
+
"name": "<%= name %>",
|
3
|
+
"version": "0.0.0",
|
4
|
+
"private": true,
|
5
|
+
"type": "module",
|
6
|
+
"scripts": {
|
7
|
+
"dev": "farris-cli dev",
|
8
|
+
"build": "farris-cli build",
|
9
|
+
"preview": "farris-cli preview",
|
10
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
11
|
+
"format": "prettier --write src/"
|
12
|
+
},
|
13
|
+
"dependencies": {
|
14
|
+
"@farris/ui-vue": "latest",
|
15
|
+
"vue": "^3.4.29",
|
16
|
+
"vue-router": "^4.3.0"
|
17
|
+
},
|
18
|
+
"devDependencies": {
|
19
|
+
"@farris/cli": "<%= cliVersion %>",
|
20
|
+
"@rushstack/eslint-patch": "^1.8.0",
|
21
|
+
"@vue/eslint-config-prettier": "^9.0.0",
|
22
|
+
"@vue/eslint-config-typescript": "^13.0.0",
|
23
|
+
"@vue/tsconfig": "^0.5.1",
|
24
|
+
"eslint": "^8.57.0",
|
25
|
+
"eslint-plugin-vue": "^9.23.0",
|
26
|
+
"prettier": "^3.2.5",
|
27
|
+
"typescript": "~5.4.0"
|
28
|
+
}
|
29
29
|
}
|
@@ -1,5 +1,80 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<script setup lang="ts">
|
2
|
+
import { RouterLink, RouterView } from 'vue-router';
|
3
|
+
</script>
|
4
|
+
|
5
|
+
<template>
|
6
|
+
<header>
|
7
|
+
<div class="wrapper">
|
8
|
+
<nav>
|
9
|
+
<RouterLink to="/">Home</RouterLink>
|
10
|
+
<RouterLink to="/about">About</RouterLink>
|
11
|
+
</nav>
|
12
|
+
</div>
|
13
|
+
</header>
|
14
|
+
|
15
|
+
<RouterView />
|
16
|
+
</template>
|
17
|
+
|
18
|
+
<style scoped>
|
19
|
+
header {
|
20
|
+
line-height: 1.5;
|
21
|
+
max-height: 100vh;
|
22
|
+
}
|
23
|
+
|
24
|
+
.logo {
|
25
|
+
display: block;
|
26
|
+
margin: 0 auto 2rem;
|
27
|
+
}
|
28
|
+
|
29
|
+
nav {
|
30
|
+
width: 100%;
|
31
|
+
font-size: 12px;
|
32
|
+
text-align: center;
|
33
|
+
margin-top: 2rem;
|
34
|
+
}
|
35
|
+
|
36
|
+
nav a.router-link-exact-active {
|
37
|
+
color: var(--color-text);
|
38
|
+
}
|
39
|
+
|
40
|
+
nav a.router-link-exact-active:hover {
|
41
|
+
background-color: transparent;
|
42
|
+
}
|
43
|
+
|
44
|
+
nav a {
|
45
|
+
display: inline-block;
|
46
|
+
padding: 0 1rem;
|
47
|
+
border-left: 1px solid var(--color-border);
|
48
|
+
}
|
49
|
+
|
50
|
+
nav a:first-of-type {
|
51
|
+
border: 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
@media (min-width: 1024px) {
|
55
|
+
header {
|
56
|
+
display: flex;
|
57
|
+
place-items: center;
|
58
|
+
padding-right: calc(var(--section-gap) / 2);
|
59
|
+
}
|
60
|
+
|
61
|
+
.logo {
|
62
|
+
margin: 0 2rem 0 0;
|
63
|
+
}
|
64
|
+
|
65
|
+
header .wrapper {
|
66
|
+
display: flex;
|
67
|
+
place-items: flex-start;
|
68
|
+
flex-wrap: wrap;
|
69
|
+
}
|
70
|
+
|
71
|
+
nav {
|
72
|
+
text-align: left;
|
73
|
+
margin-left: -1rem;
|
74
|
+
font-size: 1rem;
|
75
|
+
|
76
|
+
padding: 1rem 0;
|
77
|
+
margin-top: 1rem;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
</style>
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import { createApp } from 'vue'
|
2
|
-
import
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import { createApp } from 'vue';
|
2
|
+
import FarrisVue from '@farris/ui-vue';
|
3
|
+
import App from './App.vue';
|
4
|
+
import router from './router';
|
5
|
+
|
6
|
+
const app = createApp(App);
|
7
|
+
|
8
|
+
app.use(router).use(FarrisVue);
|
9
|
+
|
10
|
+
app.mount('#app');
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
2
|
+
import HomeView from '../views/HomeView.vue';
|
3
|
+
|
4
|
+
const router = createRouter({
|
5
|
+
history: createWebHistory(import.meta.env.BASE_URL),
|
6
|
+
routes: [
|
7
|
+
{
|
8
|
+
path: '/',
|
9
|
+
name: 'home',
|
10
|
+
component: HomeView
|
11
|
+
},
|
12
|
+
{
|
13
|
+
path: '/about',
|
14
|
+
name: 'about',
|
15
|
+
// route level code-splitting
|
16
|
+
// this generates a separate chunk (About.[hash].js) for this route
|
17
|
+
// which is lazy-loaded when the route is visited.
|
18
|
+
component: () => import('../views/AboutView.vue')
|
19
|
+
}
|
20
|
+
]
|
21
|
+
});
|
22
|
+
|
23
|
+
export default router;
|