Skip to content

Commit 698f23c

Browse files
feat: application
1 parent 2eff491 commit 698f23c

File tree

6 files changed

+270
-113
lines changed

6 files changed

+270
-113
lines changed

ui/src/views/application-overview/component/LimitDialog.vue

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
width="650"
88
>
99
<el-form label-position="top" ref="limitFormRef" :model="form">
10-
<!-- <el-form-item
11-
:label="$t('views.applicationOverview.appInfo.LimitDialog.showSourceLabel')"
12-
@click.prevent
13-
>
14-
<el-switch size="small" v-model="form.show_source"></el-switch>
15-
</el-form-item> -->
1610
<el-form-item
1711
:label="$t('views.applicationOverview.appInfo.LimitDialog.clientQueryLimitLabel')"
1812
>
@@ -30,50 +24,7 @@
3024
$t('views.applicationOverview.appInfo.LimitDialog.timesDays')
3125
}}</span>
3226
</el-form-item>
33-
<!-- 身份验证 -->
34-
<el-form-item
35-
:label="$t('views.applicationOverview.appInfo.LimitDialog.authentication')"
36-
v-hasPermission="new ComplexPermission([], ['x-pack'], 'OR')"
37-
>
38-
<el-switch size="small" v-model="form.authentication" @change="firstGeneration"></el-switch>
39-
</el-form-item>
40-
<el-form-item
41-
prop="authentication_value"
42-
v-if="form.authentication"
43-
:label="$t('views.applicationOverview.appInfo.LimitDialog.authenticationValue')"
44-
v-hasPermission="new ComplexPermission([], ['x-pack'], 'OR')"
45-
>
46-
<el-input
47-
class="authentication-append-input"
48-
v-model="form.authentication_value"
49-
readonly
50-
style="width: 268px"
51-
disabled
52-
>
53-
<template #append>
54-
<el-tooltip :content="$t('common.copy')" placement="top">
55-
<el-button
56-
type="primary"
57-
text
58-
@click="copyClick(form.authentication_value)"
59-
style="margin: 0 4px !important"
60-
>
61-
<AppIcon iconName="app-copy"></AppIcon>
62-
</el-button>
63-
</el-tooltip>
64-
<el-tooltip :content="$t('common.refresh')" placement="top">
65-
<el-button
66-
@click="refreshAuthentication"
67-
type="primary"
68-
text
69-
style="margin: 0 4px 0 0 !important"
70-
>
71-
<el-icon><RefreshRight /></el-icon>
72-
</el-button>
73-
</el-tooltip>
74-
</template>
75-
</el-input>
76-
</el-form-item>
27+
7728
<el-form-item
7829
:label="$t('views.applicationOverview.appInfo.LimitDialog.whitelistLabel')"
7930
@click.prevent
@@ -106,12 +57,10 @@ import type { FormInstance, FormRules } from 'element-plus'
10657
import applicationApi from '@/api/application/application'
10758
import { MsgSuccess } from '@/utils/message'
10859
import { t } from '@/locales'
109-
import { copyClick } from '@/utils/clipboard'
110-
import { ComplexPermission } from '@/utils/permission/type'
11160
11261
const route = useRoute()
11362
const {
114-
params: { id }
63+
params: { id },
11564
} = route
11665
11766
const emit = defineEmits(['refresh'])
@@ -122,7 +71,7 @@ const form = ref<any>({
12271
white_active: true,
12372
white_list: '',
12473
authentication_value: '',
125-
authentication: false
74+
authentication: false,
12675
})
12776
12877
const dialogVisible = ref<boolean>(false)
@@ -133,7 +82,7 @@ watch(dialogVisible, (bool) => {
13382
form.value = {
13483
access_num: 0,
13584
white_active: true,
136-
white_list: ''
85+
white_list: '',
13786
}
13887
}
13988
})
@@ -156,7 +105,7 @@ const submit = async (formEl: FormInstance | undefined) => {
156105
white_active: form.value.white_active,
157106
access_num: form.value.access_num,
158107
authentication: form.value.authentication,
159-
authentication_value: form.value.authentication_value
108+
authentication_value: form.value.authentication_value,
160109
}
161110
applicationApi.putAccessToken(id as string, obj, loading).then((res) => {
162111
emit('refresh')
@@ -167,30 +116,8 @@ const submit = async (formEl: FormInstance | undefined) => {
167116
}
168117
})
169118
}
170-
function generateAuthenticationValue(length: number = 10) {
171-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
172-
const randomValues = new Uint8Array(length)
173-
window.crypto.getRandomValues(randomValues)
174-
return Array.from(randomValues)
175-
.map((value) => chars[value % chars.length])
176-
.join('')
177-
}
178-
function refreshAuthentication() {
179-
form.value.authentication_value = generateAuthenticationValue()
180-
}
181-
182-
function firstGeneration() {
183-
if (form.value.authentication && !form.value.authentication_value) {
184-
form.value.authentication_value = generateAuthenticationValue()
185-
}
186-
}
187-
188119
defineExpose({ open })
189120
</script>
190121
<style lang="scss" scoped>
191-
.authentication-append-input {
192-
.el-input-group__append {
193-
padding: 0 !important;
194-
}
195-
}
122+
196123
</style>

