i18n.ts
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import request from '/@/utils/request';
import axios from 'axios';
export function fetchList(query?: Object) {
return request({
url: '/admin/i18n/page',
method: 'get',
params: query,
});
}
export function addObj(obj?: Object) {
return request({
url: '/admin/i18n',
method: 'post',
data: obj,
});
}
export function getObj(id?: string) {
return request({
url: '/admin/i18n/details/' + id,
method: 'get',
});
}
export function getObjDetails(obj?: object) {
return request({
url: '/admin/i18n/details',
method: 'get',
params: obj,
});
}
export function delObj(ids?: object) {
return request({
url: '/admin/i18n',
method: 'delete',
data: ids,
});
}
export function putObj(obj?: Object) {
return request({
url: '/admin/i18n',
method: 'put',
data: obj,
});
}
export function refreshCache() {
return request({
url: '/admin/i18n/sync',
method: 'put',
});
}
/**
* 注意这里使用原声axios对象进行操作,request 实例中依赖i18n 所以还没有初始化会报错
* @returns
*/
export function info() {
return axios.get(import.meta.env.VITE_API_URL + '/admin/i18n/info');
}
export function validateName(rule: any, value: any, callback: any, isEdit: boolean) {
if (isEdit) {
return callback();
}
getObjDetails({ name: value }).then((response) => {
const result = response.data;
if (result !== null) {
callback(new Error('国际化编码已经存在'));
} else {
callback();
}
});
}
export function validateZhCn(rule: any, value: any, callback: any, isEdit: boolean) {
if (isEdit) {
return callback();
}
getObjDetails({ zhCn: value }).then((response) => {
const result = response.data;
if (result !== null) {
callback(new Error('国际化中文已经存在'));
} else {
callback();
}
});
}
export function validateEn(rule: any, value: any, callback: any, isEdit: boolean) {
if (isEdit) {
return callback();
}
getObjDetails({ en: value }).then((response) => {
const result = response.data;
if (result !== null) {
callback(new Error('国际化英文已经存在'));
} else {
callback();
}
});
}