@opendesign-plus/components 0.0.1-rc.6 → 0.0.1-rc.7

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 (162) hide show
  1. package/dist/chunk-OElCookieNotice.cjs.js +1 -0
  2. package/dist/chunk-OElCookieNotice.es.js +281 -0
  3. package/dist/components/OFooter.vue.d.ts +25 -0
  4. package/dist/components/OHeader.vue.d.ts +23 -0
  5. package/dist/components/OHeaderMoblie.vue.d.ts +33 -0
  6. package/dist/components/OHeaderUser.vue.d.ts +40 -0
  7. package/dist/components/OSourceCode.vue.d.ts +20 -0
  8. package/dist/components/events/OEventsApply.vue.d.ts +16 -0
  9. package/dist/components/events/OEventsCalendar.vue.d.ts +5 -0
  10. package/dist/components/events/OEventsList.vue.d.ts +26 -0
  11. package/dist/components/events/config.d.ts +26 -0
  12. package/dist/components/events/index.d.ts +78 -0
  13. package/dist/components/events/types.d.ts +66 -0
  14. package/dist/components/events/utils.d.ts +7 -0
  15. package/dist/components.cjs.js +3 -1
  16. package/dist/components.css +1 -1
  17. package/dist/components.element.cjs.js +1 -1
  18. package/dist/components.element.es.js +2 -214
  19. package/dist/components.es.js +3000 -444
  20. package/dist/index.d.ts +8 -1
  21. package/docs/design.md +27 -27
  22. package/docs/design_banner.md +41 -41
  23. package/docs/design_section.md +27 -27
  24. package/npmcachae/_cacache/content-v2/sha512/bd/56/25079ffb18446953f88fc063c3d6eaf7191772851b8477c118f113b920a7f357b67b9006181af58c9f68b0059b899ad0f2c86fe0a6490958d138cb063afd +1 -0
  25. package/npmcachae/_cacache/index-v5/d8/49/af4c6bb8f580edbd7b6e18db381844403e5f689a9849c5ffcdd2dd95d735 +3 -0
  26. package/npmcachae/_logs/2026-03-17T09_38_12_009Z-debug-0.log +157 -0
  27. package/npmcachae/_logs/2026-03-17T09_38_14_370Z-debug-0.log +157 -0
  28. package/npmcachae/_logs/2026-03-17T09_38_16_516Z-debug-0.log +157 -0
  29. package/npmcachae/_logs/2026-03-17T09_38_18_616Z-debug-0.log +157 -0
  30. package/npmcachae/_logs/2026-03-17T09_38_20_859Z-debug-0.log +157 -0
  31. package/npmcachae/_logs/2026-03-17T09_38_23_182Z-debug-0.log +157 -0
  32. package/npmcachae/_logs/2026-03-17T09_38_25_452Z-debug-0.log +157 -0
  33. package/npmcachae/_logs/2026-03-17T09_38_27_865Z-debug-0.log +157 -0
  34. package/npmcachae/_logs/2026-03-17T09_38_30_082Z-debug-0.log +157 -0
  35. package/npmcachae/_logs/2026-03-17T09_38_32_219Z-debug-0.log +157 -0
  36. package/npmcachae/_logs/2026-03-17T09_38_34_308Z-debug-0.log +157 -0
  37. package/npmcachae/_update-notifier-last-checked +0 -0
  38. package/package.json +2 -1
  39. package/scripts/generate-components-index.js +99 -80
  40. package/src/assets/events/city/default-cover.png +0 -0
  41. package/src/assets/events/city//344/270/212/346/265/267.png +0 -0
  42. package/src/assets/events/city//345/214/227/344/272/254.png +0 -0
  43. package/src/assets/events/city//345/215/227/344/272/254.png +0 -0
  44. package/src/assets/events/city//345/244/251/346/264/245.png +0 -0
  45. package/src/assets/events/city//345/271/277/345/267/236.png +0 -0
  46. package/src/assets/events/city//346/210/220/351/203/275.png +0 -0
  47. package/src/assets/events/city//346/227/240/351/224/241.png +0 -0
  48. package/src/assets/events/city//346/235/255/345/267/236.png +0 -0
  49. package/src/assets/events/city//346/255/246/346/261/211.png +0 -0
  50. package/src/assets/events/city//346/267/261/345/234/2631.png +0 -0
  51. package/src/assets/events/city//346/267/261/345/234/2632.png +0 -0
  52. package/src/assets/events/city//350/213/217/345/267/236.png +0 -0
  53. package/src/assets/events/city//350/245/277/345/256/211.png +0 -0
  54. package/src/assets/events/city//351/203/221/345/267/236.png +0 -0
  55. package/src/assets/events/svg-icons/icon-checked.svg +3 -0
  56. package/src/assets/events/svg-icons/icon-competition.svg +7 -0
  57. package/src/assets/events/svg-icons/icon-events.svg +4 -0
  58. package/src/assets/events/svg-icons/icon-release.svg +4 -0
  59. package/src/assets/events/svg-icons/icon-summit.svg +4 -0
  60. package/src/assets/svg-icons/icon-arrow-left.svg +3 -0
  61. package/src/assets/svg-icons/icon-avatar-line.svg +3 -0
  62. package/src/assets/svg-icons/icon-caret-left.svg +3 -0
  63. package/src/assets/svg-icons/icon-caret-right.svg +3 -0
  64. package/src/assets/svg-icons/icon-chevron-down.svg +3 -0
  65. package/src/assets/svg-icons/icon-chevron-right.svg +3 -3
  66. package/src/assets/svg-icons/icon-close.svg +3 -3
  67. package/src/assets/svg-icons/icon-delete.svg +3 -3
  68. package/src/assets/svg-icons/icon-header-back.svg +3 -3
  69. package/src/assets/svg-icons/icon-header-delete.svg +3 -3
  70. package/src/assets/svg-icons/icon-header-menu.svg +3 -0
  71. package/src/assets/svg-icons/icon-header-person.svg +3 -0
  72. package/src/assets/svg-icons/icon-header-search.svg +4 -4
  73. package/src/assets/svg-icons/icon-locale.svg +3 -0
  74. package/src/assets/svg-icons/icon-log-off.svg +3 -0
  75. package/src/assets/svg-icons/icon-message.svg +3 -0
  76. package/src/assets/svg-icons/icon-moon.svg +3 -3
  77. package/src/assets/svg-icons/icon-outlink.svg +3 -0
  78. package/src/assets/svg-icons/icon-overview.svg +3 -0
  79. package/src/assets/svg-icons/icon-setting.svg +3 -0
  80. package/src/assets/svg-icons/icon-sun.svg +3 -3
  81. package/src/components/OBanner.vue +390 -390
  82. package/src/components/OCookieNotice.vue +423 -423
  83. package/src/components/OFooter.vue +566 -0
  84. package/src/components/OHeader.vue +97 -0
  85. package/src/components/OHeaderMoblie.vue +149 -0
  86. package/src/components/OHeaderSearch.vue +601 -601
  87. package/src/components/OHeaderUser.vue +304 -0
  88. package/src/components/OPlusConfigProvider.vue +32 -32
  89. package/src/components/OSection.vue +178 -178
  90. package/src/components/OSourceCode.vue +153 -0
  91. package/src/components/OThemeSwitcher.vue +108 -108
  92. package/src/components/common/AppAvatar.vue +83 -0
  93. package/src/components/common/ClientOnlyWrapper.ts +21 -21
  94. package/src/components/common/ContentWrapper.vue +85 -85
  95. package/src/components/common/HeaderEulerNav.vue +1118 -0
  96. package/src/components/common/HeaderNavMoblie.vue +344 -0
  97. package/src/components/common/HeaderUbmcNav.vue +597 -0
  98. package/src/components/element-plus/OElCookieNotice.vue +412 -412
  99. package/src/components/element-plus/index.ts +3 -3
  100. package/src/components/events/OEventsApply.vue +487 -0
  101. package/src/components/events/OEventsCalendar.vue +613 -0
  102. package/src/components/events/OEventsList.vue +402 -0
  103. package/src/components/events/config.ts +47 -0
  104. package/src/components/events/index.ts +23 -0
  105. package/src/components/events/npmcachae/_cacache/content-v2/sha512/2c/4f/a4140bfbf374a43f7dfe71880c051f79149cd259fb1a154fb692802c7489ef2317b737e7e690a627714ba19317971f29051b3798c246297b425a626a5b7a +1 -0
  106. package/src/components/events/npmcachae/_cacache/index-v5/8e/86/70dc69f1b1592fe14da10d2516ddfaa609af0cd9054a6ebde664acc6ab12 +2 -0
  107. package/src/components/events/npmcachae/_logs/2026-03-25T09_58_33_134Z-debug-0.log +105 -0
  108. package/src/components/events/npmcachae/_update-notifier-last-checked +0 -0
  109. package/src/components/events/types.ts +80 -0
  110. package/src/components/events/utils.ts +9 -0
  111. package/src/components/meeting/npmcachae/_cacache/content-v2/sha512/3e/17/1865217b9acb9f4921c53a09b5c76587cd2ab748beb2699ff6cfb1341d73b1aa56ed91ffc5ab2c9c9b3fbe626103b35d9a79ff29ff6b8cbb8d89755fe1a2 +1 -0
  112. package/src/components/meeting/npmcachae/_cacache/content-v2/sha512/a6/15/47bb7552ec9248079e839a5feecc1742d4de19524fdf041cf581701cf4760a5025106036145e279ba193b07c8fa5b07ae3d75f1b6032f0cb2219115b6167 +1 -0
  113. package/src/components/meeting/npmcachae/_cacache/content-v2/sha512/d1/4c/133b32e09c97101a27a07cc4432f94e470cff02d120d21babcea77c3f5cd436793516dc1a8e282ee1a568f923c148b1a48f4a43233462a530d35e8b41c67 +1 -0
  114. package/src/components/meeting/npmcachae/_cacache/index-v5/54/0d/a4909047714a0a7198bb9bd37020992464e47c79a791889919b84d90aab0 +3 -0
  115. package/src/components/meeting/npmcachae/_cacache/index-v5/8e/2b/21a79778e2ac08cf5663baf83cb35f951995a496007eb2e2f7fba54021a4 +3 -0
  116. package/src/components/meeting/npmcachae/_cacache/index-v5/eb/a0/b70c8132e5b57a0f1e129b8cc941796420a9c147c0baa680710083740898 +2 -0
  117. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_03_54_955Z-debug-0.log +277 -0
  118. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_03_57_842Z-debug-0.log +277 -0
  119. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_04_00_016Z-debug-0.log +277 -0
  120. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_04_02_191Z-debug-0.log +277 -0
  121. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_04_04_425Z-debug-0.log +277 -0
  122. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_04_06_642Z-debug-0.log +277 -0
  123. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_04_08_826Z-debug-0.log +277 -0
  124. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_25_36_140Z-debug-0.log +433 -0
  125. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_25_39_573Z-debug-0.log +433 -0
  126. package/src/components/meeting/npmcachae/_logs/2026-03-20T07_25_42_134Z-debug-0.log +212 -0
  127. package/src/components/meeting/npmcachae/_update-notifier-last-checked +0 -0
  128. package/src/draft/Banner.vue +265 -265
  129. package/src/draft/ButtonCards.vue +105 -105
  130. package/src/draft/Feature.vue +133 -133
  131. package/src/draft/Footer.vue +512 -512
  132. package/src/draft/HorizontalAnchor.vue +165 -165
  133. package/src/draft/ItemSwiper.vue +133 -133
  134. package/src/draft/Logo.vue +141 -141
  135. package/src/draft/LogoCard.vue +74 -74
  136. package/src/draft/LogoV2.vue +19 -19
  137. package/src/draft/MainCard.vue +38 -38
  138. package/src/draft/MultiCard.vue +94 -94
  139. package/src/draft/MultiIconCard.vue +73 -73
  140. package/src/draft/OInfoCard.vue +176 -176
  141. package/src/draft/Process.vue +81 -81
  142. package/src/draft/Section.vue +167 -167
  143. package/src/draft/SingleTabCard.vue +84 -84
  144. package/src/draft/SliderCard.vue +110 -110
  145. package/src/env.d.ts +1 -1
  146. package/src/i18n/en.ts +20 -20
  147. package/src/i18n/index.ts +42 -42
  148. package/src/i18n/zh.ts +14 -9
  149. package/src/index.ts +15 -1
  150. package/src/npmcachae/_cacache/content-v2/sha512/bd/56/25079ffb18446953f88fc063c3d6eaf7191772851b8477c118f113b920a7f357b67b9006181af58c9f68b0059b899ad0f2c86fe0a6490958d138cb063afd +1 -0
  151. package/src/npmcachae/_cacache/index-v5/d8/49/af4c6bb8f580edbd7b6e18db381844403e5f689a9849c5ffcdd2dd95d735 +3 -0
  152. package/src/npmcachae/_logs/2026-03-17T10_53_33_398Z-debug-0.log +156 -0
  153. package/src/npmcachae/_logs/2026-03-17T10_53_35_464Z-debug-0.log +156 -0
  154. package/src/npmcachae/_logs/2026-03-17T10_53_37_852Z-debug-0.log +156 -0
  155. package/src/npmcachae/_update-notifier-last-checked +0 -0
  156. package/src/shared/provide.ts +6 -6
  157. package/src/shims-vue-dompurify-html.d.ts +17 -0
  158. package/src/vue.d.ts +9 -9
  159. package/tsconfig.json +33 -33
  160. package/vite.config.ts +102 -101
  161. package/dist/chunk-index.cjs.js +0 -1
  162. package/dist/chunk-index.es.js +0 -64
