officialblock 1.0.7 → 1.0.9

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.
Files changed (103) hide show
  1. package/dist/index-Ch_ldWmA.js +1 -0
  2. package/dist/index-DXm2cqxo.mjs +485 -0
  3. package/dist/official-block.cjs.js +74 -74
  4. package/dist/official-block.es.js +13608 -10831
  5. package/dist/official-block.umd.js +78 -78
  6. package/dist/style.css +1 -1
  7. package/dist/swiper-JiLDDxAF.js +1 -0
  8. package/dist/swiper-acbnDJoL.mjs +2035 -0
  9. package/dist/utils-DD-vVZej.mjs +316 -0
  10. package/dist/utils-DOLLD0-F.js +1 -0
  11. package/package.json +2 -1
  12. package/src/assets/icon-email.svg +3 -0
  13. package/src/components/ArticleList/article.vue +3 -3
  14. package/src/components/ArticleList/contact.vue +9 -9
  15. package/src/components/ArticleList/index.ts +1 -1
  16. package/src/components/ArticleList/index.vue +22 -80
  17. package/src/components/ArticleList/setting.vue +339 -175
  18. package/src/components/ArticleList/type.ts +12 -18
  19. package/src/components/BannerImage/index.ts +11 -0
  20. package/src/components/BannerImage/index.vue +153 -0
  21. package/src/components/BannerImage/setting.vue +55 -0
  22. package/src/components/BannerImage/type.ts +10 -0
  23. package/src/components/BannerImageWithLink/index.ts +11 -0
  24. package/src/components/BannerImageWithLink/index.vue +323 -0
  25. package/src/components/BannerImageWithLink/setting.vue +344 -0
  26. package/src/components/BannerImageWithLink/type.ts +17 -0
  27. package/src/components/BannerPage/index.ts +11 -0
  28. package/src/components/BannerPage/index.vue +283 -0
  29. package/src/components/BannerPage/setting.vue +55 -0
  30. package/src/components/BannerPage/type.ts +10 -0
  31. package/src/components/BtnList/index.ts +11 -0
  32. package/src/components/BtnList/index.vue +588 -0
  33. package/src/components/BtnList/setting.vue +255 -0
  34. package/src/components/BtnList/type.ts +10 -0
  35. package/src/components/Button/index.vue +45 -33
  36. package/src/components/ContactUsList/index.ts +11 -0
  37. package/src/components/ContactUsList/index.vue +369 -0
  38. package/src/components/ContactUsList/setting.vue +497 -0
  39. package/src/components/ContactUsList/type.ts +17 -0
  40. package/src/components/CountDown/index.ts +11 -0
  41. package/src/components/CountDown/index.vue +315 -0
  42. package/src/components/CountDown/setting.vue +302 -0
  43. package/src/components/CountDown/type.ts +17 -0
  44. package/src/components/CustomIframe/index.ts +11 -0
  45. package/src/components/CustomIframe/index.vue +118 -0
  46. package/src/components/CustomIframe/setting.vue +323 -0
  47. package/src/components/CustomIframe/type.ts +17 -0
  48. package/src/components/CustomSpace/index.ts +11 -0
  49. package/src/components/CustomSpace/index.vue +82 -0
  50. package/src/components/CustomSpace/setting.vue +89 -0
  51. package/src/components/CustomSpace/type.ts +10 -0
  52. package/src/components/GalleryList/index.ts +12 -0
  53. package/src/components/GalleryList/index.vue +311 -0
  54. package/src/components/GalleryList/setting.vue +268 -0
  55. package/src/components/GalleryList/type.ts +10 -0
  56. package/src/components/HeroSlide/index.ts +1 -1
  57. package/src/components/HeroSlide/index.vue +85 -133
  58. package/src/components/HeroSlide/setting.vue +435 -0
  59. package/src/components/HeroSlide/type.ts +5 -14
  60. package/src/components/LinkLIst/index.ts +11 -0
  61. package/src/components/LinkLIst/index.vue +317 -0
  62. package/src/components/LinkLIst/setting.vue +264 -0
  63. package/src/components/LinkLIst/type.ts +10 -0
  64. package/src/components/Media/index.vue +18 -18
  65. package/src/components/Operate/index.vue +17 -8
  66. package/src/components/Profile/index.vue +999 -0
  67. package/src/components/Profile/modal.vue +56 -0
  68. package/src/components/Profile/setting.vue +330 -0
  69. package/src/components/QuickLinks/index.vue +166 -0
  70. package/src/components/QuoteText/index.ts +11 -0
  71. package/src/components/QuoteText/index.vue +133 -0
  72. package/src/components/QuoteText/setting.vue +81 -0
  73. package/src/components/QuoteText/type.ts +10 -0
  74. package/src/components/ScrollKeyInfo/index.ts +11 -0
  75. package/src/components/ScrollKeyInfo/index.vue +1345 -0
  76. package/src/components/ScrollKeyInfo/setting.vue +302 -0
  77. package/src/components/ScrollKeyInfo/type.ts +17 -0
  78. package/src/components/Swiper/index.vue +538 -0
  79. package/src/components/TabDefault/components/ComponentSelector/compsData.js +143 -0
  80. package/src/components/TabDefault/components/ComponentSelector/index.vue +188 -0
  81. package/src/components/TabDefault/components/PageContent.vue +207 -0
  82. package/src/components/TabDefault/index.vue +475 -0
  83. package/src/components/TabDefault/setting.vue +581 -0
  84. package/src/components/TabDefault/type.ts +17 -0
  85. package/src/components/TableTwo/index.ts +11 -0
  86. package/src/components/TableTwo/index.vue +232 -0
  87. package/src/components/TableTwo/setting.vue +558 -0
  88. package/src/components/TableTwo/type.ts +17 -0
  89. package/src/components/index.ts +40 -5
  90. package/src/index.ts +56 -12
  91. package/src/main.ts +6 -3
  92. package/src/router/index.ts +6 -0
  93. package/src/style.css +17 -0
  94. package/src/styles/component-isolation.scss +257 -0
  95. package/src/styles/editor.scss +1 -1
  96. package/src/styles/layers.scss +256 -0
  97. package/src/styles/main.scss +21687 -0
  98. package/src/styles/mixins/style-isolation.scss +262 -0
  99. package/src/styles/smart-reset.scss +287 -0
  100. package/src/styles/test.scss +1 -1
  101. package/src/types/button.ts +10 -0
  102. package/src/views/StyleIsolationTest.vue +292 -0
  103. package/src/views/components/ArticleListDemo.vue +59 -19
