diff --git a/src/service/api/auth.ts b/src/service/api/auth.ts index 80b4a67..f9c7c2e 100644 --- a/src/service/api/auth.ts +++ b/src/service/api/auth.ts @@ -84,3 +84,67 @@ export function doGetCheckCode() { url: '/code' }); } +/** Get rate limit list */ +export function fetchRateLimitList() { + return request({ + url: '/system/rateLimit/list', + method: 'get' + }); +} +/** Add rate limit config */ +export function addRateLimit(data: Api.Auth.RateLimitAdd) { + return request({ + url: '/system/rateLimit', + method: 'post', + data + }); +} + +/** Edit rate limit config */ +export function editRateLimit(data: Api.Auth.RateLimitAdd & { id: number }) { + return request({ + url: '/system/rateLimit', + method: 'put', + data + }); +} + +/** Remove rate limit config */ +export function removeRateLimit(ids: number | number[]) { + return request({ + url: `/system/rateLimit/${ids}`, + method: 'delete' + }); +} +/** Get package list */ +export function fetchPackageList() { + return request({ + url: '/u/package/list', + method: 'get' + }); +} +/** Add package config */ +export function addPackage(data: Api.Auth.PackageAdd) { + return request({ + url: '/system/package', + method: 'post', + data + }); +} +/** 修改套餐 */ +export function updatePackage(data: Api.Auth.PackageAdd & { id: string }) { + return request({ + url: '/system/package', + method: 'put', + data + }); +} + +/** 删除套餐 */ +export function deletePackage(id: string) { + return request({ + url: `/system/package/${id}`, + method: 'delete' + }); +} + diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index 99554e0..9a2f62b 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -157,6 +157,62 @@ declare namespace Api { phonenumber?:string; authType: string; } + interface RateLimit { + id: number; + rateLimitName: string; + upLimit: number; + downLimit: number; + upLimitEnable: boolean; + downLimitEnable: boolean; + createBy: number; + createTime: string; + updateBy: number; + updateTime: string; + delFlag: boolean; + } + interface RateLimitAdd { + rateLimitName: string; + upLimitEnable: boolean; + downLimitEnable: boolean; + upLimit: number; + downLimit: number; + } + interface Package { + id: string; + packageName: string; + periodNum: number; + periodType: number; + price: number; + trafficEnable: boolean; + traffic: number; + rateLimitEnable: boolean; + rateLimitId?: number; + durationEnable: boolean; + duration: number; + clientNumEnable: boolean; + clientNum: number; + packageEnable: boolean; + createBy: number; + createTime: string; + updateBy: number; + updateTime: string; + delFlag: boolean; + } + interface PackageAdd { + packageName: string; + periodNum: number; + periodType: number; + price: number; + trafficEnable: boolean; + traffic: number; + rateLimitEnable: boolean; + rateLimitId?: number; + durationEnable: boolean; + duration: number; + clientNumEnable: boolean; + clientNum: number; + packageEnable: boolean; + } } /** @@ -422,5 +478,6 @@ declare namespace Api { type DictSearchParams = Partial & CommonSearchParams>; type DictList = Common.PaginatingQueryRecord; + } } diff --git a/src/typings/auto-imports.d.ts b/src/typings/auto-imports.d.ts index b08221e..7b675cb 100644 --- a/src/typings/auto-imports.d.ts +++ b/src/typings/auto-imports.d.ts @@ -10,6 +10,8 @@ declare global { const $notification: typeof import('ant-design-vue')['notification'] const EffectScope: typeof import('vue')['EffectScope'] const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate'] + const addPackage: typeof import('../service/api/auth')['addPackage'] + const addRateLimit: typeof import('../service/api/auth')['addRateLimit'] const addThemeVarsToHtml: typeof import('../store/modules/theme/shared')['addThemeVarsToHtml'] const afterAll: typeof import('vitest')['afterAll'] const afterEach: typeof import('vitest')['afterEach'] @@ -17,6 +19,8 @@ declare global { const assign: typeof import('lodash-es')['assign'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] + const bandwidthFactors: typeof import('../utils/units')['bandwidthFactors'] + const bandwidthUnits: typeof import('../utils/units')['bandwidthUnits'] const beforeAll: typeof import('vitest')['beforeAll'] const beforeEach: typeof import('vitest')['beforeEach'] const chai: typeof import('vitest')['chai'] @@ -30,6 +34,9 @@ declare global { const computedWithControl: typeof import('@vueuse/core')['computedWithControl'] const controlledComputed: typeof import('@vueuse/core')['controlledComputed'] const controlledRef: typeof import('@vueuse/core')['controlledRef'] + const convertBandwidth: typeof import('../utils/units')['convertBandwidth'] + const convertStorage: typeof import('../utils/units')['convertStorage'] + const convertTime: typeof import('../utils/units')['convertTime'] const createApp: typeof import('vue')['createApp'] const createEventHook: typeof import('@vueuse/core')['createEventHook'] const createGlobalState: typeof import('@vueuse/core')['createGlobalState'] @@ -48,6 +55,7 @@ declare global { const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] const defineComponent: typeof import('vue')['defineComponent'] const defineStore: typeof import('pinia')['defineStore'] + const deletePackage: typeof import('../service/api/auth')['deletePackage'] const describe: typeof import('vitest')['describe'] const doAddDept: typeof import('../service/api/dept')['doAddDept'] const doAddDict: typeof import('../service/api/dict')['doAddDict'] @@ -90,6 +98,7 @@ declare global { const doPutRole: typeof import('../service/api/role')['doPutRole'] const doPutUser: typeof import('../service/api/user')['doPutUser'] const eagerComputed: typeof import('@vueuse/core')['eagerComputed'] + const editRateLimit: typeof import('../service/api/auth')['editRateLimit'] const effectScope: typeof import('vue')['effectScope'] const emptyInfo: typeof import('../store/modules/auth/shared')['emptyInfo'] const expect: typeof import('vitest')['expect'] @@ -101,12 +110,17 @@ declare global { const fetchGetMenuTree: typeof import('../service/api/menu')['fetchGetMenuTree'] const fetchIsRouteExist: typeof import('../service/api/route')['fetchIsRouteExist'] const fetchLogin: typeof import('../service/api/auth')['fetchLogin'] + const fetchPackageList: typeof import('../service/api/auth')['fetchPackageList'] + const fetchRateLimitList: typeof import('../service/api/auth')['fetchRateLimitList'] const fetchRefreshToken: typeof import('../service/api/auth')['fetchRefreshToken'] const fetchRegister: typeof import('../service/api/auth')['fetchRegister'] const filterAuthRoutesByRoles: typeof import('../store/modules/route/shared')['filterAuthRoutesByRoles'] const filterTabsById: typeof import('../store/modules/tab/shared')['filterTabsById'] const filterTabsByIds: typeof import('../store/modules/tab/shared')['filterTabsByIds'] const findTabByRouteName: typeof import('../store/modules/tab/shared')['findTabByRouteName'] + const formatBandwidth: typeof import('../utils/units')['formatBandwidth'] + const formatStorage: typeof import('../utils/units')['formatStorage'] + const formatTime: typeof import('../utils/units')['formatTime'] const getActivePinia: typeof import('pinia')['getActivePinia'] const getAllTabs: typeof import('../store/modules/tab/shared')['getAllTabs'] const getAntdTheme: typeof import('../store/modules/theme/shared')['getAntdTheme'] @@ -186,6 +200,7 @@ declare global { const refThrottled: typeof import('@vueuse/core')['refThrottled'] const refWithControl: typeof import('@vueuse/core')['refWithControl'] const removeEmptyChildren: typeof import('../utils/menu')['removeEmptyChildren'] + const removeRateLimit: typeof import('../service/api/auth')['removeRateLimit'] const resolveComponent: typeof import('vue')['resolveComponent'] const resolveRef: typeof import('@vueuse/core')['resolveRef'] const resolveUnref: typeof import('@vueuse/core')['resolveUnref'] @@ -197,6 +212,8 @@ declare global { const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] const sortRoutesByOrder: typeof import('../store/modules/route/shared')['sortRoutesByOrder'] + const storageFactors: typeof import('../utils/units')['storageFactors'] + const storageUnits: typeof import('../utils/units')['storageUnits'] const storeToRefs: typeof import('pinia')['storeToRefs'] const suite: typeof import('vitest')['suite'] const syncRef: typeof import('@vueuse/core')['syncRef'] @@ -205,6 +222,8 @@ declare global { const test: typeof import('vitest')['test'] const throttledRef: typeof import('@vueuse/core')['throttledRef'] const throttledWatch: typeof import('@vueuse/core')['throttledWatch'] + const timeFactors: typeof import('../utils/units')['timeFactors'] + const timeUnits: typeof import('../utils/units')['timeUnits'] const toRaw: typeof import('vue')['toRaw'] const toReactive: typeof import('@vueuse/core')['toReactive'] const toRef: typeof import('vue')['toRef'] @@ -222,10 +241,12 @@ declare global { const tryOnMounted: typeof import('@vueuse/core')['tryOnMounted'] const tryOnScopeDispose: typeof import('@vueuse/core')['tryOnScopeDispose'] const tryOnUnmounted: typeof import('@vueuse/core')['tryOnUnmounted'] + const unitFactors: typeof import('../utils/bandwidth')['unitFactors'] const unref: typeof import('vue')['unref'] const unrefElement: typeof import('@vueuse/core')['unrefElement'] const until: typeof import('@vueuse/core')['until'] const updateLocaleOfGlobalMenus: typeof import('../store/modules/route/shared')['updateLocaleOfGlobalMenus'] + const updatePackage: typeof import('../service/api/auth')['updatePackage'] const updateTabByI18nKey: typeof import('../store/modules/tab/shared')['updateTabByI18nKey'] const updateTabsByI18nKey: typeof import('../store/modules/tab/shared')['updateTabsByI18nKey'] const useActiveElement: typeof import('@vueuse/core')['useActiveElement'] diff --git a/src/views/billing/package/index.vue b/src/views/billing/package/index.vue new file mode 100644 index 0000000..85ace19 --- /dev/null +++ b/src/views/billing/package/index.vue @@ -0,0 +1,546 @@ + + + + +