diff --git a/ui/src/components/card-box/index.vue b/ui/src/components/card-box/index.vue index dc1eb6996..f987bc7f1 100644 --- a/ui/src/components/card-box/index.vue +++ b/ui/src/components/card-box/index.vue @@ -18,6 +18,9 @@ +
+ +
@@ -109,5 +112,10 @@ function subHoveredEnter() { width: 100%; box-sizing: border-box; } + .status-tag { + position: absolute; + right: 16px; + top: 15px; + } } diff --git a/ui/src/locales/lang/en-US/views/application.ts b/ui/src/locales/lang/en-US/views/application.ts index 175cdd0fb..bba34454f 100644 --- a/ui/src/locales/lang/en-US/views/application.ts +++ b/ui/src/locales/lang/en-US/views/application.ts @@ -14,7 +14,10 @@ export default { searchBar: { placeholder: 'Search by name', }, - + status: { + published: 'Published', + unpublished: 'Unpublished', + }, setting: { demo: 'Demo', }, diff --git a/ui/src/locales/lang/zh-CN/views/application.ts b/ui/src/locales/lang/zh-CN/views/application.ts index 54a10ae9e..35d1544be 100644 --- a/ui/src/locales/lang/zh-CN/views/application.ts +++ b/ui/src/locales/lang/zh-CN/views/application.ts @@ -13,6 +13,10 @@ export default { searchBar: { placeholder: '按名称搜索', }, + status: { + published: '已发布', + unpublished: '未发布', + }, setting: { demo: '演示', }, diff --git a/ui/src/locales/lang/zh-Hant/views/application.ts b/ui/src/locales/lang/zh-Hant/views/application.ts index 51cc720dc..6c3d5bc2c 100644 --- a/ui/src/locales/lang/zh-Hant/views/application.ts +++ b/ui/src/locales/lang/zh-Hant/views/application.ts @@ -12,6 +12,10 @@ export default { copy: '副本', searchBar: { placeholder: '按名稱搜尋', + }, + status: { + published: '已发布', + unpublished: '未发布', }, setting: { demo: '示範', diff --git a/ui/src/stores/index.ts b/ui/src/stores/index.ts index fd8909c76..b04575e49 100644 --- a/ui/src/stores/index.ts +++ b/ui/src/stores/index.ts @@ -9,6 +9,7 @@ import usePromptStore from './modules/prompt' import useProblemStore from './modules/problem' import useParagraphStore from './modules/paragraph' import useDocumentStore from './modules/document' +import useApplicationStore from './modules/application' const useStore = () => ({ common: useCommonStore(), @@ -22,6 +23,7 @@ const useStore = () => ({ problem: useProblemStore(), paragraph: useParagraphStore(), document: useDocumentStore(), + application: useApplicationStore(), }) export default useStore diff --git a/ui/src/stores/modules/application.ts b/ui/src/stores/modules/application.ts new file mode 100644 index 000000000..8de8297ab --- /dev/null +++ b/ui/src/stores/modules/application.ts @@ -0,0 +1,139 @@ +import { defineStore } from 'pinia' +import applicationApi from '@/api/application/application' +import applicationXpackApi from '@/api/application/application-xpack' +import { type Ref } from 'vue' +import { getBrowserLang } from '@/locales/index' +import useUserStore from './user' +const useApplicationStore = defineStore('application', { + state: () => ({ + location: `${window.location.origin}/ui/chat/`, + }), + actions: { + async asyncGetAllApplication() { + return new Promise((resolve, reject) => { + applicationApi + .getAllAppilcation() + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) + }, + + async asyncGetApplicationDetail(id: string, loading?: Ref) { + return new Promise((resolve, reject) => { + applicationApi + .getApplicationDetail(id, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) + }, + + async asyncGetApplicationDataset(id: string, loading?: Ref) { + return new Promise((resolve, reject) => { + applicationApi + .getApplicationDataset(id, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) + }, + + async asyncGetAccessToken(id: string, loading?: Ref) { + return new Promise((resolve, reject) => { + const user = useUserStore() + if (user.isEnterprise()) { + applicationXpackApi + .getAccessToken(id, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + } else { + applicationApi + .getAccessToken(id, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + } + }) + }, + + async asyncGetAppProfile(loading?: Ref) { + return new Promise((resolve, reject) => { + applicationApi + .getAppProfile(loading) + .then((res) => { + sessionStorage.setItem('language', res.data?.language || getBrowserLang()) + resolve(res) + }) + .catch((error) => { + reject(error) + }) + }) + }, + + async asyncAppAuthentication( + token: string, + loading?: Ref, + authentication_value?: any, + ) { + return new Promise((resolve, reject) => { + applicationApi + .postAppAuthentication(token, loading, authentication_value) + .then((res) => { + localStorage.setItem(`${token}-accessToken`, res.data) + sessionStorage.setItem(`${token}-accessToken`, res.data) + resolve(res) + }) + .catch((error) => { + reject(error) + }) + }) + }, + async refreshAccessToken(token: string) { + this.asyncAppAuthentication(token) + }, + // 修改应用 + async asyncPutApplication(id: string, data: any, loading?: Ref) { + return new Promise((resolve, reject) => { + applicationApi + .putApplication(id, data, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) + }, + async validatePassword(id: string, password: string, loading?: Ref) { + return new Promise((resolve, reject) => { + applicationApi + .validatePassword(id, password, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) + }, + }, +}) + +export default useApplicationStore diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index f5ad016bd..68ac02933 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -19,9 +19,9 @@ style="width: 120px" @change="search_type_change" > - + - + - + {{ $t('common.create') }} - +
- - - +
- + +