Skip to content

Commit 3f1db2c

Browse files
committed
fix:修复空组织判断,AI接口不鉴权和本地启动不登录等问题
1 parent 7c49f35 commit 3f1db2c

5 files changed

Lines changed: 41 additions & 16 deletions

File tree

designer-demo/engine.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const isDevelopEnv = import.meta.env.MODE?.includes('dev')
2+
13
export default {
24
id: 'engine.config',
35
theme: 'light',
@@ -7,5 +9,5 @@ export default {
79
// 是否开启 TailWindCSS 特性
810
enableTailwindCSS: true,
911
// 是否启用登录
10-
enableLogin: true
12+
enableLogin: isDevelopEnv ? false : true
1113
}

packages/common/composable/http/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ const whiteList = [
104104
'/platform-center/api/user/me',
105105
'/platform-center/api/user/tenant'
106106
]
107+
// 不鉴权名单
108+
const notAuthList = ['app-center/api/chat/completions', 'app-center/api/ai/chat', 'app-center/api/ai/search']
107109
const LoginErrorCode = ['CM004', 'CM005', 'CM006', 'CM007', 'CM336', 'CM339']
108110

109111
// 创建 AbortController 并关联到请求
@@ -189,7 +191,9 @@ const requestHandler = (config) => {
189191
return new Promise(() => {})
190192
}
191193
} else {
192-
config.headers.Authorization = `Bearer ${token}`
194+
if (!notAuthList.some((url) => config.url.includes(url))) {
195+
config.headers.Authorization = `Bearer ${token}`
196+
}
193197
}
194198

195199
// 请求结束时清理 AbortController

packages/design-core/registry.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
TemplateCenter
5858
} from './re-export'
5959

60+
const isDevelopEnv = import.meta.env.MODE?.includes('dev')
6061
window.__TINY_ENGINE_REMOVED_REGISTRY = {}
6162

6263
export default {
@@ -135,7 +136,7 @@ export default {
135136
}
136137
],
137138
enableTailwindCSS: true,
138-
enableLogin: true
139+
enableLogin: isDevelopEnv ? false : true
139140
},
140141
layout: __TINY_ENGINE_REMOVED_REGISTRY['engine.layout'] === false ? null : Layout,
141142
toolbars: [

packages/toolbars/user/src/Main.vue

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<svg-icon class="plus-circle" name="plus-circle" @click="createTenant"></svg-icon>
2020
</div>
2121
</div>
22+
<div class="tenant-tip" v-if="state.isShowTenantTip">组织名不能为空</div>
2223
<div class="user-tenant">
2324
<div class="tenant-label">选择组织</div>
2425
<div class="tenant-item">
@@ -38,14 +39,15 @@
3839
<script lang="ts">
3940
import { reactive, computed } from 'vue'
4041
import type { Component } from 'vue'
41-
import { Popover, Select, Input } from '@opentiny/vue'
42+
import { Popover, Select, Input, Tooltip } from '@opentiny/vue'
4243
import { getMetaApi, META_SERVICE, useModal } from '@opentiny/tiny-engine-meta-register'
4344
4445
export default {
4546
components: {
4647
TinyPopover: Popover as Component,
4748
TinySelect: Select,
48-
TinyInput: Input
49+
TinyInput: Input,
50+
TinyTooltip: Tooltip
4951
},
5052
props: {
5153
iconExpand: {
@@ -63,20 +65,23 @@ export default {
6365
)
6466
const state = reactive({
6567
tenantValue: getBaseInfo().tenantId,
66-
newTenant: ''
68+
newTenant: '',
69+
isShowTenantTip: false
6770
})
6871
6972
const userInfo = computed(() => getUserInfo())
7073
const tenantList = computed(() => {
7174
const info = getUserInfo()
7275
73-
return info.tenant?.map((item) => {
74-
return {
75-
...item,
76-
value: item.id,
77-
label: item.nameEn
78-
}
79-
})
76+
return Array.isArray(info?.tenant)
77+
? info.tenant?.map((item) => {
78+
return {
79+
...item,
80+
value: item.id,
81+
label: item.nameEn
82+
}
83+
})
84+
: []
8085
})
8186
8287
const logOut = () => {
@@ -85,6 +90,15 @@ export default {
8590
}
8691
8792
const createTenant = () => {
93+
if (!state.newTenant.length) {
94+
state.isShowTenantTip = true
95+
setTimeout(() => {
96+
state.isShowTenantTip = false
97+
}, 2000)
98+
99+
return
100+
}
101+
88102
getMetaApi(META_SERVICE.Http)
89103
.post('/platform-center/api/tenant/create', {
90104
nameEn: state.newTenant
@@ -158,6 +172,10 @@ export default {
158172
cursor: pointer;
159173
}
160174
}
175+
.tenant-tip {
176+
color: var(--te-toolbars-user-text-color-error);
177+
padding-left: 60px;
178+
}
161179
.tenant-label {
162180
font-size: 12px;
163181
margin-right: 6px;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
:root {
2-
--te-toolbars-user-border-bottom-color: var(--te-common-border-default);
3-
}
4-
2+
--te-toolbars-user-border-bottom-color: var(--te-common-border-default);
3+
--te-toolbars-user-text-color-error: var(--te-common-color-error);
4+
}

0 commit comments

Comments
 (0)