@@ -1,412 +1,412 @@
1
- <script lang="ts" setup>
2
- import { ref, onMounted, computed, nextTick, watch } from 'vue';
3
- import ClientOnly from '../common/ClientOnlyWrapper';
4
- import { useScreen } from '@opendesign-plus/composables';
5
- import { useI18n } from '@/i18n';
6
- import { ElButton, ElDialog, ElSwitch, ElIcon } from 'element-plus';
7
- import { useVModel } from '@vueuse/core';
8
-
9
- const NOT_SIGNED = '0';
10
- const ALL_AGREED = '1';
11
- const NECCESSARY_AGREED = '2';
12
- const NOT_SHOW_BUT_AGREED = '3';
13
- const COOKIE_KEY_ZH = 'agreed-cookiepolicy-zh';
14
- const COOKIE_KEY_EN = 'agreed-cookiepolicy-en';
15
-
16
- const props = defineProps<{
17
- visible?: boolean;
18
- enableGrid?: boolean;
19
- community: string;
20
- detailUrl: string;
21
- wrapper?: string | HTMLElement;
22
- cookieDomain: string;
23
- }>();
24
-
25
- const emits = defineEmits<{
26
- (e: 'update:visible', value: boolean): void;
27
- }>();
28
-
29
- const { lePadV } = useScreen();
30
- const { locale, t } = useI18n();
31
- const isZh = computed(() => locale.value === 'zh');
32
-
33
- const cookieKey = computed(() => (isZh.value ? COOKIE_KEY_ZH : COOKIE_KEY_EN));
34
-
35
- // 是否允许分析cookie
36
- const analysisAllowed = ref(false);
37
- const visibleVmodel = useVModel(props, 'visible', emits, { defaultValue: false });
38
-
39
- const getCookie = (key: string) => {
40
- const cookie = document.cookie.split(';').find((row) => row.split('=')[0].trim() === encodeURIComponent(key));
41
- if (!cookie) {
42
- return null;
43
- }
44
- return decodeURIComponent(cookie.split('=')[1]);
45
- };
46
-
47
- const setCookie = (key: string, value: string, days: number, domain: string) => {
48
- const maxAge = days ? `; max-age=${days * 24 * 60 * 60}` : '';
49
- document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}${maxAge}; path=/; domain=${domain}`;
50
- };
51
-
52
- // 显示/隐藏cookie提示
53
- const toggleNoticeVisible = (val?: boolean) => {
54
- if (typeof val === 'boolean') {
55
- visibleVmodel.value = val;
56
- } else {
57
- visibleVmodel.value = !visibleVmodel.value;
58
- }
59
- nextTick(() => {
60
- if (!visibleVmodel.value && isZh.value && getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED) {
61
- setCookie(cookieKey.value, NOT_SHOW_BUT_AGREED, 180, props.cookieDomain ?? location.hostname);
62
- }
63
- });
64
- };
65
-
66
- // 弹出框是否显示
67
- const isDlgVisible = ref(false);
68
-
69
- // 显示/隐藏弹出框
70
- const toggleDlgVisible = (val?: boolean) => {
71
- if (typeof val === 'boolean') {
72
- isDlgVisible.value = val;
73
- } else {
74
- isDlgVisible.value = !isDlgVisible.value;
75
- }
76
- };
77
-
78
- // 是否未签署
79
- const isNotSigned = () => {
80
- if (isZh.value) {
81
- return getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED;
82
- }
83
- return (getCookie(cookieKey.value) ?? '0') === NOT_SIGNED;
84
- };
85
-
86
- // 是否全部同意
87
- const isAllAgreed = () => {
88
- if (isZh.value) {
89
- return getCookie(cookieKey.value) === NOT_SHOW_BUT_AGREED;
90
- }
91
- return getCookie(cookieKey.value) === ALL_AGREED;
92
- };
93
-
94
- onMounted(() => {
95
- // 未签署,展示cookie notice
96
- if (isNotSigned()) {
97
- toggleNoticeVisible(true);
98
- }
99
- });
100
-
101
- watch(locale, () => {
102
- toggleNoticeVisible(isNotSigned());
103
- });
104
-
105
- // 用户同意所有cookie
106
- const acceptAll = () => {
107
- analysisAllowed.value = true;
108
- setCookie(cookieKey.value, ALL_AGREED, 180, props.cookieDomain ?? location.hostname);
109
- toggleNoticeVisible(false);
110
- };
111
-
112
- // 用户拒绝所有cookie,即仅同意必要cookie
113
- const rejectAll = () => {
114
- analysisAllowed.value = false;
115
- setCookie(cookieKey.value, NECCESSARY_AGREED, 180, props.cookieDomain ?? location.hostname);
116
- toggleNoticeVisible(false);
117
- };
118
-
119
- const handleSave = () => {
120
- if (analysisAllowed.value) {
121
- acceptAll();
122
- } else {
123
- rejectAll();
124
- }
125
- toggleDlgVisible(false);
126
- };
127
-
128
- const handleAllowAll = () => {
129
- analysisAllowed.value = true;
130
- acceptAll();
131
- toggleDlgVisible(false);
132
- };
133
-
134
- const onDlgOpening = () => {
135
- analysisAllowed.value = isAllAgreed();
136
- };
137
-
138
- defineExpose({
139
- check() {
140
- const agreed = isAllAgreed();
141
- if (agreed === visibleVmodel.value) {
142
- toggleNoticeVisible();
143
- }
144
- },
145
- });
146
- </script>
147
-
148
- <template>
149
- <ClientOnly>
150
- <Teleport :to="wrapper || '#app'">
151
- <div v-if="visibleVmodel" class="cookie-notice">
152
- <div class="cookie-notice-content">
153
- <div :type="locale" :class="{ 'cookie-notice-wrap-grid': enableGrid, 'cookie-notice-wrap': !enableGrid }">
154
- <div class="cookie-notice-left">
155
- <p v-if="isZh" class="cookie-desc" style="margin-top: 0">
156
- {{ t('cookie.desc') }}
157
- <a :href="detailUrl" target="_blank" rel="noopener noreferrer">
158
- {{ t('cookie.about') }}
159
- </a>
160
- </p>
161
- <template v-else>
162
- <p class="cookie-title">{{ t('cookie.title', [community]) }}</p>
163
- <p class="cookie-desc">
164
- {{ t('cookie.desc') }}
165
- <a :href="detailUrl" target="_blank" rel="noopener noreferrer">{{ t('cookie.about') }} </a>.
166
- </p>
167
- </template>
168
- </div>
169
- <div v-if="!isZh" class="cookie-notice-right">
170
- <el-button round type="primary" @click="acceptAll">{{ t('cookie.acceptAll') }}</el-button>
171
- <el-button round type="primary" @click="rejectAll">{{ t('cookie.rejectAll') }}</el-button>
172
- <el-button round type="primary" @click="toggleDlgVisible(true)">{{ t('cookie.manage') }}</el-button>
173
- </div>
174
- <el-icon class="cookie-notice-close" :type="locale" @click="toggleNoticeVisible(false)">
175
- <slot name="close-icon">
176
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z" /></svg>
177
- </slot>
178
- </el-icon>
179
- </div>
180
- </div>
181
- <el-dialog v-model="isDlgVisible" :width="lePadV ? '90%' : '50%'" :title="t('cookie.manage')" destroy-on-close @open="onDlgOpening">
182
- <div class="cookie-dlg-content">
183
- <div class="content-item">
184
- <div class="item-header">
185
- <span class="item-title">{{ t('cookie.necessaryCookie') }}</span>
186
- <span class="item-extra">{{ t('cookie.alwaysOn') }}</span>
187
- </div>
188
- <div class="item-detail">
189
- {{ t('cookie.necessaryCookieDetail') }}
190
- </div>
191
- </div>
192
- <div class="content-item">
193
- <div class="item-header">
194
- <span class="item-title">{{ t('cookie.analyticalCookie') }}</span>
195
- <span class="item-extra">
196
- <el-switch v-model="analysisAllowed" />
197
- </span>
198
- </div>
199
- <div class="item-detail">
200
- {{ t('cookie.analyticalCookieDetail') }}
201
- </div>
202
- </div>
203
- </div>
204
- <template #footer>
205
- <el-button round type="primary" @click="handleSave" style="margin-right: 16px">{{ t('cookie.saveSetting') }}</el-button>
206
- <el-button round type="primary" @click="handleAllowAll">{{ t('cookie.acceptAll') }}</el-button>
207
- </template>
208
- </el-dialog>
209
- </div>
210
- </Teleport>
211
- </ClientOnly>
212
- </template>
213
-
214
- <style lang="scss" scoped>
215
- .el-button {
216
- --el-button-bg-color: transparent;
217
- --el-button-text-color: var(--o-color-primary1);
218
- --el-button-border-color: var(--o-color-primary1);
219
- --el-button-hover-bg-color: var(--o-color-primary1);
220
- }
221
-
222
- .cookie-notice {
223
- position: fixed;
224
- bottom: 0;
225
- z-index: 999;
226
- width: 100%;
227
- --el-color-primary: var(--o-color-primary1);
228
- .o-button {
229
- --o-button-font-size-mini: 14px;
230
- }
231
- .o-button + .o-button {
232
- margin-left: 16px;
233
-
234
- @media (max-width: 840px) {
235
- margin-left: 0;
236
- margin-top: 12px;
237
- }
238
- }
239
- }
240
-
241
- .cookie-notice-content {
242
- background-color: rgba(var(--o-mixedgray-1), 0.9);
243
- backdrop-filter: blur(5px);
244
- box-shadow: var(--o-shadow-1);
245
- }
246
-
247
- .cookie-notice-wrap {
248
- position: relative;
249
- display: flex;
250
- justify-content: space-between;
251
- margin: 0 auto;
252
- padding: 24px var(--layout-content-padding);
253
- max-width: var(--layout-content-max-width);
254
- &:not([type='zh']) {
255
- @media (max-width: 840px) {
256
- flex-direction: column;
257
- align-items: center;
258
- }
259
- }
260
- }
261
-
262
- .cookie-notice-wrap-grid {
263
- position: relative;
264
- display: flex;
265
- justify-content: space-between;
266
- width: var(--grid-content-width);
267
- padding: 24px 0;
268
- margin: 0 auto;
269
- @media (max-width: 840px) {
270
- padding: 16px 0;
271
- flex-direction: column;
272
- align-items: center;
273
- }
274
- }
275
-
276
- .cookie-notice-left {
277
- width: 60%;
278
-
279
- @media (max-width: 1100px) {
280
- width: 58%;
281
- }
282
-
283
- @media (max-width: 840px) {
284
- width: 100%;
285
- }
286
-
287
- .cookie-title {
288
- font-size: 16px;
289
- line-height: 28px;
290
- color: var(--o-color-info1);
291
- font-weight: 500;
292
- @media (max-width: 840px) {
293
- font-size: 16px;
294
- line-height: 24px;
295
- text-align: center;
296
- }
297
- }
298
-
299
- .cookie-desc {
300
- font-size: 12px;
301
- line-height: 18px;
302
- color: var(--o-color-info2);
303
- margin-top: 8px;
304
- }
305
- }
306
-
307
- .cookie-notice-right {
308
- display: flex;
309
- align-items: center;
310
- margin-top: 12px;
311
-
312
- @media (max-width: 840px) {
313
- width: 100%;
314
- }
315
-
316
- @media (max-width: 840px) {
317
- flex-direction: column;
318
- align-items: center;
319
- }
320
-
321
- .el-button:not(:first-child) {
322
- margin-left: 16px;
323
- }
324
-
325
- @media (max-width: 840px) {
326
- .el-button {
327
- align-self: stretch;
328
- &:not(:first-child) {
329
- margin-top: 12px;
330
- margin-left: 0;
331
- }
332
- }
333
- }
334
- }
335
-
336
- .cookie-notice-close {
337
- &[type='en'] {
338
- position: absolute;
339
- top: 16px;
340
- right: var(--layout-content-padding);
341
- transform-origin: center;
342
- }
343
- cursor: pointer;
344
- color: var(--o-color-info1);
345
- font-size: 20px;
346
- &:hover {
347
- color: var(--o-color-primary2);
348
- }
349
- @media (max-width: 840px) {
350
- font-size: 14px;
351
- }
352
- @include x-svg-hover;
353
- }
354
-
355
- .cookie-dlg-content {
356
- .content-item + .content-item {
357
- margin-top: 24px;
358
- }
359
-
360
- .content-item {
361
- .item-header {
362
- display: flex;
363
- align-items: center;
364
- .item-title {
365
- font-size: 18px;
366
- line-height: 32px;
367
- color: var(--o-color-info1);
368
- font-weight: 500;
369
- }
370
-
371
- .item-extra {
372
- font-size: 14px;
373
- line-height: 22px;
374
- color: var(--o-color-info3);
375
- margin-left: 24px;
376
- }
377
- }
378
-
379
- .item-detail {
380
- font-size: 16px;
381
- line-height: 28px;
382
- color: var(--o-color-info2);
383
- margin-top: 12px;
384
- @media (max-width: 840px) {
385
- font-size: 14px;
386
- line-height: 21px;
387
- margin-top: 8px;
388
- }
389
- }
390
- }
391
- }
392
-
393
- :deep(.el-dialog) {
394
- .el-dialog__header {
395
- text-align: center;
396
- }
397
- .el-dialog__title {
398
- font-size: 32px;
399
- @media (max-width: 840px) {
400
- font-size: 22px;
401
- }
402
- }
403
- .el-dialog__footer {
404
- text-align: center;
405
- @media (max-width: 840px) {
406
- .o-button {
407
- margin: 0 8px;
408
- }
409
- }
410
- }
411
- }
412
- </style>
1
+ <script lang="ts" setup>
2
+ import { ref, onMounted, computed, nextTick, watch } from 'vue';
3
+ import ClientOnly from '../common/ClientOnlyWrapper';
4
+ import { useScreen } from '@opendesign-plus/composables';
5
+ import { useI18n } from '@/i18n';
6
+ import { ElButton, ElDialog, ElSwitch, ElIcon } from 'element-plus';
7
+ import { useVModel } from '@vueuse/core';
8
+
9
+ const NOT_SIGNED = '0';
10
+ const ALL_AGREED = '1';
11
+ const NECCESSARY_AGREED = '2';
12
+ const NOT_SHOW_BUT_AGREED = '3';
13
+ const COOKIE_KEY_ZH = 'agreed-cookiepolicy-zh';
14
+ const COOKIE_KEY_EN = 'agreed-cookiepolicy-en';
15
+
16
+ const props = defineProps<{
17
+ visible?: boolean;
18
+ enableGrid?: boolean;
19
+ community: string;
20
+ detailUrl: string;
21
+ wrapper?: string | HTMLElement;
22
+ cookieDomain: string;
23
+ }>();
24
+
25
+ const emits = defineEmits<{
26
+ (e: 'update:visible', value: boolean): void;
27
+ }>();
28
+
29
+ const { lePadV } = useScreen();
30
+ const { locale, t } = useI18n();
31
+ const isZh = computed(() => locale.value === 'zh');
32
+
33
+ const cookieKey = computed(() => (isZh.value ? COOKIE_KEY_ZH : COOKIE_KEY_EN));
34
+
35
+ // 是否允许分析cookie
36
+ const analysisAllowed = ref(false);
37
+ const visibleVmodel = useVModel(props, 'visible', emits, { defaultValue: false });
38
+
39
+ const getCookie = (key: string) => {
40
+ const cookie = document.cookie.split(';').find((row) => row.split('=')[0].trim() === encodeURIComponent(key));
41
+ if (!cookie) {
42
+ return null;
43
+ }
44
+ return decodeURIComponent(cookie.split('=')[1]);
45
+ };
46
+
47
+ const setCookie = (key: string, value: string, days: number, domain: string) => {
48
+ const maxAge = days ? `; max-age=${days * 24 * 60 * 60}` : '';
49
+ document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}${maxAge}; path=/; domain=${domain}`;
50
+ };
51
+
52
+ // 显示/隐藏cookie提示
53
+ const toggleNoticeVisible = (val?: boolean) => {
54
+ if (typeof val === 'boolean') {
55
+ visibleVmodel.value = val;
56
+ } else {
57
+ visibleVmodel.value = !visibleVmodel.value;
58
+ }
59
+ nextTick(() => {
60
+ if (!visibleVmodel.value && isZh.value && getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED) {
61
+ setCookie(cookieKey.value, NOT_SHOW_BUT_AGREED, 180, props.cookieDomain ?? location.hostname);
62
+ }
63
+ });
64
+ };
65
+
66
+ // 弹出框是否显示
67
+ const isDlgVisible = ref(false);
68
+
69
+ // 显示/隐藏弹出框
70
+ const toggleDlgVisible = (val?: boolean) => {
71
+ if (typeof val === 'boolean') {
72
+ isDlgVisible.value = val;
73
+ } else {
74
+ isDlgVisible.value = !isDlgVisible.value;
75
+ }
76
+ };
77
+
78
+ // 是否未签署
79
+ const isNotSigned = () => {
80
+ if (isZh.value) {
81
+ return getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED;
82
+ }
83
+ return (getCookie(cookieKey.value) ?? '0') === NOT_SIGNED;
84
+ };
85
+
86
+ // 是否全部同意
87
+ const isAllAgreed = () => {
88
+ if (isZh.value) {
89
+ return getCookie(cookieKey.value) === NOT_SHOW_BUT_AGREED;
90
+ }
91
+ return getCookie(cookieKey.value) === ALL_AGREED;
92
+ };
93
+
94
+ onMounted(() => {
95
+ // 未签署,展示cookie notice
96
+ if (isNotSigned()) {
97
+ toggleNoticeVisible(true);
98
+ }
99
+ });
100
+
101
+ watch(locale, () => {
102
+ toggleNoticeVisible(isNotSigned());
103
+ });
104
+
105
+ // 用户同意所有cookie
106
+ const acceptAll = () => {
107
+ analysisAllowed.value = true;
108
+ setCookie(cookieKey.value, ALL_AGREED, 180, props.cookieDomain ?? location.hostname);
109
+ toggleNoticeVisible(false);
110
+ };
111
+
112
+ // 用户拒绝所有cookie,即仅同意必要cookie
113
+ const rejectAll = () => {
114
+ analysisAllowed.value = false;
115
+ setCookie(cookieKey.value, NECCESSARY_AGREED, 180, props.cookieDomain ?? location.hostname);
116
+ toggleNoticeVisible(false);
117
+ };
118
+
119
+ const handleSave = () => {
120
+ if (analysisAllowed.value) {
121
+ acceptAll();
122
+ } else {
123
+ rejectAll();
124
+ }
125
+ toggleDlgVisible(false);
126
+ };
127
+
128
+ const handleAllowAll = () => {
129
+ analysisAllowed.value = true;
130
+ acceptAll();
131
+ toggleDlgVisible(false);
132
+ };
133
+
134
+ const onDlgOpening = () => {
135
+ analysisAllowed.value = isAllAgreed();
136
+ };
137
+
138
+ defineExpose({
139
+ check() {
140
+ const agreed = isAllAgreed();
141
+ if (agreed === visibleVmodel.value) {
142
+ toggleNoticeVisible();
143
+ }
144
+ },
145
+ });
146
+ </script>
147
+
148
+ <template>
149
+ <ClientOnly>
150
+ <Teleport :to="wrapper || '#app'">
151
+ <div v-if="visibleVmodel" class="cookie-notice">
152
+ <div class="cookie-notice-content">
153
+ <div :type="locale" :class="{ 'cookie-notice-wrap-grid': enableGrid, 'cookie-notice-wrap': !enableGrid }">
154
+ <div class="cookie-notice-left">
155
+ <p v-if="isZh" class="cookie-desc" style="margin-top: 0">
156
+ {{ t('cookie.desc') }}
157
+ <a :href="detailUrl" target="_blank" rel="noopener noreferrer">
158
+ {{ t('cookie.about') }}
159
+ </a>
160
+ </p>
161
+ <template v-else>
162
+ <p class="cookie-title">{{ t('cookie.title', [community]) }}</p>
163
+ <p class="cookie-desc">
164
+ {{ t('cookie.desc') }}
165
+ <a :href="detailUrl" target="_blank" rel="noopener noreferrer">{{ t('cookie.about') }} </a>.
166
+ </p>
167
+ </template>
168
+ </div>
169
+ <div v-if="!isZh" class="cookie-notice-right">
170
+ <el-button round type="primary" @click="acceptAll">{{ t('cookie.acceptAll') }}</el-button>
171
+ <el-button round type="primary" @click="rejectAll">{{ t('cookie.rejectAll') }}</el-button>
172
+ <el-button round type="primary" @click="toggleDlgVisible(true)">{{ t('cookie.manage') }}</el-button>
173
+ </div>
174
+ <el-icon class="cookie-notice-close" :type="locale" @click="toggleNoticeVisible(false)">
175
+ <slot name="close-icon">
176
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z" /></svg>
177
+ </slot>
178
+ </el-icon>
179
+ </div>
180
+ </div>
181
+ <el-dialog v-model="isDlgVisible" :width="lePadV ? '90%' : '50%'" :title="t('cookie.manage')" destroy-on-close @open="onDlgOpening">
182
+ <div class="cookie-dlg-content">
183
+ <div class="content-item">
184
+ <div class="item-header">
185
+ <span class="item-title">{{ t('cookie.necessaryCookie') }}</span>
186
+ <span class="item-extra">{{ t('cookie.alwaysOn') }}</span>
187
+ </div>
188
+ <div class="item-detail">
189
+ {{ t('cookie.necessaryCookieDetail') }}
190
+ </div>
191
+ </div>
192
+ <div class="content-item">
193
+ <div class="item-header">
194
+ <span class="item-title">{{ t('cookie.analyticalCookie') }}</span>
195
+ <span class="item-extra">
196
+ <el-switch v-model="analysisAllowed" />
197
+ </span>
198
+ </div>
199
+ <div class="item-detail">
200
+ {{ t('cookie.analyticalCookieDetail') }}
201
+ </div>
202
+ </div>
203
+ </div>
204
+ <template #footer>
205
+ <el-button round type="primary" @click="handleSave" style="margin-right: 16px">{{ t('cookie.saveSetting') }}</el-button>
206
+ <el-button round type="primary" @click="handleAllowAll">{{ t('cookie.acceptAll') }}</el-button>
207
+ </template>
208
+ </el-dialog>
209
+ </div>
210
+ </Teleport>
211
+ </ClientOnly>
212
+ </template>
213
+
214
+ <style lang="scss" scoped>
215
+ .el-button {
216
+ --el-button-bg-color: transparent;
217
+ --el-button-text-color: var(--o-color-primary1);
218
+ --el-button-border-color: var(--o-color-primary1);
219
+ --el-button-hover-bg-color: var(--o-color-primary1);
220
+ }
221
+
222
+ .cookie-notice {
223
+ position: fixed;
224
+ bottom: 0;
225
+ z-index: 999;
226
+ width: 100%;
227
+ --el-color-primary: var(--o-color-primary1);
228
+ .o-button {
229
+ --o-button-font-size-mini: 14px;
230
+ }
231
+ .o-button + .o-button {
232
+ margin-left: 16px;
233
+
234
+ @media (max-width: 840px) {
235
+ margin-left: 0;
236
+ margin-top: 12px;
237
+ }
238
+ }
239
+ }
240
+
241
+ .cookie-notice-content {
242
+ background-color: rgba(var(--o-mixedgray-1), 0.9);
243
+ backdrop-filter: blur(5px);
244
+ box-shadow: var(--o-shadow-1);
245
+ }
246
+
247
+ .cookie-notice-wrap {
248
+ position: relative;
249
+ display: flex;
250
+ justify-content: space-between;
251
+ margin: 0 auto;
252
+ padding: 24px var(--layout-content-padding);
253
+ max-width: var(--layout-content-max-width);
254
+ &:not([type='zh']) {
255
+ @media (max-width: 840px) {
256
+ flex-direction: column;
257
+ align-items: center;
258
+ }
259
+ }
260
+ }
261
+
262
+ .cookie-notice-wrap-grid {
263
+ position: relative;
264
+ display: flex;
265
+ justify-content: space-between;
266
+ width: var(--grid-content-width);
267
+ padding: 24px 0;
268
+ margin: 0 auto;
269
+ @media (max-width: 840px) {
270
+ padding: 16px 0;
271
+ flex-direction: column;
272
+ align-items: center;
273
+ }
274
+ }
275
+
276
+ .cookie-notice-left {
277
+ width: 60%;
278
+
279
+ @media (max-width: 1100px) {
280
+ width: 58%;
281
+ }
282
+
283
+ @media (max-width: 840px) {
284
+ width: 100%;
285
+ }
286
+
287
+ .cookie-title {
288
+ font-size: 16px;
289
+ line-height: 28px;
290
+ color: var(--o-color-info1);
291
+ font-weight: 500;
292
+ @media (max-width: 840px) {
293
+ font-size: 16px;
294
+ line-height: 24px;
295
+ text-align: center;
296
+ }
297
+ }
298
+
299
+ .cookie-desc {
300
+ font-size: 12px;
301
+ line-height: 18px;
302
+ color: var(--o-color-info2);
303
+ margin-top: 8px;
304
+ }
305
+ }
306
+
307
+ .cookie-notice-right {
308
+ display: flex;
309
+ align-items: center;
310
+ margin-top: 12px;
311
+
312
+ @media (max-width: 840px) {
313
+ width: 100%;
314
+ }
315
+
316
+ @media (max-width: 840px) {
317
+ flex-direction: column;
318
+ align-items: center;
319
+ }
320
+
321
+ .el-button:not(:first-child) {
322
+ margin-left: 16px;
323
+ }
324
+
325
+ @media (max-width: 840px) {
326
+ .el-button {
327
+ align-self: stretch;
328
+ &:not(:first-child) {
329
+ margin-top: 12px;
330
+ margin-left: 0;
331
+ }
332
+ }
333
+ }
334
+ }
335
+
336
+ .cookie-notice-close {
337
+ &[type='en'] {
338
+ position: absolute;
339
+ top: 16px;
340
+ right: var(--layout-content-padding);
341
+ transform-origin: center;
342
+ }
343
+ cursor: pointer;
344
+ color: var(--o-color-info1);
345
+ font-size: 20px;
346
+ &:hover {
347
+ color: var(--o-color-primary2);
348
+ }
349
+ @media (max-width: 840px) {
350
+ font-size: 14px;
351
+ }
352
+ @include x-svg-hover;
353
+ }
354
+
355
+ .cookie-dlg-content {
356
+ .content-item + .content-item {
357
+ margin-top: 24px;
358
+ }
359
+
360
+ .content-item {
361
+ .item-header {
362
+ display: flex;
363
+ align-items: center;
364
+ .item-title {
365
+ font-size: 18px;
366
+ line-height: 32px;
367
+ color: var(--o-color-info1);
368
+ font-weight: 500;
369
+ }
370
+
371
+ .item-extra {
372
+ font-size: 14px;
373
+ line-height: 22px;
374
+ color: var(--o-color-info3);
375
+ margin-left: 24px;
376
+ }
377
+ }
378
+
379
+ .item-detail {
380
+ font-size: 16px;
381
+ line-height: 28px;
382
+ color: var(--o-color-info2);
383
+ margin-top: 12px;
384
+ @media (max-width: 840px) {
385
+ font-size: 14px;
386
+ line-height: 21px;
387
+ margin-top: 8px;
388
+ }
389
+ }
390
+ }
391
+ }
392
+
393
+ :deep(.el-dialog) {
394
+ .el-dialog__header {
395
+ text-align: center;
396
+ }
397
+ .el-dialog__title {
398
+ font-size: 32px;
399
+ @media (max-width: 840px) {
400
+ font-size: 22px;
401
+ }
402
+ }
403
+ .el-dialog__footer {
404
+ text-align: center;
405
+ @media (max-width: 840px) {
406
+ .o-button {
407
+ margin: 0 8px;
408
+ }
409
+ }
410
+ }
411
+ }
412
+ </style>