@opendesign-plus-test/components 0.0.1-rc.2
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/dist/components.cjs.js +1 -0
- package/dist/components.css +1 -0
- package/dist/components.es.js +1193 -0
- package/dist/components.umd.js +1 -0
- package/docs/design.md +27 -0
- package/docs/design_banner.md +41 -0
- package/docs/design_section.md +27 -0
- package/package.json +47 -0
- package/scripts/generate-components-index.js +81 -0
- package/src/assets/svg-icons/icon-chevron-right.svg +3 -0
- package/src/assets/svg-icons/icon-close.svg +3 -0
- package/src/assets/svg-icons/icon-delete.svg +3 -0
- package/src/assets/svg-icons/icon-header-back.svg +3 -0
- package/src/assets/svg-icons/icon-header-delete.svg +3 -0
- package/src/assets/svg-icons/icon-header-search.svg +4 -0
- package/src/assets/svg-icons/icon-moon.svg +3 -0
- package/src/assets/svg-icons/icon-sun.svg +3 -0
- package/src/components/OBanner.vue +390 -0
- package/src/components/OCookieNotice.vue +417 -0
- package/src/components/OCookieNoticeEl.vue +403 -0
- package/src/components/OHeaderSearch.vue +601 -0
- package/src/components/OPlusConfigProvider.vue +32 -0
- package/src/components/OSection.vue +178 -0
- package/src/components/OThemeSwitcher.vue +108 -0
- package/src/components/common/ClientOnlyWrapper.ts +21 -0
- package/src/components/common/ContentWrapper.vue +85 -0
- package/src/draft/Banner.vue +265 -0
- package/src/draft/ButtonCards.vue +106 -0
- package/src/draft/Feature.vue +134 -0
- package/src/draft/Footer.vue +512 -0
- package/src/draft/HorizontalAnchor.vue +165 -0
- package/src/draft/ItemSwiper.vue +133 -0
- package/src/draft/Logo.vue +141 -0
- package/src/draft/LogoCard.vue +75 -0
- package/src/draft/LogoV2.vue +19 -0
- package/src/draft/MainCard.vue +38 -0
- package/src/draft/MultiCard.vue +95 -0
- package/src/draft/MultiIconCard.vue +74 -0
- package/src/draft/OInfoCard.vue +176 -0
- package/src/draft/Process.vue +81 -0
- package/src/draft/Section.vue +167 -0
- package/src/draft/SingleTabCard.vue +85 -0
- package/src/draft/SliderCard.vue +110 -0
- package/src/env.d.ts +1 -0
- package/src/i18n/en.ts +20 -0
- package/src/i18n/index.ts +42 -0
- package/src/i18n/zh.ts +9 -0
- package/src/index.ts +34 -0
- package/src/shared/provide.ts +6 -0
- package/src/vue.d.ts +10 -0
- package/tsconfig.json +33 -0
- package/vite.config.ts +90 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, onMounted, computed, nextTick } from 'vue';
|
|
3
|
+
import ClientOnly from './common/ClientOnlyWrapper';
|
|
4
|
+
import { useScreen } from '@opendesign-plus/composables';
|
|
5
|
+
import { useI18n } from '@/i18n';
|
|
6
|
+
import { DialogActionT, OButton, ODialog, OIcon, OIconClose, OSwitch } from '@opensig/opendesign';
|
|
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_DOMAIN = import.meta.env.VITE_COOKIE_DOMAIN as string;
|
|
14
|
+
const COOKIE_KEY_ZH = 'agreed-cookiepolicy-zh';
|
|
15
|
+
const COOKIE_KEY_EN = 'agreed-cookiepolicy-en';
|
|
16
|
+
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
enableGrid?: boolean;
|
|
20
|
+
community: string;
|
|
21
|
+
aboutPathZh: string;
|
|
22
|
+
aboutPathEn: string;
|
|
23
|
+
}>();
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
(e: 'update:visible', value: boolean): void;
|
|
27
|
+
}>();
|
|
28
|
+
|
|
29
|
+
const { lePadV, leLaptop } = 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', emit, { defaultValue: false });
|
|
38
|
+
|
|
39
|
+
const getCookie = (key: string) => {
|
|
40
|
+
const cookie = document.cookie
|
|
41
|
+
.split(';')
|
|
42
|
+
.find((row) => row.split('=')[0].trim() === encodeURIComponent(key));
|
|
43
|
+
if (!cookie) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return decodeURIComponent(cookie.split('=')[1]);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const setCookie = (key: string, value: string, days: number, domain: string) => {
|
|
50
|
+
const maxAge = days ? `; max-age=${days * 24 * 60 * 60}` : '';
|
|
51
|
+
document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}${maxAge}; path=/; domain=${domain}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const removeCookie = (key: string, domain: string) => {
|
|
55
|
+
document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${domain}`;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// 显示/隐藏cookie提示
|
|
59
|
+
const toggleNoticeVisible = (val?: boolean) => {
|
|
60
|
+
if (typeof val === 'boolean') {
|
|
61
|
+
visibleVmodel.value = val;
|
|
62
|
+
} else {
|
|
63
|
+
visibleVmodel.value = !visibleVmodel.value;
|
|
64
|
+
}
|
|
65
|
+
nextTick(() => {
|
|
66
|
+
if (!visibleVmodel.value && isZh.value && getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED) {
|
|
67
|
+
setCookie(cookieKey.value, NOT_SHOW_BUT_AGREED, 180, COOKIE_DOMAIN ?? location.hostname);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// 弹出框是否显示
|
|
73
|
+
const isDlgVisible = ref(false);
|
|
74
|
+
|
|
75
|
+
// 显示/隐藏弹出框
|
|
76
|
+
const toggleDlgVisible = (val?: boolean) => {
|
|
77
|
+
if (typeof val === 'boolean') {
|
|
78
|
+
isDlgVisible.value = val;
|
|
79
|
+
} else {
|
|
80
|
+
isDlgVisible.value = !isDlgVisible.value;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// 是否未签署
|
|
85
|
+
const isNotSigned = () => {
|
|
86
|
+
if (isZh.value) {
|
|
87
|
+
return getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED;
|
|
88
|
+
}
|
|
89
|
+
return (getCookie(cookieKey.value) ?? '0') === NOT_SIGNED;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// 是否全部同意
|
|
93
|
+
const isAllAgreed = () => {
|
|
94
|
+
if (isZh.value) {
|
|
95
|
+
return getCookie(cookieKey.value) === NOT_SHOW_BUT_AGREED;
|
|
96
|
+
}
|
|
97
|
+
return getCookie(cookieKey.value) === ALL_AGREED;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
onMounted(() => {
|
|
101
|
+
// 未签署,展示cookie notice
|
|
102
|
+
if (isNotSigned()) {
|
|
103
|
+
toggleNoticeVisible(true);
|
|
104
|
+
if (isZh.value && getCookie(cookieKey.value) !== NOT_SHOW_BUT_AGREED) {
|
|
105
|
+
setCookie(cookieKey.value, NOT_SHOW_BUT_AGREED, 180, COOKIE_DOMAIN);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// 用户同意所有cookie
|
|
111
|
+
const acceptAll = () => {
|
|
112
|
+
analysisAllowed.value = true;
|
|
113
|
+
removeCookie(cookieKey.value, COOKIE_DOMAIN ?? location.hostname);
|
|
114
|
+
setCookie(cookieKey.value, ALL_AGREED, 180, COOKIE_DOMAIN ?? location.hostname);
|
|
115
|
+
toggleNoticeVisible(false);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// 用户拒绝所有cookie,即仅同意必要cookie
|
|
119
|
+
const rejectAll = () => {
|
|
120
|
+
analysisAllowed.value = false;
|
|
121
|
+
removeCookie(cookieKey.value, COOKIE_DOMAIN ?? location.hostname);
|
|
122
|
+
setCookie(cookieKey.value, NECCESSARY_AGREED, 180, COOKIE_DOMAIN ?? location.hostname);
|
|
123
|
+
toggleNoticeVisible(false);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// 弹出框设置
|
|
127
|
+
const dlgActions: Array<DialogActionT> = [
|
|
128
|
+
{
|
|
129
|
+
id: 'save',
|
|
130
|
+
color: 'primary',
|
|
131
|
+
label: t('cookie.saveSetting'),
|
|
132
|
+
variant: 'outline',
|
|
133
|
+
size: 'large',
|
|
134
|
+
round: 'pill',
|
|
135
|
+
onClick: () => {
|
|
136
|
+
if (analysisAllowed.value) {
|
|
137
|
+
acceptAll();
|
|
138
|
+
} else {
|
|
139
|
+
rejectAll();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
toggleDlgVisible(false);
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: 'allowAll',
|
|
147
|
+
color: 'primary',
|
|
148
|
+
label: t('cookie.acceptAll'),
|
|
149
|
+
variant: 'outline',
|
|
150
|
+
size: 'large',
|
|
151
|
+
round: 'pill',
|
|
152
|
+
onClick: () => {
|
|
153
|
+
analysisAllowed.value = true;
|
|
154
|
+
acceptAll();
|
|
155
|
+
toggleDlgVisible(false);
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
const onDlgChange = (val: boolean) => {
|
|
161
|
+
if (val) {
|
|
162
|
+
analysisAllowed.value = isAllAgreed();
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
</script>
|
|
166
|
+
|
|
167
|
+
<template>
|
|
168
|
+
<ClientOnly>
|
|
169
|
+
<Teleport to="#app">
|
|
170
|
+
<div v-if="visibleVmodel" class="cookie-notice">
|
|
171
|
+
<div class="cookie-notice-content">
|
|
172
|
+
<div :type="locale" :class="{ 'cookie-notice-wrap-grid': enableGrid, 'cookie-notice-wrap': !enableGrid }">
|
|
173
|
+
<div class="cookie-notice-left">
|
|
174
|
+
<p v-if="isZh" class="cookie-desc" style="margin-top: 0;">
|
|
175
|
+
{{ t('cookie.desc') }}
|
|
176
|
+
<a :href="aboutPathZh" target="_blank" rel="noopener noreferrer">
|
|
177
|
+
{{ t('cookie.about') }}
|
|
178
|
+
</a>
|
|
179
|
+
</p>
|
|
180
|
+
<template v-else>
|
|
181
|
+
<p class="cookie-title">{{ t('cookie.title', [community]) }}</p>
|
|
182
|
+
<p class="cookie-desc">
|
|
183
|
+
{{ t('cookie.desc') }}
|
|
184
|
+
<a :href="aboutPathEn" target="_blank" rel="noopener noreferrer">{{ t('cookie.about') }} </a>.
|
|
185
|
+
</p>
|
|
186
|
+
</template>
|
|
187
|
+
</div>
|
|
188
|
+
<div v-if="!isZh" class="cookie-notice-right">
|
|
189
|
+
<OButton round="pill" variant="outline" color="primary" @click="acceptAll">{{ t('cookie.acceptAll') }}</OButton>
|
|
190
|
+
<OButton round="pill" variant="outline" color="primary" @click="rejectAll">{{ t('cookie.rejectAll') }}</OButton>
|
|
191
|
+
<OButton round="pill" variant="outline" color="primary" @click="toggleDlgVisible(true)">
|
|
192
|
+
{{ t('cookie.manage') }}
|
|
193
|
+
</OButton>
|
|
194
|
+
</div>
|
|
195
|
+
<OIcon class="cookie-notice-close" :type="locale" @click="toggleNoticeVisible(false)">
|
|
196
|
+
<OIconClose />
|
|
197
|
+
</OIcon>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
<ODialog
|
|
201
|
+
v-model:visible="isDlgVisible"
|
|
202
|
+
:size="leLaptop ? 'medium' : 'large'"
|
|
203
|
+
:phone-half-full="lePadV"
|
|
204
|
+
class="cookie-dlg"
|
|
205
|
+
:actions="dlgActions"
|
|
206
|
+
@change="onDlgChange"
|
|
207
|
+
>
|
|
208
|
+
<template #header>
|
|
209
|
+
<span class="cookie-dlg-title">{{ t('cookie.manage') }}</span>
|
|
210
|
+
</template>
|
|
211
|
+
<div class="cookie-dlg-content">
|
|
212
|
+
<div class="content-item">
|
|
213
|
+
<div class="item-header">
|
|
214
|
+
<span class="item-title">{{ t('cookie.necessaryCookie') }}</span>
|
|
215
|
+
<span class="item-extra">{{ t('cookie.alwaysOn') }}</span>
|
|
216
|
+
</div>
|
|
217
|
+
<div class="item-detail">
|
|
218
|
+
{{ t('cookie.necessaryCookieDetail') }}
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
<div class="content-item">
|
|
222
|
+
<div class="item-header">
|
|
223
|
+
<span class="item-title">{{ t('cookie.analyticalCookie') }}</span>
|
|
224
|
+
<span class="item-extra">
|
|
225
|
+
<OSwitch v-model="analysisAllowed" />
|
|
226
|
+
</span>
|
|
227
|
+
</div>
|
|
228
|
+
<div class="item-detail">
|
|
229
|
+
{{ t('cookie.analyticalCookieDetail') }}
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
</ODialog>
|
|
234
|
+
</div>
|
|
235
|
+
</Teleport>
|
|
236
|
+
</ClientOnly>
|
|
237
|
+
</template>
|
|
238
|
+
|
|
239
|
+
<style lang="scss" scoped>
|
|
240
|
+
.cookie-notice {
|
|
241
|
+
position: fixed;
|
|
242
|
+
bottom: 0;
|
|
243
|
+
z-index: 999;
|
|
244
|
+
width: 100%;
|
|
245
|
+
.o-button {
|
|
246
|
+
--o-button-font-size-mini: 14px;
|
|
247
|
+
}
|
|
248
|
+
.o-button + .o-button {
|
|
249
|
+
margin-left: 16px;
|
|
250
|
+
|
|
251
|
+
@media (max-width: 840px) {
|
|
252
|
+
margin-left: 0;
|
|
253
|
+
margin-top: 12px;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.cookie-notice-content {
|
|
259
|
+
background-color: rgba(var(--o-mixedgray-1),.9);
|
|
260
|
+
backdrop-filter: blur(5px);
|
|
261
|
+
box-shadow: var(--o-shadow-1);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.cookie-notice-wrap {
|
|
265
|
+
position: relative;
|
|
266
|
+
display: flex;
|
|
267
|
+
justify-content: space-between;
|
|
268
|
+
margin: 0 auto;
|
|
269
|
+
padding: 24px var(--layout-content-padding);
|
|
270
|
+
max-width: var(--layout-content-max-width);
|
|
271
|
+
&:not([type="zh"]) {
|
|
272
|
+
@media (max-width: 840px) {
|
|
273
|
+
flex-direction: column;
|
|
274
|
+
align-items: center;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.cookie-notice-wrap-grid {
|
|
280
|
+
position: relative;
|
|
281
|
+
display: flex;
|
|
282
|
+
justify-content: space-between;
|
|
283
|
+
width: var(--grid-content-width);
|
|
284
|
+
padding: 24px 0;
|
|
285
|
+
margin: 0 auto;
|
|
286
|
+
&:not([type="zh"]) {
|
|
287
|
+
@media (max-width: 840px) {
|
|
288
|
+
padding: 16px 0;
|
|
289
|
+
flex-direction: column;
|
|
290
|
+
align-items: center;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.cookie-notice-left {
|
|
296
|
+
width: 60%;
|
|
297
|
+
|
|
298
|
+
@media (max-width: 1100px) {
|
|
299
|
+
width: 58%;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@media (max-width: 840px) {
|
|
303
|
+
width: 100%;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.cookie-title {
|
|
307
|
+
font-size: 16px;
|
|
308
|
+
line-height: 28px;
|
|
309
|
+
color: var(--o-color-info1);
|
|
310
|
+
font-weight: 500;
|
|
311
|
+
@media (max-width: 840px) {
|
|
312
|
+
font-size: 16px;
|
|
313
|
+
line-height: 24px;
|
|
314
|
+
text-align: center;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.cookie-desc {
|
|
319
|
+
font-size: 12px;
|
|
320
|
+
line-height: 18px;
|
|
321
|
+
color: var(--o-color-info2);
|
|
322
|
+
margin-top: 8px;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.cookie-notice-right {
|
|
327
|
+
display: flex;
|
|
328
|
+
align-items: center;
|
|
329
|
+
margin-top: 12px;
|
|
330
|
+
|
|
331
|
+
@media (max-width: 840px) {
|
|
332
|
+
width: 100%;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@media (max-width: 840px) {
|
|
336
|
+
flex-direction: column;
|
|
337
|
+
align-items: center;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.o-btn:not(:first-child) {
|
|
341
|
+
margin-left: 16px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@media (max-width: 840px) {
|
|
345
|
+
.o-btn {
|
|
346
|
+
align-self: stretch;
|
|
347
|
+
&:not(:first-child) {
|
|
348
|
+
margin-top: 12px;
|
|
349
|
+
margin-left: 0;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.cookie-notice-close {
|
|
356
|
+
&[type="en"] {
|
|
357
|
+
position: absolute;
|
|
358
|
+
top: 16px;
|
|
359
|
+
right: var(--layout-content-padding);
|
|
360
|
+
transform-origin: center;
|
|
361
|
+
}
|
|
362
|
+
cursor: pointer;
|
|
363
|
+
color: var(--o-color-info1);
|
|
364
|
+
font-size: 20px;
|
|
365
|
+
&:hover {
|
|
366
|
+
color: var(--o-color-primary2);
|
|
367
|
+
}
|
|
368
|
+
@media (max-width: 840px) {
|
|
369
|
+
font-size: 14px;
|
|
370
|
+
}
|
|
371
|
+
@include x-svg-hover;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.cookie-notice-wrap-grid .cookie-notice-close {
|
|
375
|
+
right: 0;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.cookie-dlg {
|
|
379
|
+
.cookie-dlg-content {
|
|
380
|
+
.content-item + .content-item {
|
|
381
|
+
margin-top: 24px;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.content-item {
|
|
385
|
+
.item-header {
|
|
386
|
+
display: flex;
|
|
387
|
+
align-items: center;
|
|
388
|
+
.item-title {
|
|
389
|
+
font-size: 18px;
|
|
390
|
+
line-height: 32px;
|
|
391
|
+
color: var(--o-color-info1);
|
|
392
|
+
font-weight: 500;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.item-extra {
|
|
396
|
+
font-size: 14px;
|
|
397
|
+
line-height: 22px;
|
|
398
|
+
color: var(--o-color-info3);
|
|
399
|
+
margin-left: 24px;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.item-detail {
|
|
404
|
+
font-size: 16px;
|
|
405
|
+
line-height: 28px;
|
|
406
|
+
color: var(--o-color-info2);
|
|
407
|
+
margin-top: 12px;
|
|
408
|
+
@media (max-width: 840px) {
|
|
409
|
+
font-size: 14px;
|
|
410
|
+
line-height: 21px;
|
|
411
|
+
margin-top: 8px;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
</style>
|