@tzk-design-vue2/shared 1.0.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/mixins/form.js ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 表单 Mixin
3
+ */
4
+
5
+ export default {
6
+ props: {
7
+ // 表单值
8
+ value: {
9
+ type: [String, Number, Boolean, Array, Object],
10
+ default: ''
11
+ },
12
+ // 是否禁用
13
+ disabled: {
14
+ type: Boolean,
15
+ default: false
16
+ },
17
+ // 是否只读
18
+ readonly: {
19
+ type: Boolean,
20
+ default: false
21
+ }
22
+ },
23
+
24
+ data() {
25
+ return {
26
+ // 内部值
27
+ innerValue: this.value,
28
+ // 是否聚焦
29
+ isFocused: false
30
+ };
31
+ },
32
+
33
+ watch: {
34
+ value(newVal) {
35
+ this.innerValue = newVal;
36
+ },
37
+
38
+ innerValue(newVal) {
39
+ this.$emit('input', newVal);
40
+ this.$emit('change', newVal);
41
+ }
42
+ },
43
+
44
+ methods: {
45
+ /**
46
+ * 更新值
47
+ * @param {*} value - 新值
48
+ */
49
+ updateValue(value) {
50
+ this.innerValue = value;
51
+ },
52
+
53
+ /**
54
+ * 聚焦处理
55
+ * @param {Event} event - 事件对象
56
+ */
57
+ handleFocus(event) {
58
+ if (this.disabled || this.readonly) return;
59
+ this.isFocused = true;
60
+ this.$emit('focus', event);
61
+ },
62
+
63
+ /**
64
+ * 失焦处理
65
+ * @param {Event} event - 事件对象
66
+ */
67
+ handleBlur(event) {
68
+ if (this.disabled || this.readonly) return;
69
+ this.isFocused = false;
70
+ this.$emit('blur', event);
71
+ },
72
+
73
+ /**
74
+ * 清空值
75
+ */
76
+ clearValue() {
77
+ this.updateValue('');
78
+ this.$emit('clear');
79
+ }
80
+ }
81
+ };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@tzk-design-vue2/shared",
3
+ "version": "1.0.0",
4
+ "description": "TZK Design 共享资源包",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "vue",
8
+ "uniapp",
9
+ "shared",
10
+ "utils"
11
+ ],
12
+ "author": "TZK Design Team",
13
+ "license": "MIT",
14
+ "peerDependencies": {
15
+ "vue": "^2.7.14",
16
+ "vuex": "^3.6.2"
17
+ },
18
+ "dependencies": {
19
+ "vuex": "^3.6.2"
20
+ }
21
+ }
package/store/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Vuex Store 入口
3
+ */
4
+
5
+ import Vue from 'vue';
6
+ import Vuex from 'vuex';
7
+ import componentModule from './modules/component';
8
+
9
+ Vue.use(Vuex);
10
+
11
+ const store = new Vuex.Store({
12
+ modules: {
13
+ component: componentModule
14
+ },
15
+
16
+ strict: process.env.NODE_ENV !== 'production'
17
+ });
18
+
19
+ export default store;
@@ -0,0 +1,124 @@
1
+ /**
2
+ * 组件通信 Store 模块
3
+ * 用于组件间状态共享和通信
4
+ */
5
+
6
+ const state = {
7
+ // 全局配置
8
+ globalConfig: {},
9
+
10
+ // 组件状态映射
11
+ componentStates: {}
12
+ };
13
+
14
+ const mutations = {
15
+ /**
16
+ * 设置全局配置
17
+ * @param {Object} state - 状态
18
+ * @param {Object} config - 配置
19
+ */
20
+ SET_GLOBAL_CONFIG(state, config) {
21
+ state.globalConfig = { ...state.globalConfig, ...config };
22
+ },
23
+
24
+ /**
25
+ * 设置组件状态
26
+ * @param {Object} state - 状态
27
+ * @param {Object} payload - 载荷
28
+ */
29
+ SET_COMPONENT_STATE(state, { id, data }) {
30
+ state.componentStates = {
31
+ ...state.componentStates,
32
+ [id]: data
33
+ };
34
+ },
35
+
36
+ /**
37
+ * 移除组件状态
38
+ * @param {Object} state - 状态
39
+ * @param {string} id - 组件 ID
40
+ */
41
+ REMOVE_COMPONENT_STATE(state, id) {
42
+ const newStates = { ...state.componentStates };
43
+ delete newStates[id];
44
+ state.componentStates = newStates;
45
+ },
46
+
47
+ /**
48
+ * 清空所有组件状态
49
+ * @param {Object} state - 状态
50
+ */
51
+ CLEAR_COMPONENT_STATES(state) {
52
+ state.componentStates = {};
53
+ }
54
+ };
55
+
56
+ const actions = {
57
+ /**
58
+ * 更新全局配置
59
+ * @param {Object} context - 上下文
60
+ * @param {Object} config - 配置
61
+ */
62
+ updateGlobalConfig({ commit }, config) {
63
+ commit('SET_GLOBAL_CONFIG', config);
64
+ },
65
+
66
+ /**
67
+ * 更新组件状态
68
+ * @param {Object} context - 上下文
69
+ * @param {Object} payload - 载荷
70
+ */
71
+ updateComponentState({ commit }, payload) {
72
+ commit('SET_COMPONENT_STATE', payload);
73
+ },
74
+
75
+ /**
76
+ * 移除组件状态
77
+ * @param {Object} context - 上下文
78
+ * @param {string} id - 组件 ID
79
+ */
80
+ removeComponentState({ commit }, id) {
81
+ commit('REMOVE_COMPONENT_STATE', id);
82
+ },
83
+
84
+ /**
85
+ * 清空所有组件状态
86
+ * @param {Object} context - 上下文
87
+ */
88
+ clearComponentStates({ commit }) {
89
+ commit('CLEAR_COMPONENT_STATES');
90
+ }
91
+ };
92
+
93
+ const getters = {
94
+ /**
95
+ * 获取全局配置
96
+ * @param {Object} state - 状态
97
+ * @returns {Object}
98
+ */
99
+ globalConfig: state => state.globalConfig,
100
+
101
+ /**
102
+ * 获取组件状态
103
+ * @param {Object} state - 状态
104
+ * @returns {Function}
105
+ */
106
+ getComponentState: state => id => {
107
+ return state.componentStates[id] || null;
108
+ },
109
+
110
+ /**
111
+ * 获取所有组件状态
112
+ * @param {Object} state - 状态
113
+ * @returns {Object}
114
+ */
115
+ allComponentStates: state => state.componentStates
116
+ };
117
+
118
+ export default {
119
+ namespaced: true,
120
+ state,
121
+ mutations,
122
+ actions,
123
+ getters
124
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 样式入口文件
3
+ */
4
+ /**
5
+ * 色彩系统 Token
6
+ * 参考 NutUI 设计规范
7
+ */
8
+ /**
9
+ * 字体系统 Token
10
+ */
11
+ /**
12
+ * 间距系统 Token
13
+ * 基础单位: 4px (8rpx)
14
+ */
15
+ /**
16
+ * 通用变量 Token
17
+ */
18
+ /**
19
+ * Less Mixins
20
+ * 常用样式混入
21
+ */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 样式入口文件
3
+ */
4
+
5
+ @import './variables/color.less';
6
+ @import './variables/typography.less';
7
+ @import './variables/spacing.less';
8
+ @import './variables/common.less';
9
+ @import './mixins.less';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Less Mixins
3
+ * 常用样式混入
4
+ */
5
+ /**
6
+ * 色彩系统 Token
7
+ * 参考 NutUI 设计规范
8
+ */
9
+ /**
10
+ * 字体系统 Token
11
+ */
12
+ /**
13
+ * 间距系统 Token
14
+ * 基础单位: 4px (8rpx)
15
+ */
16
+ /**
17
+ * 通用变量 Token
18
+ */
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Less Mixins
3
+ * 常用样式混入
4
+ */
5
+
6
+ @import './variables/color.less';
7
+ @import './variables/typography.less';
8
+ @import './variables/spacing.less';
9
+ @import './variables/common.less';
10
+
11
+ // ========== 清除浮动 ==========
12
+ .clearfix() {
13
+ &::after {
14
+ content: '';
15
+ display: table;
16
+ clear: both;
17
+ }
18
+ }
19
+
20
+ // ========== 文本溢出省略 ==========
21
+ .ellipsis() {
22
+ overflow: hidden;
23
+ text-overflow: ellipsis;
24
+ white-space: nowrap;
25
+ }
26
+
27
+ .multi-ellipsis(@lines: 2) {
28
+ display: -webkit-box;
29
+ overflow: hidden;
30
+ text-overflow: ellipsis;
31
+ -webkit-line-clamp: @lines;
32
+ /* autoprefixer: ignore next */
33
+ -webkit-box-orient: vertical;
34
+ }
35
+
36
+ // ========== Flex 布局 ==========
37
+ .flex-center() {
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ }
42
+
43
+ .flex-between() {
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: space-between;
47
+ }
48
+
49
+ .flex-start() {
50
+ display: flex;
51
+ align-items: center;
52
+ justify-content: flex-start;
53
+ }
54
+
55
+ .flex-end() {
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: flex-end;
59
+ }
60
+
61
+ // ========== 绝对定位居中 ==========
62
+ .absolute-center() {
63
+ position: absolute;
64
+ top: 50%;
65
+ left: 50%;
66
+ transform: translate(-50%, -50%);
67
+ }
68
+
69
+ // ========== 1px 边框 ==========
70
+ .hairline(@direction: all, @color: @border-color-base, @radius: 0) {
71
+ position: relative;
72
+
73
+ &::after {
74
+ content: '';
75
+ position: absolute;
76
+ top: 0;
77
+ left: 0;
78
+ width: 200%;
79
+ height: 200%;
80
+ border: 0 solid @color;
81
+ transform: scale(0.5);
82
+ transform-origin: 0 0;
83
+ box-sizing: border-box;
84
+ pointer-events: none;
85
+
86
+ & when (@direction = all) {
87
+ border-width: 2rpx;
88
+ border-radius: @radius * 2;
89
+ }
90
+
91
+ & when (@direction = top) {
92
+ border-top-width: 2rpx;
93
+ }
94
+
95
+ & when (@direction = right) {
96
+ border-right-width: 2rpx;
97
+ }
98
+
99
+ & when (@direction = bottom) {
100
+ border-bottom-width: 2rpx;
101
+ }
102
+
103
+ & when (@direction = left) {
104
+ border-left-width: 2rpx;
105
+ }
106
+ }
107
+ }
108
+
109
+ // ========== 安全区域 ==========
110
+ .safe-area-top(@padding: 0) {
111
+ padding-top: calc(@padding + constant(safe-area-inset-top));
112
+ padding-top: calc(@padding + env(safe-area-inset-top));
113
+ }
114
+
115
+ .safe-area-bottom(@padding: 0) {
116
+ padding-bottom: calc(@padding + constant(safe-area-inset-bottom));
117
+ padding-bottom: calc(@padding + env(safe-area-inset-bottom));
118
+ }
119
+
120
+ // ========== 禁用状态 ==========
121
+ .disabled() {
122
+ opacity: @opacity-disabled;
123
+ cursor: not-allowed;
124
+ }
125
+
126
+ // ========== 点击态 ==========
127
+ .active-opacity(@opacity: 0.6) {
128
+ &:active {
129
+ opacity: @opacity;
130
+ }
131
+ }
132
+
133
+ // ========== 过渡动画 ==========
134
+ .transition(@property: all, @duration: @animation-duration-base, @timing: @animation-timing-function-ease) {
135
+ transition: @property @duration @timing;
136
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 色彩系统 Token
3
+ * 参考 NutUI 设计规范
4
+ */
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 色彩系统 Token
3
+ * 参考 NutUI 设计规范
4
+ */
5
+
6
+ // ========== 品牌色 ==========
7
+ @primary-color: #fa2c19; // 主色
8
+ @primary-color-light: #ff6034; // 浅主色
9
+ @primary-color-dark: #d81e06; // 深主色
10
+
11
+ // ========== 功能色 ==========
12
+ @success-color: #1ba784; // 成功
13
+ @warning-color: #ff8800; // 警告
14
+ @danger-color: #fa2c19; // 危险
15
+ @info-color: #3460fa; // 信息
16
+
17
+ // ========== 中性色 ==========
18
+ @gray-1: #f7f8fa; // 浅灰色-1
19
+ @gray-2: #f2f3f5; // 浅灰色-2
20
+ @gray-3: #e5e6eb; // 浅灰色-3
21
+ @gray-4: #dcdee3; // 浅灰色-4
22
+ @gray-5: #c5c6cc; // 灰色-5
23
+ @gray-6: #a8abb2; // 灰色-6
24
+ @gray-7: #888b94; // 深灰色-7
25
+ @gray-8: #6c6f7a; // 深灰色-8
26
+ @gray-9: #494d56; // 深灰色-9
27
+ @gray-10: #1a1c24; // 深灰色-10
28
+
29
+ // ========== 文本色 ==========
30
+ @text-color-primary: #1a1c24; // 主要文本
31
+ @text-color-secondary: #494d56; // 次要文本
32
+ @text-color-tertiary: #888b94; // 三级文本
33
+ @text-color-disabled: #c5c6cc; // 禁用文本
34
+ @text-color-inverse: #ffffff; // 反色文本
35
+
36
+ // ========== 背景色 ==========
37
+ @bg-color-page: #f7f8fa; // 页面背景
38
+ @bg-color-container: #ffffff; // 容器背景
39
+ @bg-color-overlay: rgba(0, 0, 0, 0.7); // 遮罩背景
40
+ @bg-color-disabled: #f2f3f5; // 禁用背景
41
+
42
+ // ========== 边框色 ==========
43
+ @border-color-base: #e5e6eb; // 基础边框
44
+ @border-color-light: #f2f3f5; // 浅色边框
45
+ @border-color-dark: #dcdee3; // 深色边框
46
+
47
+ // ========== 链接色 ==========
48
+ @link-color: #3460fa; // 链接颜色
49
+ @link-hover-color: #5a7eff; // 链接悬停颜色
50
+ @link-active-color: #2347d9; // 链接激活颜色
51
+
52
+ // ========== 白色和黑色 ==========
53
+ @white: #ffffff;
54
+ @black: #000000;
@@ -0,0 +1,3 @@
1
+ /**
2
+ * 通用变量 Token
3
+ */
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 通用变量 Token
3
+ */
4
+
5
+ // ========== 圆角 ==========
6
+ @border-radius-none: 0;
7
+ @border-radius-sm: 4rpx; // 2px
8
+ @border-radius-base: 8rpx; // 4px
9
+ @border-radius-md: 12rpx; // 6px
10
+ @border-radius-lg: 16rpx; // 8px
11
+ @border-radius-xl: 24rpx; // 12px
12
+ @border-radius-2xl: 32rpx; // 16px
13
+ @border-radius-round: 9999rpx; // 圆形
14
+ @border-radius-circle: 50%; // 圆形百分比
15
+
16
+ // ========== 边框宽度 ==========
17
+ @border-width-none: 0;
18
+ @border-width-thin: 1rpx; // 0.5px
19
+ @border-width-base: 2rpx; // 1px
20
+ @border-width-thick: 4rpx; // 2px
21
+
22
+ // ========== 阴影 ==========
23
+ @box-shadow-none: none;
24
+ @box-shadow-sm: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
25
+ @box-shadow-base: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
26
+ @box-shadow-md: 0 8rpx 24rpx rgba(0, 0, 0, 0.1);
27
+ @box-shadow-lg: 0 12rpx 32rpx rgba(0, 0, 0, 0.12);
28
+ @box-shadow-xl: 0 16rpx 48rpx rgba(0, 0, 0, 0.15);
29
+
30
+ // ========== 层级 (z-index) ==========
31
+ @z-index-base: 1;
32
+ @z-index-dropdown: 1000;
33
+ @z-index-sticky: 1020;
34
+ @z-index-fixed: 1030;
35
+ @z-index-modal-backdrop: 1040;
36
+ @z-index-modal: 1050;
37
+ @z-index-popover: 1060;
38
+ @z-index-tooltip: 1070;
39
+ @z-index-toast: 1080;
40
+
41
+ // ========== 动画时长 ==========
42
+ @animation-duration-fast: 150ms;
43
+ @animation-duration-base: 300ms;
44
+ @animation-duration-slow: 500ms;
45
+
46
+ // ========== 动画曲线 ==========
47
+ @animation-timing-function-ease: ease;
48
+ @animation-timing-function-ease-in: ease-in;
49
+ @animation-timing-function-ease-out: ease-out;
50
+ @animation-timing-function-ease-in-out: ease-in-out;
51
+ @animation-timing-function-linear: linear;
52
+
53
+ // ========== 透明度 ==========
54
+ @opacity-disabled: 0.4;
55
+ @opacity-loading: 0.6;
56
+ @opacity-overlay: 0.7;
57
+
58
+ // ========== 组件尺寸 ==========
59
+ @height-xs: 48rpx; // 24px
60
+ @height-sm: 56rpx; // 28px
61
+ @height-base: 64rpx; // 32px
62
+ @height-md: 80rpx; // 40px
63
+ @height-lg: 96rpx; // 48px
64
+ @height-xl: 112rpx; // 56px
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 间距系统 Token
3
+ * 基础单位: 4px (8rpx)
4
+ */
@@ -0,0 +1,38 @@
1
+ /**
2
+ * 间距系统 Token
3
+ * 基础单位: 4px (8rpx)
4
+ */
5
+
6
+ // ========== 基础间距单位 ==========
7
+ @spacing-unit: 8rpx; // 4px
8
+
9
+ // ========== Padding ==========
10
+ @padding-xs: 8rpx; // 4px
11
+ @padding-sm: 16rpx; // 8px
12
+ @padding-base: 24rpx; // 12px
13
+ @padding-md: 32rpx; // 16px
14
+ @padding-lg: 48rpx; // 24px
15
+ @padding-xl: 64rpx; // 32px
16
+ @padding-2xl: 96rpx; // 48px
17
+
18
+ // ========== Margin ==========
19
+ @margin-xs: 8rpx; // 4px
20
+ @margin-sm: 16rpx; // 8px
21
+ @margin-base: 24rpx; // 12px
22
+ @margin-md: 32rpx; // 16px
23
+ @margin-lg: 48rpx; // 24px
24
+ @margin-xl: 64rpx; // 32px
25
+ @margin-2xl: 96rpx; // 48px
26
+
27
+ // ========== 组件内边距 ==========
28
+ @padding-h-xs: 16rpx; // 水平内边距-xs
29
+ @padding-h-sm: 24rpx; // 水平内边距-sm
30
+ @padding-h-base: 32rpx; // 水平内边距-base
31
+ @padding-h-md: 40rpx; // 水平内边距-md
32
+ @padding-h-lg: 48rpx; // 水平内边距-lg
33
+
34
+ @padding-v-xs: 8rpx; // 垂直内边距-xs
35
+ @padding-v-sm: 16rpx; // 垂直内边距-sm
36
+ @padding-v-base: 24rpx; // 垂直内边距-base
37
+ @padding-v-md: 32rpx; // 垂直内边距-md
38
+ @padding-v-lg: 40rpx; // 垂直内边距-lg
@@ -0,0 +1,3 @@
1
+ /**
2
+ * 字体系统 Token
3
+ */
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 字体系统 Token
3
+ */
4
+
5
+ // ========== 字体族 ==========
6
+ @font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
7
+ 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
8
+ 'Noto Color Emoji';
9
+ @font-family-number: 'Helvetica Neue', Helvetica, Arial, sans-serif;
10
+
11
+ // ========== 字号 ==========
12
+ @font-size-xs: 20rpx; // 10px
13
+ @font-size-sm: 24rpx; // 12px
14
+ @font-size-base: 28rpx; // 14px
15
+ @font-size-md: 32rpx; // 16px
16
+ @font-size-lg: 36rpx; // 18px
17
+ @font-size-xl: 40rpx; // 20px
18
+ @font-size-2xl: 48rpx; // 24px
19
+ @font-size-3xl: 56rpx; // 28px
20
+ @font-size-4xl: 64rpx; // 32px
21
+
22
+ // ========== 字重 ==========
23
+ @font-weight-light: 300;
24
+ @font-weight-normal: 400;
25
+ @font-weight-medium: 500;
26
+ @font-weight-semibold: 600;
27
+ @font-weight-bold: 700;
28
+
29
+ // ========== 行高 ==========
30
+ @line-height-xs: 1.2;
31
+ @line-height-sm: 1.4;
32
+ @line-height-base: 1.5;
33
+ @line-height-md: 1.6;
34
+ @line-height-lg: 1.8;
35
+ @line-height-xl: 2;