Skip to content

Commit

Permalink
Merge pull request #213 from little3201/develop
Browse files Browse the repository at this point in the history
添加页面
  • Loading branch information
little3201 authored Nov 26, 2024
2 parents 569fae1 + 7d5f48d commit 1669f90
Show file tree
Hide file tree
Showing 70 changed files with 1,501 additions and 299 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/node_modules
.eslintrc.cjs
/src-ssr
/quasar.config.*.temporary.compiled*
/quasar.config.*
.temporary.compiled*
Binary file modified .yarn/install-state.gz
Binary file not shown.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
"build": "quasar build"
},
"dependencies": {
"@quasar/extras": "^1.16.11",
"@quasar/extras": "^1.16.13",
"apexcharts": "^3.54.1",
"axios": "^1.7.3",
"highlight.js": "^11.10.0",
"lottie-web": "^5.12.2",
"pinia": "^2.1.7",
"quasar": "^2.17.1",
"quasar": "^2.17.4",
"vue": "^3.5.12",
"vue-i18n": "^10.0.4",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@quasar/app-vite": "^1.10.2",
"@quasar/app-vite": "^1.11.0",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"autoprefixer": "^10.4.19",
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion quasar.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = configure(function (ctx) {
// directives: [],

// Quasar plugins
plugins: ['Notify', 'Cookies']
plugins: ['Notify']
},

// animations: 'all', // --- includes all animations
Expand Down
2 changes: 1 addition & 1 deletion src/api/access-logs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/audit-logs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/authentication.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'

/**
* Sign in
Expand Down
2 changes: 1 addition & 1 deletion src/api/dictionaries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination, Dictionary } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination, File } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/groups.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination, Group } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/operation-logs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/privileges.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/regions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination, Region } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/roles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination, Role } from 'src/models'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/scheduler-logs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination } from 'src/models'

/**
Expand Down
107 changes: 107 additions & 0 deletions src/api/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/constants'
import type { Pagination, Schema, Field } from 'src/models'

/**
* Retrieve rows
* @param pagination Pagination and sort parameters
* @param filters Optional filter or sort parameters
* @param filters Optional filter or sort parameters
* @returns Rows data
*/
export const retrieveSchemas = (pagination: Pagination, filters?: object) => {
return api.get(SERVER_URL.SCHEMA, { params: { ...pagination, page: pagination.page - 1, ...filters } })
}

export const retrieveSchemaFields = (id: number) => {
return api.get(`${SERVER_URL.SCHEMA}/${id}/fields`)
}

export const retrieveSchemaPreview = (id: number) => {
return api.get(`${SERVER_URL.SCHEMA}/${id}/preview`)
}

/**
* Fetch a specific row
* @param id Row ID
* @returns Row data
*/
export const fetchSchema = (id: number) => {
return api.get(`${SERVER_URL.SCHEMA}/${id}`)
}

/**
* Create a new row
* @param row Row data
* @returns Created row
*/
export const createSchema = (row: Schema) => {
return api.post(SERVER_URL.SCHEMA, row)
}

/**
* Check if a specific row exists by name
* @param name Row name
* @param id Row ID
* @returns Row data
*/
export const checkSchemaExists = (name: string, id?: number) => {
return api.get(`${SERVER_URL.SCHEMA}/exists`, { params: { name, id } })
}

/**
* Modify an existing row
* @param id Row ID
* @param row Updated row data
* @returns Modified row
*/
export const modifySchema = (id: number, row: Schema) => {
return api.put(`${SERVER_URL.SCHEMA}/${id}`, row)
}

/**
* Sync a existing row
* @param id Row ID
* @returns Created row
*/
export const syncSchema = (id: number) => {
return api.patch(`${SERVER_URL.SCHEMA}/${id}/sync`)
}

/**
* Generate
* @param id Row ID
* @returns Created row
*/
export const generateSchema = (id: number) => {
return api.get(`${SERVER_URL.SCHEMA}/${id}/download`, { responseType: 'blob' })
}

/**
* Remove a row
* @param id Row ID
* @returns Deletion status
*/
export const removeSchema = (id: number) => {
return api.delete(`${SERVER_URL.SCHEMA}/${id}`)
}

/**
* Config rows
* @param id Row ID
* @param row rows data
* @returns
*/
export const configSchemaFields = (id: number, rows: Array<Field>) => {
return api.patch(`${SERVER_URL.SCHEMA}/${id}/fields`, rows)
}

/**
* Export rows
* @param ids Rows ID
* @returns
*/
export const exprotSchemas = (ids?: number[]) => {
const params = ids ? { ids: ids.join(',') } : {}
return api.get(`${SERVER_URL.SCHEMA}/export`, { params, responseType: 'blob' })
}
79 changes: 79 additions & 0 deletions src/api/templates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/constants'
import type { Pagination, Template } from 'src/models'

/**
* Retrieve rows
* @param pagination Pagination and sort parameters
* @param filters Optional filter or sort parameters
* @returns Rows data
*/
export const retrieveTemplates = (pagination: Pagination, filters?: object) => {
return api.get(SERVER_URL.TEMPLATE, { params: { ...pagination, page: pagination.page - 1, ...filters } })
}

/**
* Fetch a specific row
* @param id Row ID
* @returns Row data
*/
export const fetchTemplate = (id: number) => {
return api.get(`${SERVER_URL.TEMPLATE}/${id}`)
}

/**
* Check if a specific row exists by name
* @param name Row name
* @param id Row ID
* @returns Row data
*/
export const checkTemplateExists = (name: string, suffix: string, version: string, id?: number) => {
return api.get(`${SERVER_URL.TEMPLATE}/exists`, { params: { name, suffix, version, id } })
}

/**
* Create a new row
* @param row Row data
* @returns Created row
*/
export const createTemplate = (row: Template) => {
return api.post(SERVER_URL.TEMPLATE, row)
}

/**
* Modify an existing row
* @param id Row ID
* @param row Updated row data
* @returns Modified row
*/
export const modifyTemplate = (id: number, row: Template) => {
return api.put(`${SERVER_URL.TEMPLATE}/${id}`, row)
}

/**
* Enable or Disable an existing row
* @param id Row ID
* @returns Enable or Disable result
*/
export const enableTemplate = (id: number) => {
return api.patch(`${SERVER_URL.TEMPLATE}/${id}`)
}

/**
* Remove a row
* @param id Row ID
* @returns Deletion status
*/
export const removeTemplate = (id: number) => {
return api.delete(`${SERVER_URL.TEMPLATE}/${id}`)
}

/**
* Export rows
* @param ids Rows ID
* @returns
*/
export const exprotTemplates = (ids?: number[]) => {
const params = ids ? { ids: ids.join(',') } : {}
return api.get(`${SERVER_URL.TEMPLATE}/export`, { params, responseType: 'blob' })
}
2 changes: 1 addition & 1 deletion src/api/users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from 'boot/axios'
import { SERVER_URL } from 'src/api/paths'
import { SERVER_URL } from 'src/constants'
import type { Pagination, User } from 'src/models'

/**
Expand Down
43 changes: 33 additions & 10 deletions src/boot/axios.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { boot } from 'quasar/wrappers'
import axios, { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
import { Notify } from 'quasar'
import { i18n } from 'boot/i18n'

const { t } = i18n.global

const abortControllerMap: Map<string, AbortController> = new Map()

const api: AxiosInstance = axios.create({ baseURL: process.env.API, withCredentials: true, timeout: 10000 })
const api: AxiosInstance = axios.create({
baseURL: process.env.API,
timeout: 10000
})

export default boot(() => {
export default boot(({ router }) => {
// 请求拦截器
api.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// 创建 AbortController 实例
const abortController = new AbortController()
// 将 signal 添加到请求配置中
const url = config.url || ''
config.signal = abortController.signal
abortControllerMap.set(url, abortController)
const controller = new AbortController()
const uniqueKey = `${config.method}:${config.url}`
config.signal = controller.signal
abortControllerMap.set(uniqueKey, controller)

return config
},
(error: AxiosError) => {
Expand All @@ -27,12 +33,29 @@ export default boot(() => {
// 响应拦截器
api.interceptors.response.use(
(response: AxiosResponse) => {
const url = response.config.url || ''
abortControllerMap.delete(url)
const uniqueKey = `${response.config.method}:${response.config.url}`
abortControllerMap.delete(uniqueKey)
return response
},
(error: AxiosError) => {
Notify.create({ type: 'negative', message: error.message })
const status = error.response?.status
switch (status) {
case 401:
localStorage.removeItem('access_token')
router.replace('/login')
break
case 403:
Notify.create({ type: 'forbidden', message: t('error') })
break
case 404:
Notify.create({ type: 'negative', message: t('notFound') })
break
case 500:
Notify.create({ type: 'negative', message: t('serverError') })
break
default:
Notify.create({ type: 'negative', message: t('error') })
}
return Promise.reject(error)
}
)
Expand Down
Loading

0 comments on commit 1669f90

Please sign in to comment.