Skip to content

Commit

Permalink
feat(frontend): 工具箱支持资源池协议变更_mysql添加proxy TencentBlueKing#8076
Browse files Browse the repository at this point in the history
  • Loading branch information
JustaCattt committed Dec 12, 2024
1 parent a09e95c commit 203d034
Show file tree
Hide file tree
Showing 7 changed files with 5,572 additions and 5,507 deletions.
34 changes: 34 additions & 0 deletions dbm-ui/frontend/src/hooks/useCreateTicket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createTicket } from '@services/source/ticket';

import type { TicketTypes } from '@common/const';

export function useCreateTicket<T>(ticketType: TicketTypes) {
const loading = ref(false);
const router = useRouter();

const run = async (details: T, remark = '') => {
loading.value = true;
const { id } = await createTicket<T>({
ticket_type: ticketType,
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
details,
remark,
ignore_duplication: true,
});
loading.value = false;
router.push({
name: ticketType,
params: {
page: 'success',
},
query: {
ticketId: id,
},
});
};

return {
run,
loading,
};
}
18 changes: 4 additions & 14 deletions dbm-ui/frontend/src/hooks/useCreateTicket/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import { createTicket } from '@services/source/ticket';

import type * as Mongodb from './mongodb';
import type * as Mysql from './mysql';
import type * as Redis from './redis';
import type * as Sqlserver from './sqlserver';
import type * as Tendbcluster from './tendbcluster';
import type { TicketTypes } from '@common/const';

export type * from './common';

type TicketCreateDetails = Mysql.TicketCreateDetails &
Tendbcluster.TicketCreateDetails &
Redis.TicketCreateDetails &
Sqlserver.TicketCreateDetails &
Mongodb.TicketCreateDetails;

export function useCreateTicket(ticketType: keyof TicketCreateDetails) {
export function useCreateTicket<T>(ticketType: TicketTypes) {
const loading = ref(false);
const router = useRouter();

const run = async (details: TicketCreateDetails[typeof ticketType], remark = '') => {
const run = async (details: T, remark = '') => {
loading.value = true;
const { id } = await createTicket({
const { id } = await createTicket<T>({
ticket_type: ticketType,
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
details,
Expand Down
Loading

0 comments on commit 203d034

Please sign in to comment.