@ikun2274/spiritechoui 0.1.50 → 0.1.60
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 +1 -1
- package/readme.md +8 -4
- package/src/components/Navigation/TabPane.vue +45 -0
- package/src/components/Navigation/Tabs.vue +80 -0
- package/src/registerComponents.js +19 -11
- package/src/type/global.d.ts +3 -3
- package/src/type/types.ts +13 -0
- /package/src/components/{Button.vue → Basic/Button.vue} +0 -0
- /package/src/components/{SPEBlock.vue → Tool/SPEBlock.vue} +0 -0
- /package/src/components/{SpInput.vue → form/SpInput.vue} +0 -0
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -20,11 +20,15 @@ npm uninstall @ikun2274/spiritechoui
|
|
|
20
20
|
|
|
21
21
|
#### 0.1.3 (2025-11-06-13:25)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
### 0.1.51 (2036-2-14 11:17)
|
|
24
|
+
```
|
|
25
|
+
更新了代码块组件
|
|
26
|
+
```
|
|
27
|
+
### 0.1.60 (2036-2-14 15:57)
|
|
28
|
+
```
|
|
29
|
+
更新了Tab&TabPane
|
|
30
|
+
```
|
|
24
31
|
|
|
25
32
|
## 后续规划
|
|
26
33
|
|
|
27
34
|
|
|
28
|
-
#### v0.2.x:新增表单组件(输入框、选择器等),完善按钮与表单的联动。
|
|
29
|
-
#### v0.3.x:补充布局工具类,支持更灵活的响应式场景。
|
|
30
|
-
#### v0.4.x:还不知道
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="activeName === name" class="tab-pane">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { inject, onMounted } from 'vue';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: 'TabPane',
|
|
12
|
+
props: {
|
|
13
|
+
name: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
setup(props) {
|
|
23
|
+
const TabsContext = inject('TabsContext');
|
|
24
|
+
const activeName = TabsContext.activeName;
|
|
25
|
+
|
|
26
|
+
// 挂载时注册到 Tabs
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
TabsContext.addPane({
|
|
29
|
+
name: props.name,
|
|
30
|
+
label: props.label
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
activeName
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style scoped>
|
|
42
|
+
.tab-pane {
|
|
43
|
+
/* 可自定义内容区样式 */
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="tabs">
|
|
3
|
+
<div class="tabs-header">
|
|
4
|
+
<div
|
|
5
|
+
v-for="pane in panes"
|
|
6
|
+
:key="pane.name"
|
|
7
|
+
:class="['tab-item', { active: modelValue === pane.name }]"
|
|
8
|
+
@click="handleTabClick(pane.name)"
|
|
9
|
+
>
|
|
10
|
+
{{ pane.label }}
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="tabs-content">
|
|
14
|
+
<slot></slot>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import { ref, provide, computed } from 'vue';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
name: 'Tabs',
|
|
24
|
+
props: {
|
|
25
|
+
modelValue: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
emits: ['update:modelValue'],
|
|
31
|
+
setup(props, { emit }) {
|
|
32
|
+
const panes = ref([]);
|
|
33
|
+
|
|
34
|
+
// 提供给子组件的注册方法
|
|
35
|
+
const addPane = (pane) => {
|
|
36
|
+
panes.value.push(pane);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// 共享激活状态
|
|
40
|
+
const activeName = computed(() => props.modelValue);
|
|
41
|
+
provide('TabsContext', {
|
|
42
|
+
activeName,
|
|
43
|
+
addPane
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// 点击切换标签
|
|
47
|
+
const handleTabClick = (name) => {
|
|
48
|
+
emit('update:modelValue', name);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
panes,
|
|
53
|
+
handleTabClick
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<style scoped>
|
|
60
|
+
.tabs {
|
|
61
|
+
border: 1px solid #e4e7ed;
|
|
62
|
+
border-radius: 4px;
|
|
63
|
+
}
|
|
64
|
+
.tabs-header {
|
|
65
|
+
display: flex;
|
|
66
|
+
border-bottom: 1px solid #e4e7ed;
|
|
67
|
+
}
|
|
68
|
+
.tab-item {
|
|
69
|
+
padding: 10px 20px;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
border-bottom: 2px solid transparent;
|
|
72
|
+
}
|
|
73
|
+
.tab-item.active {
|
|
74
|
+
border-bottom-color: #409eff;
|
|
75
|
+
color: #409eff;
|
|
76
|
+
}
|
|
77
|
+
.tabs-content {
|
|
78
|
+
padding: 20px;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
// 组件库内部的 registerComponents.js 示例
|
|
2
2
|
import MyUI from './MyUI';
|
|
3
3
|
import ComponentInjector from './ComponentInjector';
|
|
4
|
-
|
|
5
4
|
//引入组件
|
|
6
|
-
import speButton from './components/Button.vue';
|
|
7
|
-
import speinput from './components/SpInput.vue';
|
|
5
|
+
import speButton from './components/Basic/Button.vue';
|
|
6
|
+
import speinput from './components/form/SpInput.vue';
|
|
8
7
|
import speblock from './components/SPEBlock.vue'
|
|
9
8
|
|
|
10
|
-
const injector = new ComponentInjector(MyUI);
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
import speTabs from './components/Navigation/Tabs.vue'
|
|
11
|
+
import speTabPane from './components/Navigation/TabPane.vue'
|
|
12
|
+
|
|
13
|
+
/////////////////
|
|
14
|
+
const injector = new ComponentInjector(MyUI);
|
|
15
|
+
injector.register('basic', 'speButton', speButton, {
|
|
13
16
|
type: 'default',
|
|
14
17
|
size: 'medium'
|
|
15
18
|
});
|
|
16
|
-
|
|
19
|
+
|
|
17
20
|
injector.register('form', 'speinput', speinput);
|
|
18
21
|
injector.register('tool', 'speblock', speblock);
|
|
19
|
-
|
|
20
22
|
//Spirit EchoUI
|
|
23
|
+
injector.register('navigation', 'speTabs', speTabs);
|
|
24
|
+
injector.register('navigation', 'speTabPane', speTabPane);
|
|
25
|
+
|
|
26
|
+
|
|
21
27
|
|
|
22
|
-
//全局激活组件
|
|
23
28
|
|
|
29
|
+
|
|
30
|
+
//全局激活组件
|
|
24
31
|
MyUI.install = (app) => {
|
|
25
|
-
app.component('SPE-Button', MyUI.
|
|
32
|
+
app.component('SPE-Button', MyUI.basic.speButton({}));
|
|
26
33
|
app.component('SPE-Input', MyUI.form.speinput({}));
|
|
27
|
-
app.component('SPE-Block', MyUI.tool.speblock({})
|
|
28
|
-
);
|
|
34
|
+
app.component('SPE-Block', MyUI.tool.speblock({}));
|
|
29
35
|
|
|
36
|
+
app.component('SPE-Tabs', MyUI.navigation.speTabs({}));
|
|
37
|
+
app.component('SPE-TabPane', MyUI.navigation.speTabPane({}));
|
|
30
38
|
|
|
31
39
|
};
|
|
32
40
|
|
package/src/type/global.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/types/global.d.ts
|
|
2
|
-
import { SpInput } from "../components/SpInput.vue";
|
|
3
|
-
import { Button } from "../components/Button.vue"; // 若有其他组件也需声明
|
|
2
|
+
import { SpInput } from "../components/form/SpInput.vue";
|
|
3
|
+
import { Button } from "../components/Basic/Button.vue"; // 若有其他组件也需声明
|
|
4
4
|
|
|
5
5
|
declare module "vue" {
|
|
6
6
|
export interface GlobalComponents {
|
|
7
7
|
SpInput: typeof SpInput;
|
|
8
8
|
Button: typeof Button;
|
|
9
9
|
}
|
|
10
|
-
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// types.ts
|
|
2
|
+
export interface TabPaneProps {
|
|
3
|
+
name: string; // 唯一标识
|
|
4
|
+
label: string; // 标签文本
|
|
5
|
+
disabled?: boolean; // 是否禁用
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TabsProvide {
|
|
9
|
+
activeName: import("vue").ComputedRef<string>; // 当前激活的标签名
|
|
10
|
+
changeTab: (name: string) => void; // 切换标签方法
|
|
11
|
+
addPane: (pane: TabPaneProps) => void; // 注册子组件
|
|
12
|
+
removePane: (name: string) => void; // 注销子组件
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|