@@ -0,0 +1,188 @@
1
+ <template>
2
+ <a-modal v-model:visible="visible" title="添加组件" width="90%" :footer="false">
3
+ <a-layout class="component-library-container" style="display: flex">
4
+ <!-- 左侧导航栏 -->
5
+ <a-layout-sider :width="240" :style="{ background: '#fff', boxShadow: '0 2px 8px rgba(0, 0, 0, 0.08)' }">
6
+ <div class="search-box">
7
+ <a-input-search placeholder="Search components..." />
8
+ </div>
9
+ <a-menu v-model:selected-keys="selectedKeys" :style="{ height: '100%', borderRight: 0 }">
10
+ <a-menu-item v-for="item in menuData" :key="item.key">
11
+ {{ item.label }}
12
+ </a-menu-item>
13
+ </a-menu>
14
+ </a-layout-sider>
15
+
16
+ <!-- 右侧内容区 -->
17
+ <a-layout-content :style="{ padding: '24px 40px 24px 24px', background: '#f5f5f5' }">
18
+ <div class="component-section">
19
+ <h2 class="section-title">{{ currentSection.label }}</h2>
20
+ <p class="section-description">{{ currentSection.description }}</p>
21
+
22
+ <div class="component-grid">
23
+ <div
24
+ v-for="(component, index) in currentComponents"
25
+ :key="index"
26
+ class="component-card"
27
+ @click="selectComponent(component)"
28
+ >
29
+ <div class="thumbnail-placeholder">
30
+ <!-- 这里应该是实际缩略图,示例使用占位色块 -->
31
+ <div class="thumbnail-color" :style="{ backgroundColor: getRandomColor() }">
32
+ <!-- <component :is="getComponetnBytype(component.label)" v-model:model-value="componentValues[component.label]" /> -->
33
+ <!-- <ArticleList v-model:model-value="test" /> -->
34
+ </div>
35
+ </div>
36
+ <div class="component-name">{{ component.label }}</div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </a-layout-content>
41
+ </a-layout>
42
+ <!-- <ArticleList v-model:model-value="test" /> -->
43
+ </a-modal>
44
+ </template>
45
+
46
+ <script setup>
47
+ import { reactive, ref, computed, watch } from "vue"; // 添加 reactive 导入
48
+
49
+ // import * as allPageComponents from "officialblock";
50
+ import { compJsonData } from "./compsData";
51
+ import { randomString } from "@/utils/common";
52
+
53
+ // 接收 props
54
+ const props = defineProps({
55
+ visible: {
56
+ type: Boolean,
57
+ default: false,
58
+ },
59
+ });
60
+
61
+ // 定义事件
62
+ const emit = defineEmits(["update:visible", "ok", "cancel"]);
63
+
64
+ // 初始化组件映射
65
+ // const componentMap = allPageComponents;
66
+
67
+ // 响应式数据
68
+ const componentValues = reactive({});
69
+ const selectedKeys = ref(["common"]);
70
+ const menuData = ref(compJsonData);
71
+ const currentSection = ref({});
72
+ const currentComponents = computed(() => currentSection.value.children || []);
73
+
74
+ // 初始化 componentValues
75
+ watch(
76
+ currentComponents,
77
+ (newComponents) => {
78
+ newComponents.forEach((comp) => {
79
+ if (!componentValues[comp.label]) {
80
+ componentValues[comp.label] = null;
81
+ }
82
+ });
83
+ },
84
+ { immediate: true }
85
+ );
86
+
87
+ // 监听菜单选择
88
+ watch(
89
+ selectedKeys,
90
+ (newValue) => {
91
+ currentSection.value = menuData.value.find((item) => item.key === newValue[0]) || {};
92
+ },
93
+ { immediate: true }
94
+ );
95
+
96
+ // 获取组件方法
97
+
98
+ // 选择组件
99
+ const selectComponent = (comp) => {
100
+ debugger;
101
+ // emit('ok', JSON.parse(JSON.stringify(componentValues[val])))
102
+ emit("ok", JSON.parse(JSON.stringify({ type: comp.label, id: randomString() })));
103
+ };
104
+
105
+ // 同步 visible 状态
106
+ const visible = computed({
107
+ get: () => props.visible,
108
+ set: (val) => emit("update:visible", val),
109
+ });
110
+
111
+ // 生成随机颜色用于缩略图占位
112
+ const getRandomColor = () => {
113
+ const colors = ["#3498db", "#2ecc71", "#e74c3c", "#f1c40f", "#9b59b6", "#1abc9c"];
114
+ return colors[Math.floor(Math.random() * colors.length)];
115
+ };
116
+ </script>
117
+
118
+ <style lang="scss" scoped>
119
+ .component-library-container {
120
+ height: 80vh;
121
+ background: #f5f5f5;
122
+ }
123
+
124
+ .search-box {
125
+ padding: 16px;
126
+ }
127
+
128
+ .component-section {
129
+ max-width: 1200px;
130
+ margin: 0 auto;
131
+ }
132
+
133
+ .section-title {
134
+ font-size: 24px;
135
+ margin-bottom: 8px;
136
+ color: #1d2129;
137
+ }
138
+
139
+ .section-description {
140
+ color: #666;
141
+ margin-bottom: 24px;
142
+ }
143
+
144
+ .component-grid {
145
+ display: grid;
146
+ grid-template-columns: repeat(3, 1fr);
147
+ gap: 24px;
148
+ }
149
+
150
+ .component-card {
151
+ background: #fff;
152
+ cursor: pointer;
153
+ border-radius: 8px;
154
+ overflow: hidden;
155
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
156
+ transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
157
+ position: relative;
158
+ z-index: 1;
159
+ /* 直接集成悬停效果 */
160
+ &:hover {
161
+ transform: scale(1.2);
162
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
163
+ z-index: 2;
164
+ .thumbnail-placeholder {
165
+ transform: translateZ(20px);
166
+ }
167
+ }
168
+ }
169
+
170
+ .thumbnail-placeholder {
171
+ height: 180px;
172
+ position: relative;
173
+ overflow: hidden;
174
+ }
175
+
176
+ .thumbnail-color {
177
+ width: 100%;
178
+ height: 100%;
179
+ }
180
+
181
+ .component-name {
182
+ padding: 16px;
183
+ text-align: center;
184
+ font-weight: 500;
185
+ color: #333;
186
+ border-top: 1px solid #eee;
187
+ }
188
+ </style>
@@ -0,0 +1,207 @@
1
+ <template>
2
+ <div class="page-content">
3
+ <!-- 判断 pageJsonData 是否有数据 -->
4
+ <div v-if="pageJsonData && pageJsonData.length > 0">
5
+ <draggable
6
+ v-model="pageJsonData"
7
+ :component-data="{
8
+ tag: 'div',
9
+ type: 'transition-group',
10
+ name: !drag ? 'flip-list' : null,
11
+ }"
12
+ v-bind="buttonDragOptions"
13
+ :disabled="!shouldShowDragHandle(pageJsonData)"
14
+ @start="drag = true"
15
+ @end="dragEnd"
16
+ item-key="id"
17
+ >
18
+ <template #item="{ element: component, index }">
19
+ <div
20
+ class="item-button draggable-item component-wrapper"
21
+ :class="{ 'sortable-disabled': !shouldShowDragHandle(pageJsonData) }"
22
+ :key="component.id"
23
+ >
24
+ <component
25
+ :is="getComponetnBytype(component.type)"
26
+ :model-value="component"
27
+ @update:model-value="($event) => updateComponentValue(index, $event)"
28
+ />
29
+ <div class="add-btn">
30
+ <a-button type="primary" @click="addComponent(index)">
31
+ <template #icon>
32
+ <icon-plus />
33
+ </template>
34
+ Add Component
35
+ </a-button>
36
+ </div>
37
+ </div>
38
+ </template>
39
+ </draggable>
40
+ <!-- <a-button type="primary" class="add-component-btn" @click="addComponent"> 添加组件 </a-button> -->
41
+
42
+ <!-- <div v-for="(component, index) in pageJsonData" :key="component.id" class="page-item">
43
+ <div class="component-wrapper">
44
+ <component
45
+ :is="getComponetnBytype(component.type)"
46
+ :model-value="component"
47
+ @update:model-value="($event) => updateComponentValue(index, $event)"
48
+ />
49
+ <div class="add-btn">
50
+ <a-button type="primary" @click="addComponent(index)">
51
+ <template #icon>
52
+ <icon-plus />
53
+ </template>
54
+ Add Component
55
+ </a-button>
56
+ </div>
57
+ </div>
58
+ </div> -->
59
+ </div>
60
+
61
+ <div v-else>
62
+ <!-- 使用 Arco Design 的按钮 -->
63
+ <a-button type="primary" class="add-component-btn" @click="addComponent"> 添加组件 </a-button>
64
+ </div>
65
+
66
+ <component-selector v-model:visible="visible" @ok="addComponentToPage" />
67
+ </div>
68
+ </template>
69
+
70
+ <script setup>
71
+ // import * as allPageComponents from "officialblock";
72
+ import { ref, watch, computed, defineAsyncComponent } from "vue";
73
+ import componentSelector from "./ComponentSelector/index.vue";
74
+ import draggable from "vuedraggable";
75
+
76
+ // 拖拽相关状态
77
+ const drag = ref(false);
78
+
79
+ // 接收外部传入的数据
80
+ const props = defineProps({
81
+ data: {
82
+ type: Array,
83
+ default: () => [],
84
+ },
85
+ });
86
+
87
+ const emit = defineEmits(["update"]);
88
+
89
+ // 动态导入components目录下的所有组件
90
+ const modules = import.meta.glob("@/components/*/index.vue", { eager: false });
91
+
92
+ const componentMap = {};
93
+
94
+ // 遍历并注册组件
95
+ // 遍历并注册组件,使用文件夹名称作为组件名
96
+ for (const path in modules) {
97
+ debugger;
98
+ try {
99
+ // 正确提取文件夹名称
100
+ const pathParts = path.split("/");
101
+ const folderName = pathParts[pathParts.length - 2]; // 文件夹名称
102
+ console.log(`注册组件: ${folderName} from ${path}`); // 调试信息
103
+ componentMap[folderName] = defineAsyncComponent(modules[path]);
104
+ } catch (error) {
105
+ console.error("组件注册失败:", path, error);
106
+ }
107
+ }
108
+ const getComponetnBytype = (type) => {
109
+ debugger;
110
+ return componentMap[type];
111
+ };
112
+
113
+ // const componentMap = allPageComponents;
114
+ const visible = ref(false);
115
+ const selectComponentIndex = ref(0);
116
+
117
+ // 响应式数据
118
+ const pageJsonData = ref([...props.data]);
119
+
120
+ // 当外部 modelValue 变化时,同步更新本地数据
121
+ watch(
122
+ () => props.data,
123
+ (newVal) => {
124
+ debugger;
125
+ pageJsonData.value = [...newVal];
126
+ },
127
+ { deep: true }
128
+ );
129
+
130
+ const buttonDragOptions = computed(() => ({
131
+ animation: 200,
132
+ group: "buttons", // 按钮专用分组
133
+ disabled: false,
134
+ ghostClass: "ghost",
135
+ }));
136
+
137
+ // 检查是否应该显示拖拽图标
138
+ const shouldShowDragHandle = (list) => {
139
+ return list && list.length > 1;
140
+ };
141
+
142
+ // 添加组件的方法
143
+ const addComponent = (index = 0) => {
144
+ selectComponentIndex.value = index;
145
+ visible.value = true;
146
+ };
147
+
148
+ const updateComponentValue = (index, value) => {
149
+ pageJsonData.value[index] = value;
150
+ emit("update", [...pageJsonData.value]);
151
+
152
+ console.log("组件更新:", pageJsonData.value);
153
+ };
154
+ const dragEnd = () => {
155
+ drag.value = false;
156
+ emit("update", [...pageJsonData.value]);
157
+ };
158
+
159
+ // 弹框添加
160
+ const addComponentToPage = (json) => {
161
+ visible.value = false; // 手动将新对象转为响应式对象
162
+ pageJsonData.value.splice(selectComponentIndex.value + 1, 0, json);
163
+ emit("update", [...pageJsonData.value]);
164
+ };
165
+ </script>
166
+
167
+ <style lang="scss" scoped>
168
+ .page-content {
169
+ // height: 100%;
170
+ min-height: 500px;
171
+ display: flex;
172
+ flex-direction: column;
173
+ align-items: center;
174
+ justify-content: center;
175
+ padding: 30px 0 50px;
176
+
177
+ // .page-item {
178
+ // min-width: none;
179
+ // height: 100%;
180
+
181
+ .component-wrapper {
182
+ position: relative;
183
+
184
+ &:hover {
185
+ border: 2px solid #409eff;
186
+
187
+ .add-btn {
188
+ display: block;
189
+ }
190
+ }
191
+
192
+ .add-btn {
193
+ display: none;
194
+ position: absolute;
195
+ left: 50%;
196
+ bottom: 0;
197
+ transform: translate(-50%, 50%);
198
+ }
199
+ }
200
+ // }
201
+
202
+ .add-component-btn {
203
+ padding: 12px 24px;
204
+ font-size: 16px;
205
+ }
206
+ }
207
+ </style>