项目初始化
This commit is contained in:
8
web/src/api/backend/auth/group.ts
Normal file
8
web/src/api/backend/auth/group.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export function getAdminRules() {
|
||||
return createAxios({
|
||||
url: '/admin/auth.Rule/index',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
142
web/src/api/backend/crud.ts
Normal file
142
web/src/api/backend/crud.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
import { useBaAccount } from '/@/stores/baAccount'
|
||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/crud.Crud/'
|
||||
|
||||
export function generate(data: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: url + 'generate',
|
||||
method: 'post',
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function getFileData(table: string, commonModel = 0) {
|
||||
return createAxios({
|
||||
url: url + 'getFileData',
|
||||
method: 'get',
|
||||
params: {
|
||||
table: table,
|
||||
commonModel: commonModel,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function generateCheck(data: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: url + 'generateCheck',
|
||||
method: 'post',
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
showCodeMessage: false,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function parseFieldData(data: anyObj) {
|
||||
return createAxios({
|
||||
url: url + 'parseFieldData',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export function postLogStart(id: string, type: string) {
|
||||
const data: anyObj = {
|
||||
id,
|
||||
type,
|
||||
}
|
||||
|
||||
if (type == 'Cloud history') {
|
||||
const baAccount = useBaAccount()
|
||||
data['token'] = baAccount.getToken('auth')
|
||||
}
|
||||
|
||||
return createAxios({
|
||||
url: url + 'logStart',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export function postDel(id: number) {
|
||||
return createAxios({
|
||||
url: url + 'delete',
|
||||
method: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function checkCrudLog(table: string, connection: string) {
|
||||
return createAxios({
|
||||
url: url + 'checkCrudLog',
|
||||
method: 'get',
|
||||
params: {
|
||||
table: table,
|
||||
connection: connection,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadLog(data: anyObj) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + '/api/v6.Crud/uploadLog',
|
||||
data: data,
|
||||
method: 'post',
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function uploadCompleted(data: anyObj) {
|
||||
return createAxios({
|
||||
url: url + 'uploadCompleted',
|
||||
data: data,
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
export function logs(data: anyObj = {}) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + '/api/v6.Crud/logs',
|
||||
data: data,
|
||||
method: 'post',
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function delLog(data: anyObj = {}) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + '/api/v6.Crud/del',
|
||||
data: data,
|
||||
method: 'post',
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
10
web/src/api/backend/dashboard.ts
Normal file
10
web/src/api/backend/dashboard.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/Dashboard/'
|
||||
|
||||
export function index() {
|
||||
return createAxios({
|
||||
url: url + 'index',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
72
web/src/api/backend/index.ts
Normal file
72
web/src/api/backend/index.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { useBaAccount } from '/@/stores/baAccount'
|
||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/Index/'
|
||||
|
||||
export function index() {
|
||||
return createAxios({
|
||||
url: url + 'index',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function login(method: 'get' | 'post', params: object = {}) {
|
||||
return createAxios({
|
||||
url: url + 'login',
|
||||
data: params,
|
||||
method: method,
|
||||
})
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
const adminInfo = useAdminInfo()
|
||||
return createAxios({
|
||||
url: url + 'logout',
|
||||
method: 'POST',
|
||||
data: {
|
||||
refreshToken: adminInfo.getToken('refresh'),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function baAccountCheckIn(params: object = {}) {
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + '/api/user/checkIn',
|
||||
data: params,
|
||||
method: 'post',
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function baAccountGetUserInfo() {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + '/api/user/info',
|
||||
method: 'get',
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function baAccountLogout() {
|
||||
const siteConfig = useSiteConfig()
|
||||
const baAccount = useBaAccount()
|
||||
return createAxios({
|
||||
url: siteConfig.apiUrl + '/api/user/logout',
|
||||
method: 'POST',
|
||||
data: {
|
||||
refreshToken: baAccount.getToken('refresh'),
|
||||
},
|
||||
})
|
||||
}
|
||||
190
web/src/api/backend/module.ts
Normal file
190
web/src/api/backend/module.ts
Normal file
@@ -0,0 +1,190 @@
|
||||
import { useBaAccount } from '/@/stores/baAccount'
|
||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
const storeUrl = '/api/v7.store/'
|
||||
const moduleControllerUrl = '/admin/module/'
|
||||
|
||||
export function index(params: anyObj = {}) {
|
||||
return createAxios({
|
||||
url: moduleControllerUrl + 'index',
|
||||
method: 'get',
|
||||
params: params,
|
||||
})
|
||||
}
|
||||
|
||||
export function modules(params: anyObj = {}) {
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios({
|
||||
url: siteConfig.apiUrl + storeUrl + 'modules',
|
||||
method: 'get',
|
||||
params: params,
|
||||
})
|
||||
}
|
||||
|
||||
export function info(params: anyObj) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + storeUrl + 'info',
|
||||
method: 'get',
|
||||
params: params,
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function createOrder(params: object = {}) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + storeUrl + 'order',
|
||||
method: 'post',
|
||||
params: params,
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function payOrder(orderId: number, payType: string) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + storeUrl + 'pay',
|
||||
method: 'post',
|
||||
params: {
|
||||
order_id: orderId,
|
||||
pay_type: payType,
|
||||
},
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function payCheck(sn: string) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + '/api/pay/check',
|
||||
method: 'get',
|
||||
params: {
|
||||
sn: sn,
|
||||
},
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
showCodeMessage: false,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模块的可安装版本列表
|
||||
*/
|
||||
export function preDownload(data: anyObj) {
|
||||
const baAccount = useBaAccount()
|
||||
const siteConfig = useSiteConfig()
|
||||
return createAxios(
|
||||
{
|
||||
url: siteConfig.apiUrl + storeUrl + 'preDownload',
|
||||
method: 'POST',
|
||||
data,
|
||||
},
|
||||
{
|
||||
anotherToken: baAccount.getToken('auth'),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function getInstallState(uid: string) {
|
||||
return createAxios({
|
||||
url: moduleControllerUrl + 'state',
|
||||
method: 'get',
|
||||
params: {
|
||||
uid: uid,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function postInstallModule(uid: string, orderId: number, version: string, update: boolean, extend: anyObj = {}) {
|
||||
const baAccount = useBaAccount()
|
||||
return createAxios(
|
||||
{
|
||||
url: moduleControllerUrl + 'install',
|
||||
method: 'POST',
|
||||
data: {
|
||||
uid,
|
||||
update,
|
||||
version,
|
||||
orderId,
|
||||
token: baAccount.getToken('auth'),
|
||||
extend,
|
||||
},
|
||||
timeout: 3000 * 10,
|
||||
},
|
||||
{
|
||||
showCodeMessage: false,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function postUninstall(uid: string) {
|
||||
return createAxios(
|
||||
{
|
||||
url: moduleControllerUrl + 'uninstall',
|
||||
method: 'post',
|
||||
params: {
|
||||
uid: uid,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function changeState(params: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: moduleControllerUrl + 'changeState',
|
||||
method: 'post',
|
||||
data: params,
|
||||
},
|
||||
{
|
||||
showCodeMessage: false,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function dependentInstallComplete(uid: string) {
|
||||
return createAxios({
|
||||
url: moduleControllerUrl + 'dependentInstallComplete',
|
||||
method: 'post',
|
||||
params: {
|
||||
uid: uid,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function upload(file: string) {
|
||||
const baAccount = useBaAccount()
|
||||
return createAxios({
|
||||
url: moduleControllerUrl + 'upload',
|
||||
method: 'post',
|
||||
params: {
|
||||
file: file,
|
||||
token: baAccount.getToken('auth'),
|
||||
},
|
||||
})
|
||||
}
|
||||
37
web/src/api/backend/routine/AdminInfo.ts
Normal file
37
web/src/api/backend/routine/AdminInfo.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/routine.AdminInfo/'
|
||||
|
||||
export const actionUrl = new Map([
|
||||
['index', url + 'index'],
|
||||
['edit', url + 'edit'],
|
||||
['log', '/admin/auth.AdminLog/index'],
|
||||
])
|
||||
|
||||
export function index() {
|
||||
return createAxios({
|
||||
url: actionUrl.get('index'),
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function log(filter: anyObj = {}) {
|
||||
return createAxios<TableDefaultData>({
|
||||
url: actionUrl.get('log'),
|
||||
method: 'get',
|
||||
params: filter,
|
||||
})
|
||||
}
|
||||
|
||||
export function postData(data: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: actionUrl.get('edit'),
|
||||
method: 'post',
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
59
web/src/api/backend/routine/config.ts
Normal file
59
web/src/api/backend/routine/config.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/routine.Config/'
|
||||
|
||||
export const actionUrl = new Map([
|
||||
['index', url + 'index'],
|
||||
['add', url + 'add'],
|
||||
['edit', url + 'edit'],
|
||||
['del', url + 'del'],
|
||||
['sendTestMail', url + 'sendTestMail'],
|
||||
])
|
||||
|
||||
export function index() {
|
||||
return createAxios({
|
||||
url: actionUrl.get('index'),
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function postData(action: string, data: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: actionUrl.get(action),
|
||||
method: 'post',
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function del(ids: string[]) {
|
||||
return createAxios(
|
||||
{
|
||||
url: actionUrl.get('del'),
|
||||
method: 'DELETE',
|
||||
params: {
|
||||
ids: ids,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function postSendTestMail(data: anyObj, mail: string) {
|
||||
return createAxios(
|
||||
{
|
||||
url: actionUrl.get('sendTestMail'),
|
||||
method: 'POST',
|
||||
data: Object.assign({}, data, { testMail: mail }),
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
10
web/src/api/backend/security/dataRecycle.ts
Normal file
10
web/src/api/backend/security/dataRecycle.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/security.DataRecycle/'
|
||||
|
||||
export function add() {
|
||||
return createAxios({
|
||||
url: url + 'add',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
28
web/src/api/backend/security/dataRecycleLog.ts
Normal file
28
web/src/api/backend/security/dataRecycleLog.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/security.DataRecycleLog/'
|
||||
|
||||
export function restore(ids: string[]) {
|
||||
return createAxios(
|
||||
{
|
||||
url: url + 'restore',
|
||||
method: 'POST',
|
||||
data: {
|
||||
ids: ids,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function info(id: string) {
|
||||
return createAxios({
|
||||
url: url + 'info',
|
||||
method: 'get',
|
||||
params: {
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
}
|
||||
10
web/src/api/backend/security/sensitiveData.ts
Normal file
10
web/src/api/backend/security/sensitiveData.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/security.SensitiveData/'
|
||||
|
||||
export function add() {
|
||||
return createAxios({
|
||||
url: url + 'add',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
28
web/src/api/backend/security/sensitiveDataLog.ts
Normal file
28
web/src/api/backend/security/sensitiveDataLog.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/security.SensitiveDataLog/'
|
||||
|
||||
export function rollback(ids: string[]) {
|
||||
return createAxios(
|
||||
{
|
||||
url: url + 'rollback',
|
||||
method: 'POST',
|
||||
data: {
|
||||
ids: ids,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function info(id: string) {
|
||||
return createAxios({
|
||||
url: url + 'info',
|
||||
method: 'get',
|
||||
params: {
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
}
|
||||
8
web/src/api/backend/user/group.ts
Normal file
8
web/src/api/backend/user/group.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export function getUserRules() {
|
||||
return createAxios({
|
||||
url: '/admin/user.Rule/index',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
13
web/src/api/backend/user/moneyLog.ts
Normal file
13
web/src/api/backend/user/moneyLog.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/user.MoneyLog/'
|
||||
|
||||
export function add(userId: string) {
|
||||
return createAxios({
|
||||
url: url + 'add',
|
||||
method: 'get',
|
||||
params: {
|
||||
userId: userId,
|
||||
},
|
||||
})
|
||||
}
|
||||
13
web/src/api/backend/user/scoreLog.ts
Normal file
13
web/src/api/backend/user/scoreLog.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
|
||||
export const url = '/admin/user.ScoreLog/'
|
||||
|
||||
export function add(userId: string) {
|
||||
return createAxios({
|
||||
url: url + 'add',
|
||||
method: 'get',
|
||||
params: {
|
||||
userId: userId,
|
||||
},
|
||||
})
|
||||
}
|
||||
378
web/src/api/common.ts
Normal file
378
web/src/api/common.ts
Normal file
@@ -0,0 +1,378 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { isAdminApp, checkFileMimetype } from '/@/utils/common'
|
||||
import { getUrl } from '/@/utils/axios'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { useUserInfo } from '/@/stores/userInfo'
|
||||
import { ElNotification, type UploadRawFile } from 'element-plus'
|
||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import { state as uploadExpandState, fileUpload as uploadExpand } from '/@/components/mixins/baUpload'
|
||||
import type { AxiosRequestConfig } from 'axios'
|
||||
import { uuid } from '/@/utils/random'
|
||||
import { i18n } from '../lang'
|
||||
import { adminBaseRoutePath } from '/@/router/static/adminBase'
|
||||
import { SYSTEM_ZINDEX } from '/@/stores/constant/common'
|
||||
|
||||
/*
|
||||
* 公共请求函数和Url定义
|
||||
*/
|
||||
|
||||
// Admin模块
|
||||
export const adminUploadUrl = '/admin/ajax/upload'
|
||||
export const adminBuildSuffixSvgUrl = adminBaseRoutePath + '/ajax/buildSuffixSvg'
|
||||
export const adminAreaUrl = '/admin/ajax/area'
|
||||
export const getTablePkUrl = '/admin/ajax/getTablePk'
|
||||
export const getTableListUrl = '/admin/ajax/getTableList'
|
||||
export const getTableFieldListUrl = '/admin/ajax/getTableFieldList'
|
||||
export const getDatabaseConnectionListUrl = '/admin/ajax/getDatabaseConnectionList'
|
||||
export const terminalUrl = adminBaseRoutePath + '/ajax/terminal'
|
||||
export const changeTerminalConfigUrl = '/admin/ajax/changeTerminalConfig'
|
||||
export const clearCacheUrl = '/admin/ajax/clearCache'
|
||||
|
||||
// 公共
|
||||
export const captchaUrl = '/api/common/captcha'
|
||||
export const clickCaptchaUrl = '/api/common/clickCaptcha'
|
||||
export const checkClickCaptchaUrl = '/api/common/checkClickCaptcha'
|
||||
export const refreshTokenUrl = '/api/common/refreshToken'
|
||||
|
||||
// api模块(前台)
|
||||
export const apiUploadUrl = '/api/ajax/upload'
|
||||
export const apiBuildSuffixSvgUrl = '/api/ajax/buildSuffixSvg'
|
||||
export const apiAreaUrl = '/api/ajax/area'
|
||||
export const apiSendSms = '/api/Sms/send'
|
||||
export const apiSendEms = '/api/Ems/send'
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
export function fileUpload(fd: FormData, params: anyObj = {}, forceLocal = false, config: AxiosRequestConfig = {}): ApiPromise {
|
||||
let errorMsg = ''
|
||||
const file = fd.get('file') as UploadRawFile
|
||||
const siteConfig = useSiteConfig()
|
||||
|
||||
if (!file.name || typeof file.size == 'undefined') {
|
||||
errorMsg = i18n.global.t('utils.The data of the uploaded file is incomplete!')
|
||||
} else if (!checkFileMimetype(file.name, file.type)) {
|
||||
errorMsg = i18n.global.t('utils.The type of uploaded file is not allowed!')
|
||||
} else if (file.size > siteConfig.upload.maxSize) {
|
||||
errorMsg = i18n.global.t('utils.The size of the uploaded file exceeds the allowed range!')
|
||||
}
|
||||
if (errorMsg) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ElNotification({
|
||||
type: 'error',
|
||||
message: errorMsg,
|
||||
zIndex: SYSTEM_ZINDEX,
|
||||
})
|
||||
reject(errorMsg)
|
||||
})
|
||||
}
|
||||
|
||||
if (!forceLocal && uploadExpandState() == 'enable') {
|
||||
return uploadExpand(fd, params, config)
|
||||
}
|
||||
|
||||
return createAxios({
|
||||
url: isAdminApp() ? adminUploadUrl : apiUploadUrl,
|
||||
method: 'POST',
|
||||
data: fd,
|
||||
params: params,
|
||||
timeout: 0,
|
||||
...config,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件后缀icon的svg图片
|
||||
* @param suffix 后缀名
|
||||
* @param background 背景色,如:rgb(255,255,255)
|
||||
*/
|
||||
export function buildSuffixSvgUrl(suffix: string, background = '') {
|
||||
const adminInfo = useAdminInfo()
|
||||
return (
|
||||
getUrl() +
|
||||
(isAdminApp() ? adminBuildSuffixSvgUrl : apiBuildSuffixSvgUrl) +
|
||||
'?batoken=' +
|
||||
adminInfo.getToken() +
|
||||
'&suffix=' +
|
||||
suffix +
|
||||
(background ? '&background=' + background : '') +
|
||||
'&server=1'
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地区数据
|
||||
*/
|
||||
export function getArea(values: number[]) {
|
||||
const params: { province?: number; city?: number; uuid?: string } = {}
|
||||
if (values[0]) {
|
||||
params.province = values[0]
|
||||
}
|
||||
if (values[1]) {
|
||||
params.city = values[1]
|
||||
}
|
||||
params.uuid = uuid()
|
||||
return createAxios({
|
||||
url: isAdminApp() ? adminAreaUrl : apiAreaUrl,
|
||||
method: 'GET',
|
||||
params: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
*/
|
||||
export function sendSms(mobile: string, templateCode: string, extend: anyObj = {}) {
|
||||
return createAxios(
|
||||
{
|
||||
url: apiSendSms,
|
||||
method: 'POST',
|
||||
data: {
|
||||
mobile: mobile,
|
||||
template_code: templateCode,
|
||||
...extend,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
export function sendEms(email: string, event: string, extend: anyObj = {}) {
|
||||
return createAxios(
|
||||
{
|
||||
url: apiSendEms,
|
||||
method: 'POST',
|
||||
data: {
|
||||
email: email,
|
||||
event: event,
|
||||
...extend,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存清理接口
|
||||
*/
|
||||
export function postClearCache(type: string) {
|
||||
return createAxios(
|
||||
{
|
||||
url: clearCacheUrl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
type: type,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建命令执行窗口url
|
||||
*/
|
||||
export function buildTerminalUrl(commandKey: string, uuid: string, extend: string) {
|
||||
const adminInfo = useAdminInfo()
|
||||
return (
|
||||
getUrl() + terminalUrl + '?command=' + commandKey + '&uuid=' + uuid + '&extend=' + extend + '&batoken=' + adminInfo.getToken() + '&server=1'
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求修改终端配置
|
||||
*/
|
||||
export function postChangeTerminalConfig(data: { manager?: string; port?: string }) {
|
||||
return createAxios({
|
||||
url: changeTerminalConfigUrl,
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程下拉框数据获取
|
||||
*/
|
||||
export function getSelectData(remoteUrl: string, q: string, params: anyObj = {}) {
|
||||
return createAxios({
|
||||
url: remoteUrl,
|
||||
method: 'get',
|
||||
params: {
|
||||
select: true,
|
||||
quickSearch: q,
|
||||
...params,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function buildCaptchaUrl() {
|
||||
return getUrl() + captchaUrl + '?server=1'
|
||||
}
|
||||
|
||||
export function getCaptchaData(id: string, apiBaseURL: string) {
|
||||
return createAxios({
|
||||
url: apiBaseURL + clickCaptchaUrl,
|
||||
method: 'get',
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function checkClickCaptcha(id: string, info: string, unset: boolean, apiBaseURL: string) {
|
||||
return createAxios(
|
||||
{
|
||||
url: apiBaseURL + checkClickCaptchaUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
id,
|
||||
info,
|
||||
unset,
|
||||
},
|
||||
},
|
||||
{
|
||||
showCodeMessage: false,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function getTablePk(table: string, connection = '') {
|
||||
return createAxios({
|
||||
url: getTablePkUrl,
|
||||
method: 'get',
|
||||
params: {
|
||||
table: table,
|
||||
connection: connection,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据表的字段
|
||||
* @param table 数据表名
|
||||
* @param clean 只要干净的字段注释(只要字段标题)
|
||||
*/
|
||||
export function getTableFieldList(table: string, clean = true, connection = '') {
|
||||
return createAxios({
|
||||
url: getTableFieldListUrl,
|
||||
method: 'get',
|
||||
params: {
|
||||
table: table,
|
||||
clean: clean ? 1 : 0,
|
||||
connection: connection,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function refreshToken() {
|
||||
const adminInfo = useAdminInfo()
|
||||
const userInfo = useUserInfo()
|
||||
return createAxios({
|
||||
url: refreshTokenUrl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
refreshToken: isAdminApp() ? adminInfo.getToken('refresh') : userInfo.getToken('refresh'),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速生成一个控制器的 增、删、改、查、排序 接口的请求方法
|
||||
* 本 class 实例通常直接传递给 baTable 使用,开发者可重写本类的方法,亦可直接向 baTable 传递自定义的 API 请求类
|
||||
* 表格相关网络请求无需局限于本类,开发者可于 /src/api/ 目录创建自定义的接口请求函数,并于需要的地方导入使用即可
|
||||
*/
|
||||
export class baTableApi {
|
||||
private controllerUrl
|
||||
public actionUrl
|
||||
|
||||
constructor(controllerUrl: string) {
|
||||
this.controllerUrl = controllerUrl
|
||||
this.actionUrl = new Map([
|
||||
['index', controllerUrl + 'index'],
|
||||
['add', controllerUrl + 'add'],
|
||||
['edit', controllerUrl + 'edit'],
|
||||
['del', controllerUrl + 'del'],
|
||||
['sortable', controllerUrl + 'sortable'],
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格查看接口的请求方法
|
||||
* @param filter 数据过滤条件
|
||||
*/
|
||||
index(filter: BaTable['filter'] = {}) {
|
||||
return createAxios<TableDefaultData>({
|
||||
url: this.actionUrl.get('index'),
|
||||
method: 'get',
|
||||
params: filter,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取被编辑行数据
|
||||
* @param params 被编辑行主键等
|
||||
*/
|
||||
edit(params: anyObj) {
|
||||
return createAxios({
|
||||
url: this.actionUrl.get('edit'),
|
||||
method: 'get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格删除接口的请求方法
|
||||
* @param ids 被删除数据的主键数组
|
||||
*/
|
||||
del(ids: string[]) {
|
||||
return createAxios(
|
||||
{
|
||||
url: this.actionUrl.get('del'),
|
||||
method: 'DELETE',
|
||||
params: {
|
||||
ids,
|
||||
},
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定接口 POST 数据,本方法虽然较为通用,但请不要局限于此,开发者可于 /src/api/ 目录创建自定义的接口请求函数,并于需要的地方导入使用即可
|
||||
* @param action 请求的接口,比如 add、edit
|
||||
* @param data 要 POST 的数据
|
||||
*/
|
||||
postData(action: string, data: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: this.actionUrl.has(action) ? this.actionUrl.get(action) : this.controllerUrl + action,
|
||||
method: 'post',
|
||||
data,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格行排序接口的请求方法
|
||||
*/
|
||||
sortable(data: anyObj) {
|
||||
return createAxios({
|
||||
url: this.actionUrl.get('sortable'),
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
}
|
||||
56
web/src/api/frontend/index.ts
Normal file
56
web/src/api/frontend/index.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import { useMemberCenter } from '/@/stores/memberCenter'
|
||||
import { debounce, setTitleFromRoute } from '/@/utils/common'
|
||||
import { handleFrontendRoute } from '/@/utils/router'
|
||||
import { useUserInfo } from '/@/stores/userInfo'
|
||||
import router from '/@/router/index'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
|
||||
export const indexUrl = '/api/index/'
|
||||
|
||||
/**
|
||||
* 前台初始化请求,获取站点配置信息,动态路由信息等
|
||||
* 1. 首次初始化携带了会员token时,一共只初始化一次
|
||||
* 2. 首次初始化未带会员token,将在登录后再初始化一次
|
||||
*/
|
||||
export function initialize(callback?: (res: ApiResponse) => void, requiredLogin?: boolean) {
|
||||
debounce(() => {
|
||||
if (router.currentRoute.value.meta.initialize === false) return
|
||||
|
||||
const userInfo = useUserInfo()
|
||||
const siteConfig = useSiteConfig()
|
||||
if (!userInfo.isLogin() && siteConfig.initialize) return
|
||||
if (userInfo.isLogin() && siteConfig.userInitialize) return
|
||||
|
||||
const memberCenter = useMemberCenter()
|
||||
|
||||
createAxios({
|
||||
url: indexUrl + 'index',
|
||||
method: 'get',
|
||||
params: {
|
||||
requiredLogin: requiredLogin ? 1 : 0,
|
||||
},
|
||||
}).then((res) => {
|
||||
handleFrontendRoute(res.data.rules, res.data.menus)
|
||||
siteConfig.dataFill(res.data.site)
|
||||
memberCenter.setStatus(res.data.openMemberCenter)
|
||||
|
||||
if (!isEmpty(res.data.userInfo)) {
|
||||
userInfo.dataFill(res.data.userInfo)
|
||||
|
||||
// 请求到会员信息才设置会员中心初始化是成功的
|
||||
siteConfig.setUserInitialize(true)
|
||||
}
|
||||
|
||||
if (!res.data.openMemberCenter) memberCenter.setLayoutMode('Disable')
|
||||
|
||||
siteConfig.setInitialize(true)
|
||||
|
||||
// 根据当前路由重设页面标题
|
||||
setTitleFromRoute()
|
||||
|
||||
typeof callback == 'function' && callback(res)
|
||||
})
|
||||
}, 200)()
|
||||
}
|
||||
120
web/src/api/frontend/user/index.ts
Normal file
120
web/src/api/frontend/user/index.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { useUserInfo } from '/@/stores/userInfo'
|
||||
|
||||
export const userUrl = '/api/user/'
|
||||
export const accountUrl = '/api/account/'
|
||||
|
||||
export function checkIn(method: 'get' | 'post', params: object = {}) {
|
||||
return createAxios({
|
||||
url: userUrl + 'checkIn',
|
||||
data: params,
|
||||
method: method,
|
||||
})
|
||||
}
|
||||
|
||||
export function overview() {
|
||||
return createAxios({
|
||||
url: accountUrl + 'overview',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function postProfile(params: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: accountUrl + 'profile',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function getProfile() {
|
||||
return createAxios({
|
||||
url: accountUrl + 'profile',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function postVerification(data: anyObj) {
|
||||
return createAxios({
|
||||
url: accountUrl + 'verification',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export function postChangeBind(data: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: accountUrl + 'changeBind',
|
||||
method: 'post',
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function changePassword(params: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: accountUrl + 'changePassword',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function getBalanceLog(page: number, pageSize: number) {
|
||||
return createAxios({
|
||||
url: accountUrl + 'balance',
|
||||
method: 'GET',
|
||||
params: {
|
||||
page: page,
|
||||
limit: pageSize,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function getIntegralLog(page: number, pageSize: number) {
|
||||
return createAxios({
|
||||
url: accountUrl + 'integral',
|
||||
method: 'GET',
|
||||
params: {
|
||||
page: page,
|
||||
limit: pageSize,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function postLogout() {
|
||||
const userInfo = useUserInfo()
|
||||
return createAxios({
|
||||
url: userUrl + 'logout',
|
||||
method: 'POST',
|
||||
data: {
|
||||
refreshToken: userInfo.getToken('refresh'),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function retrievePassword(params: anyObj) {
|
||||
return createAxios(
|
||||
{
|
||||
url: accountUrl + 'retrievePassword',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
},
|
||||
{
|
||||
showSuccessMessage: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user