/go-view-vi

Bản tinh chỉnh Go view hỗ trợ backend và đa ngôn ngữ

Primary LanguageVueMIT LicenseMIT

Overview

API documentation URL: https://docs.apipost.cn/preview/5aa85d10a59d66ce/ddb813732007ad2b?target_id=84dbc5b0-158f-4bcb-8f74-793ac604ada3#3e053622-1e76-43f9-a039-756aee822dbb

Usage

All API endpoints location: src\api\path\*

API endpoint modification: .env

# port
VITE_DEV_PORT = '8080'

# development path
VITE_DEV_PATH = 'http://127.0.0.1:8080'

# production path
VITE_PRO_PATH = 'http://127.0.0.1:8080'

Public prefix modification: src\settings\httpSetting.ts

// Request prefix
export const axiosPre = '/api/goview'

API encapsulation: src\api\http.ts

import axiosInstance from './axios'
import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum'

export const get = (url: string, params?: object) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.GET,
    params: params,
  })
}

export const post = (url: string, data?: object, headersType?: string) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.POST,
    data: data,
    headers: {
      'Content-Type': headersType || ContentTypeEnum.JSON
    }
  })
}

export const put = (url: string, data?: object, headersType?: string) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.PUT,
    data: data,
    headers: {
      'Content-Type': headersType || ContentTypeEnum.JSON
    }
  })
}

export const del = (url: string, params?: object) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.DELETE,
    params
  })
}

// Default request function is GET
export const http = (type?: RequestHttpEnum) => {
  switch (type) {
    case RequestHttpEnum.GET:
      return get

    case RequestHttpEnum.POST:
      return post

    case RequestHttpEnum.PUT:
      return put

    case RequestHttpEnum.DELETE:
      return del

    default:
      return get
  }
}

Code Commit

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • perf: Performance optimization
  • revert: Version rollback
  • ci: CICD integration related
  • test: Adding test code
  • refactor: Code refactoring
  • build: Changes affecting project build or dependencies
  • style: Code changes that do not affect the program logic
  • chore: Other types not included above (routine tasks)