Skip to content

Commit 649e2ce

Browse files
feat: application
1 parent e6e3acd commit 649e2ce

File tree

9 files changed

+324
-116
lines changed

9 files changed

+324
-116
lines changed

ui/src/components/card-box/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
</slot>
1919
<slot name="subTitle"> </slot>
2020
</div>
21+
<div class="status-tag">
22+
<slot name="tag"> </slot>
23+
</div>
2124
</div>
2225
</slot>
2326
</div>
@@ -109,5 +112,10 @@ function subHoveredEnter() {
109112
width: 100%;
110113
box-sizing: border-box;
111114
}
115+
.status-tag {
116+
position: absolute;
117+
right: 16px;
118+
top: 15px;
119+
}
112120
}
113121
</style>

ui/src/locales/lang/en-US/views/application.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export default {
1414
searchBar: {
1515
placeholder: 'Search by name',
1616
},
17-
17+
status: {
18+
published: 'Published',
19+
unpublished: 'Unpublished',
20+
},
1821
setting: {
1922
demo: 'Demo',
2023
},

ui/src/locales/lang/zh-CN/views/application.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export default {
1313
searchBar: {
1414
placeholder: '按名称搜索',
1515
},
16+
status: {
17+
published: '已发布',
18+
unpublished: '未发布',
19+
},
1620
setting: {
1721
demo: '演示',
1822
},

ui/src/locales/lang/zh-Hant/views/application.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export default {
1212
copy: '副本',
1313
searchBar: {
1414
placeholder: '按名稱搜尋',
15+
},
16+
status: {
17+
published: '已发布',
18+
unpublished: '未发布',
1519
},
1620
setting: {
1721
demo: '示範',

ui/src/stores/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import usePromptStore from './modules/prompt'
99
import useProblemStore from './modules/problem'
1010
import useParagraphStore from './modules/paragraph'
1111
import useDocumentStore from './modules/document'
12+
import useApplicationStore from './modules/application'
1213

1314
const useStore = () => ({
1415
common: useCommonStore(),
@@ -22,6 +23,7 @@ const useStore = () => ({
2223
problem: useProblemStore(),
2324
paragraph: useParagraphStore(),
2425
document: useDocumentStore(),
26+
application: useApplicationStore(),
2527
})
2628

2729
export default useStore
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import { defineStore } from 'pinia'
2+
import applicationApi from '@/api/application/application'
3+
import applicationXpackApi from '@/api/application/application-xpack'
4+
import { type Ref } from 'vue'
5+
import { getBrowserLang } from '@/locales/index'
6+
import useUserStore from './user'
7+
const useApplicationStore = defineStore('application', {
8+
state: () => ({
9+
location: `${window.location.origin}/ui/chat/`,
10+
}),
11+
actions: {
12+
async asyncGetAllApplication() {
13+
return new Promise((resolve, reject) => {
14+
applicationApi
15+
.getAllAppilcation()
16+
.then((data) => {
17+
resolve(data)
18+
})
19+
.catch((error) => {
20+
reject(error)
21+
})
22+
})
23+
},
24+
25+
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
26+
return new Promise((resolve, reject) => {
27+
applicationApi
28+
.getApplicationDetail(id, loading)
29+
.then((data) => {
30+
resolve(data)
31+
})
32+
.catch((error) => {
33+
reject(error)
34+
})
35+
})
36+
},
37+
38+
async asyncGetApplicationDataset(id: string, loading?: Ref<boolean>) {
39+
return new Promise((resolve, reject) => {
40+
applicationApi
41+
.getApplicationDataset(id, loading)
42+
.then((data) => {
43+
resolve(data)
44+
})
45+
.catch((error) => {
46+
reject(error)
47+
})
48+
})
49+
},
50+
51+
async asyncGetAccessToken(id: string, loading?: Ref<boolean>) {
52+
return new Promise((resolve, reject) => {
53+
const user = useUserStore()
54+
if (user.isEnterprise()) {
55+
applicationXpackApi
56+
.getAccessToken(id, loading)
57+
.then((data) => {
58+
resolve(data)
59+
})
60+
.catch((error) => {
61+
reject(error)
62+
})
63+
} else {
64+
applicationApi
65+
.getAccessToken(id, loading)
66+
.then((data) => {
67+
resolve(data)
68+
})
69+
.catch((error) => {
70+
reject(error)
71+
})
72+
}
73+
})
74+
},
75+
76+
async asyncGetAppProfile(loading?: Ref<boolean>) {
77+
return new Promise((resolve, reject) => {
78+
applicationApi
79+
.getAppProfile(loading)
80+
.then((res) => {
81+
sessionStorage.setItem('language', res.data?.language || getBrowserLang())
82+
resolve(res)
83+
})
84+
.catch((error) => {
85+
reject(error)
86+
})
87+
})
88+
},
89+
90+
async asyncAppAuthentication(
91+
token: string,
92+
loading?: Ref<boolean>,
93+
authentication_value?: any,
94+
) {
95+
return new Promise((resolve, reject) => {
96+
applicationApi
97+
.postAppAuthentication(token, loading, authentication_value)
98+
.then((res) => {
99+
localStorage.setItem(`${token}-accessToken`, res.data)
100+
sessionStorage.setItem(`${token}-accessToken`, res.data)
101+
resolve(res)
102+
})
103+
.catch((error) => {
104+
reject(error)
105+
})
106+
})
107+
},
108+
async refreshAccessToken(token: string) {
109+
this.asyncAppAuthentication(token)
110+
},
111+
// 修改应用
112+
async asyncPutApplication(id: string, data: any, loading?: Ref<boolean>) {
113+
return new Promise((resolve, reject) => {
114+
applicationApi
115+
.putApplication(id, data, loading)
116+
.then((data) => {
117+
resolve(data)
118+
})
119+
.catch((error) => {
120+
reject(error)
121+
})
122+
})
123+
},
124+
async validatePassword(id: string, password: string, loading?: Ref<boolean>) {
125+
return new Promise((resolve, reject) => {
126+
applicationApi
127+
.validatePassword(id, password, loading)
128+
.then((data) => {
129+
resolve(data)
130+
})
131+
.catch((error) => {
132+
reject(error)
133+
})
134+
})
135+
},
136+
},
137+
})
138+
139+
export default useApplicationStore

0 commit comments

Comments
 (0)