index.vue
5.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<script lang="ts" setup>
import { onMounted } from 'vue';
import { Spin, Modal, Button, Input, Row, Col } from 'ant-design-vue';
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { checkShareAccessToken, sharePageLogin, getShareContent } from '/@/api/sys/share';
import { ShareRouteParams } from '/@/api/sys/model/shareModel';
import { useUserStore } from '/@/store/modules/user';
import { BasicForm, useForm } from '/@/components/Form';
import { FieldsEnum } from '/@/views/common/ShareModal/config';
import BoardDetail from '/@/views/visual/board/detail/index.vue';
import { useI18n } from '/@/hooks/web/useI18n';
const loading = ref(true);
const ROUTE = useRoute();
const contentData = ref<any>();
const canLoadComponent = ref(false);
const modelVisable = ref(false);
// const [register, { openModal }] = useModal();
const { t } = useI18n(); // 加载国际化
const [registerForm, { getFieldsValue }] = useForm({
schemas: [
{
field: FieldsEnum.ACCESS_CREDENTIALS,
component: 'Input',
label: t('common.accessToken'),
slot: 'tokenInput',
componentProps: {
placeholder: t('common.placeInputAccessToken'),
},
},
],
showActionButtonGroup: false,
layout: 'vertical',
baseColProps: { span: 24 },
});
const userStore = useUserStore();
const getShareToken = async () => {
const { params } = ROUTE;
const { publicId } = params as Partial<ShareRouteParams>;
const { token, refreshToken } = await sharePageLogin(publicId!);
userStore.storeShareToken(token, refreshToken);
};
const getCheckNeedAccessToken = async () => {
const { params } = ROUTE;
loading.value = true;
const { viewType, id } = params as Partial<ShareRouteParams>;
const { data } = await checkShareAccessToken(viewType!, id!);
data ? (modelVisable.value = true) : await getContentData();
};
const getContentLoading = ref(false);
const getContentData = async () => {
try {
getContentLoading.value = true;
const { params } = ROUTE;
const { id } = params as unknown as ShareRouteParams;
const value = getFieldsValue() as Record<'accessCredentials', string>;
const result = await getShareContent({ id, ...value });
contentData.value = result;
loading.value = false;
canLoadComponent.value = true;
// openModal(false);
modelVisable.value = false;
} catch (error) {
} finally {
getContentLoading.value = false;
}
};
const handleSubmit = async () => {
await getContentData();
};
onMounted(async () => {
await getShareToken();
await getCheckNeedAccessToken();
});
</script>
<template>
<Modal
v-model:visible="modelVisable"
centered
:title="null"
:close-icon="null"
width="350px"
:footer="null"
wrapClassName="share-page-token-modal"
>
<section class="w-full h-full flex flex-col p-8 justify-center items-center">
<BasicForm @register="registerForm" class="w-full" @keyup.enter="handleSubmit">
<template #tokenInput="{ field, model }">
<Input.Group>
<Row>
<Col :span="18">
<Input.Password
v-model:value="model[field]"
:placeholder="t('common.placeInputAccessToken')"
/>
</Col>
<Col :span="6">
<Button
class="w-full !flex justify-center items-center"
:loading="getContentLoading"
type="primary"
@click="handleSubmit"
>
<svg
t="1682068997810"
class="icon transform rotate-180"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="79416"
width="24"
height="24"
>
<path
d="M512 928H128c-19.2 0-32-12.8-32-32V128c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32s-12.8 32-32 32H160v704h352c19.2 0 32 12.8 32 32s-12.8 32-32 32z"
fill="#fff"
p-id="79417"
/>
<path
d="M534.4 736c-9.6 0-16-3.2-22.4-9.6l-192-192c-12.8-12.8-12.8-32 0-44.8l192-192c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L387.2 512l169.6 169.6c12.8 12.8 12.8 32 0 44.8-6.4 6.4-16 9.6-22.4 9.6z"
fill="#fff"
p-id="79418"
/>
<path
d="M896 544H342.4c-19.2 0-32-12.8-32-32s12.8-32 32-32H896c19.2 0 32 12.8 32 32s-12.8 32-32 32z"
fill="#fff"
p-id="79419"
/>
</svg>
</Button>
</Col>
</Row>
</Input.Group>
</template>
</BasicForm>
</section>
</Modal>
<Spin
:spinning="loading"
tip="正在加载中..."
size="large"
class="!flex justify-center items-center w-full h-full share-full-loading"
>
<BoardDetail v-if="canLoadComponent" :value="contentData" />
</Spin>
</template>
<style lang="less">
.share-page-token-modal {
.ant-modal-close {
display: none;
}
}
</style>