chore: 新增一批接口
This commit is contained in:
@@ -5,4 +5,4 @@ ENV = 'development'
|
||||
VITE_BASE_URL = /
|
||||
|
||||
# base api url
|
||||
VITE_BASE_API_URL = 'http://8.134.216.72:8080/'
|
||||
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
||||
@@ -1,8 +1,7 @@
|
||||
# 只在生产模式中被载入
|
||||
ENV = 'production'
|
||||
|
||||
# base api url
|
||||
VITE_BASE_API_URL = 'http://127.0.0.1:8080/'
|
||||
|
||||
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
||||
VITE_BASE_URL = /
|
||||
VITE_BASE_URL = /
|
||||
|
||||
VITE_BASE_API_URL = 'https://custom-chart-api.shiyuegame.com/'
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
"@iconify/vue": "^4.3.0",
|
||||
"@iframe-resizer/parent": "^5.3.3",
|
||||
"@sy/low-code-renderer-adapter": "workspace:*",
|
||||
"@tanstack/query-core": "^5.66.4",
|
||||
"@tanstack/vue-query": "^5.66.9",
|
||||
"@vueuse/core": "~11.1.0",
|
||||
"ant-design-vue": "~4.2.6",
|
||||
"axios": "~1.7.9",
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const getApplicationList = async () => {
|
||||
const response = await instance.get('/application/list');
|
||||
const response = await instance.get('/api/v1/applications');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createApplication = async (data: any) => {
|
||||
const response = await instance.post('/api/v1/applications', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateApplication = async (id: string, data: any) => {
|
||||
const response = await instance.put(`/api/v1/applications/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteApplication = async (id: string) => {
|
||||
console.log(id);
|
||||
const response = await instance.delete(`/api/v1/applications/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export * from './application';
|
||||
export * from './project';
|
||||
export * from './user';
|
||||
|
||||
21
apps/platform/src/io/project.ts
Normal file
21
apps/platform/src/io/project.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const getProjectList = async () => {
|
||||
const response = await instance.get('/api/v1/projects');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createProject = async (data: any) => {
|
||||
const response = await instance.post('/api/v1/projects', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateProject = async (id: string, data: any) => {
|
||||
const response = await instance.put(`/api/v1/projects/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteProject = async (id: string) => {
|
||||
const response = await instance.delete(`/api/v1/projects/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
11
apps/platform/src/io/user.ts
Normal file
11
apps/platform/src/io/user.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const login = async (data: { username: string; password: string }) => {
|
||||
const response = await instance.post('/login', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const logout = async () => {
|
||||
const response = await instance.post('/logout');
|
||||
return response.data;
|
||||
};
|
||||
@@ -4,6 +4,8 @@ import dayjs from 'dayjs';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import { VueQueryPlugin } from '@tanstack/vue-query';
|
||||
|
||||
import App from './App.vue';
|
||||
import { setupRouter } from './router';
|
||||
import { setupIcons } from './components/basic/icon';
|
||||
@@ -17,6 +19,7 @@ dayjs.extend(timezone);
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(VueQueryPlugin);
|
||||
function setupPlugins() {
|
||||
// 安装图标
|
||||
setupIcons();
|
||||
|
||||
@@ -29,6 +29,16 @@ const routes: Array<RouteRecordRaw> = [
|
||||
},
|
||||
component: () => import('@/components/renderer-adapter/index.vue'),
|
||||
},
|
||||
{
|
||||
path: 'add',
|
||||
name: `${moduleName}-add`,
|
||||
meta: {
|
||||
title: '添加应用',
|
||||
keepAlive: true,
|
||||
icon: 'ant-design:list',
|
||||
},
|
||||
component: () => import('@/views/application/add.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -2,5 +2,6 @@ import dashboard from './dashboard';
|
||||
import user from './user';
|
||||
import micro from './micro';
|
||||
import application from './application';
|
||||
import project from './project';
|
||||
|
||||
export default [...dashboard, ...user, ...micro, ...application];
|
||||
export default [...dashboard, ...user, ...micro, ...application, ...project];
|
||||
|
||||
29
apps/platform/src/router/routes/modules/project.ts
Normal file
29
apps/platform/src/router/routes/modules/project.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
// 微前端路由
|
||||
const moduleName = 'project';
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/project',
|
||||
name: moduleName,
|
||||
meta: {
|
||||
title: '项目管理',
|
||||
icon: 'ant-design:appstore-outlined',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'add',
|
||||
name: `${moduleName}-add`,
|
||||
meta: {
|
||||
title: '添加项目',
|
||||
keepAlive: true,
|
||||
icon: 'ant-design:list',
|
||||
},
|
||||
component: () => import('@/views/project/add.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
||||
@@ -3,7 +3,8 @@ import { defineStore } from 'pinia';
|
||||
import { useSSEStore } from './sse';
|
||||
import { store } from '@/store';
|
||||
import { resetRouter } from '@/router';
|
||||
import { userLogin, userLogout } from '@/io';
|
||||
import { login, logout } from '@/io';
|
||||
|
||||
export const useUserStore = defineStore(
|
||||
'user',
|
||||
() => {
|
||||
@@ -28,7 +29,7 @@ export const useUserStore = defineStore(
|
||||
};
|
||||
/** 登录 */
|
||||
const login = async (params: any) => {
|
||||
const data = await userLogin(params);
|
||||
const data = await login(params);
|
||||
console.log('data', data);
|
||||
// @ts-ignore
|
||||
setToken(data.msg);
|
||||
@@ -36,7 +37,7 @@ export const useUserStore = defineStore(
|
||||
/** 登出 */
|
||||
const logout = async () => {
|
||||
sseStore.closeEventSource();
|
||||
await userLogout();
|
||||
await logout();
|
||||
clearLoginStatus();
|
||||
};
|
||||
|
||||
|
||||
51
apps/platform/src/views/application/add.vue
Normal file
51
apps/platform/src/views/application/add.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery, useMutation } from '@tanstack/vue-query';
|
||||
import { getApplicationList, createApplication, deleteApplication } from '@/io';
|
||||
|
||||
const addData = {
|
||||
name: 'test',
|
||||
active: true,
|
||||
};
|
||||
|
||||
const {
|
||||
data: appList,
|
||||
isError,
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useQuery({
|
||||
queryKey: ['applicationList'],
|
||||
queryFn: getApplicationList,
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
const { mutate: createApp, isLoading: isCreating } = useMutation({
|
||||
mutationFn: createApplication,
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
mutate: deleteApp,
|
||||
isLoading: isDeleting,
|
||||
error: deleteError,
|
||||
} = useMutation({
|
||||
mutationFn: deleteApplication,
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px">
|
||||
<div v-if="isLoading">加载中...</div>
|
||||
<div v-else-if="isError">加载失败</div>
|
||||
<div v-else>
|
||||
{{ appList }}
|
||||
</div>
|
||||
<Button type="primary" :loading="isCreating" @click="createApp(addData)"> 添加应用 </Button>
|
||||
<Button type="primary" @click="refetch">重新获取</Button>
|
||||
<Button type="primary" :loading="isDeleting" @click="deleteApp('3')"> 删除应用 </Button>
|
||||
</div>
|
||||
</template>
|
||||
0
apps/platform/src/views/application/list.vue
Normal file
0
apps/platform/src/views/application/list.vue
Normal file
53
apps/platform/src/views/project/add.vue
Normal file
53
apps/platform/src/views/project/add.vue
Normal file
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery, useMutation } from '@tanstack/vue-query';
|
||||
import { getProjectList, createProject, deleteProject } from '@/io';
|
||||
|
||||
const addData = {
|
||||
application_id: 3,
|
||||
description: 'test project',
|
||||
name: 'test project',
|
||||
platform: 'web',
|
||||
};
|
||||
|
||||
const {
|
||||
data: projectList,
|
||||
isError,
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useQuery({
|
||||
queryKey: ['getProjectList'],
|
||||
queryFn: getProjectList,
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
const { mutate: createProjectMutation, isLoading: isCreating } = useMutation({
|
||||
mutationFn: createProject,
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: deleteProjectMutation, isLoading: isDeleting } = useMutation({
|
||||
mutationFn: deleteProject,
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px">
|
||||
<div v-if="isLoading">加载中...</div>
|
||||
<div v-else-if="isError">加载失败</div>
|
||||
<div v-else>
|
||||
{{ projectList }}
|
||||
</div>
|
||||
<Button type="primary" :loading="isCreating" @click="createProjectMutation(addData)">
|
||||
添加项目
|
||||
</Button>
|
||||
<Button type="primary" @click="refetch">重新获取</Button>
|
||||
<Button type="primary" :loading="isDeleting" @click="deleteProjectMutation('3')">
|
||||
删除项目
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -45,6 +45,13 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
server: {
|
||||
open: true,
|
||||
host: true,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'https://custom-chart-pre-api.shiyue.com',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
|
||||
Reference in New Issue
Block a user