ui/src/views/application-overview/index.vue

Lines changed: 71 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<div class="p-16-24">
33
<h2 class="mb-16">{{ $t('views.applicationOverview.title') }}</h2>
4-
54
<el-scrollbar>
65
<div class="main-calc-height">
76
<el-card style="--el-card-padding: 24px">
@@ -53,7 +52,10 @@
5352
:active-text="$t('views.applicationOverview.appInfo.openText')"
5453
:inactive-text="$t('views.applicationOverview.appInfo.closeText')"
5554
:before-change="() => changeState(accessToken.is_active)"
56-
v-hasPermission="[RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.APPLICATION_EDIT.getWorkspacePermission]"
55+
v-hasPermission="[
56+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
57+
PermissionConst.APPLICATION_EDIT.getWorkspacePermission,
58+
]"
5759
/>
5860
</div>
5961

@@ -92,20 +94,35 @@
9294
<AppIcon iconName="app-create-chat" class="mr-4"></AppIcon>
9395
{{ $t('views.application.operation.toChat') }}
9496
</el-button>
95-
<el-button :disabled="!accessToken?.is_active" @click="openDialog"
96-
v-hasPermission="[RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.APPLICATION_OVERVIEW_EMBEDDED.getWorkspacePermission]"
97+
<el-button
98+
:disabled="!accessToken?.is_active"
99+
@click="openDialog"
100+
v-hasPermission="[
101+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
102+
PermissionConst.APPLICATION_OVERVIEW_EMBEDDED.getWorkspacePermission,
103+
]"
97104
>
98105
<AppIcon iconName="app-export" class="mr-4"></AppIcon>
99106
{{ $t('views.applicationOverview.appInfo.embedInWebsite') }}
100107
</el-button>
101-
<el-button @click="openLimitDialog"
102-
v-hasPermission="[RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.APPLICATION_OVERVIEW_ACCESS.getWorkspacePermission]"
108+
<!-- 访问限制 -->
109+
<el-button
110+
@click="openLimitDialog"
111+
v-hasPermission="[
112+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
113+
PermissionConst.APPLICATION_OVERVIEW_ACCESS.getWorkspacePermission,
114+
]"
103115
>
104116
<el-icon class="mr-4"><Lock /></el-icon>
105117
{{ $t('views.applicationOverview.appInfo.accessControl') }}
106118
</el-button>
107-
<el-button @click="openDisplaySettingDialog"
108-
v-hasPermission="[RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.APPLICATION_OVERVIEW_DISPLAY.getWorkspacePermission]"
119+
<!-- 显示设置 -->
120+
<el-button
121+
@click="openDisplaySettingDialog"
122+
v-hasPermission="[
123+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
124+
PermissionConst.APPLICATION_OVERVIEW_DISPLAY.getWorkspacePermission,
125+
]"
109126
>
110127
<el-icon class="mr-4"><Setting /></el-icon>
111128
{{ $t('views.applicationOverview.appInfo.displaySetting') }}
@@ -146,8 +163,12 @@
146163
</div>
147164
</div>
148165
<div>
149-
<el-button @click="openAPIKeyDialog"
150-
v-hasPermission="[RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.APPLICATION_OVERVIEW_API_KEY.getWorkspacePermission]"
166+
<el-button
167+
@click="openAPIKeyDialog"
168+
v-hasPermission="[
169+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
170+
PermissionConst.APPLICATION_OVERVIEW_API_KEY.getWorkspacePermission,
171+
]"
151172
>
152173
<el-icon class="mr-4"><Key /></el-icon>
153174
{{ $t('views.applicationOverview.appInfo.apiKey') }}</el-button
@@ -199,32 +220,33 @@
199220
:api-input-params="mapToUrlParams(apiInputParams)"
200221
/>
201222
<APIKeyDialog ref="APIKeyDialogRef" />
202-
<LimitDialog ref="LimitDialogRef" @refresh="refresh" />
203223
<EditAvatarDialog ref="EditAvatarDialogRef" @refresh="refreshIcon" />
204-
<XPackDisplaySettingDialog ref="XPackDisplaySettingDialogRef" @refresh="refresh" />
205-
<!-- v-if="user.isEnterprise()" -->
206-
<DisplaySettingDialog ref="DisplaySettingDialogRef" @refresh="refresh" />
224+
225+
<!-- 社区版访问限制 -->
226+
<component :is="currentLimitDialog" ref="LimitDialogRef" @refresh="refresh" />
227+
<!-- 显示设置 -->
228+
<component :is="currentDisplaySettingDialog" ref="DisplaySettingDialogRef" @refresh="refresh" />
207229
</div>
208230
</template>
209231
<script setup lang="ts">
210-
import { ref, computed, onMounted, watch } from 'vue'
232+
import { ref, computed, onMounted, shallowRef, nextTick } from 'vue'
211233
import { useRoute } from 'vue-router'
212234
import EmbedDialog from './component/EmbedDialog.vue'
213235
import APIKeyDialog from './component/APIKeyDialog.vue'
214236
import LimitDialog from './component/LimitDialog.vue'
237+
import XPackLimitDrawer from './xpack-component/XPackLimitDrawer.vue'
215238
import DisplaySettingDialog from './component/DisplaySettingDialog.vue'
216-
import XPackDisplaySettingDialog from './component/XPackDisplaySettingDialog.vue'
239+
import XPackDisplaySettingDialog from './xpack-component/XPackDisplaySettingDialog.vue'
217240
import EditAvatarDialog from './component/EditAvatarDialog.vue'
218241
import StatisticsCharts from './component/StatisticsCharts.vue'
219242
import applicationApi from '@/api/application/application'
220-
import overviewApi from '@/api/application/application-key'
221243
import { nowDate, beforeDay } from '@/utils/time'
222244
import { MsgSuccess, MsgConfirm } from '@/utils/message'
223245
import { copyClick } from '@/utils/clipboard'
224246
import { isAppIcon } from '@/utils/common'
225247
import useStore from '@/stores'
226248
import { t } from '@/locales'
227-
import { PermissionConst, RoleConst } from '@/utils/permission/data'
249+
import { PermissionConst, RoleConst, EditionConst } from '@/utils/permission/data'
228250
import { hasPermission } from '@/utils/permission/index'
229251
const { user, application } = useStore()
230252
const route = useRoute()
@@ -236,10 +258,7 @@ const apiUrl = window.location.origin + '/doc/chat/'
236258
237259
const baseUrl = window.location.origin + '/api/application/'
238260
239-
const DisplaySettingDialogRef = ref()
240-
const XPackDisplaySettingDialogRef = ref()
241261
const EditAvatarDialogRef = ref()
242-
const LimitDialogRef = ref()
243262
const APIKeyDialogRef = ref()
244263
const EmbedDialogRef = ref()
245264
@@ -299,13 +318,39 @@ const apiInputParams = ref([])
299318
function toUrl(url: string) {
300319
window.open(url, '_blank')
301320
}
321+
322+
// 显示设置
323+
const DisplaySettingDialogRef = ref()
324+
const currentDisplaySettingDialog = shallowRef<any>(null)
302325
function openDisplaySettingDialog() {
303-
// if (user.isEnterprise()) {
304-
XPackDisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
305-
// } else {
306-
// DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
307-
// }
326+
// 企业版和专业版
327+
if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) {
328+
currentDisplaySettingDialog.value = XPackDisplaySettingDialog
329+
} else {
330+
// 社区版
331+
currentDisplaySettingDialog.value = DisplaySettingDialog
332+
}
333+
nextTick(() => {
334+
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
335+
})
308336
}
337+
338+
// 访问限制
339+
const LimitDialogRef = ref()
340+
const currentLimitDialog = shallowRef<any>(null)
341+
function openLimitDialog() {
342+
// 企业版和专业版
343+
if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) {
344+
currentLimitDialog.value = XPackLimitDrawer
345+
} else {
346+
// 社区版
347+
currentLimitDialog.value = LimitDialog
348+
}
349+
nextTick(() => {
350+
LimitDialogRef.value.open(accessToken.value)
351+
})
352+
}
353+
309354
function openEditAvatar() {
310355
EditAvatarDialogRef.value.open(detail.value)
311356
}
@@ -370,10 +415,6 @@ async function updateAccessToken(obj: any, str: string) {
370415
})
371416
}
372417
373-
function openLimitDialog() {
374-
LimitDialogRef.value.open(accessToken.value)
375-
}
376-
377418
function openAPIKeyDialog() {
378419
APIKeyDialogRef.value.open()
379420
}

ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue renamed to ui/src/views/application-overview/xpack-component/XPackDisplaySettingDialog.vue

File renamed without changes.

0 commit comments

Comments
 (0)