2022-11-23 19:20:03 +08:00
|
|
|
|
# 常用的数据信息
|
|
|
|
|
|
2022-11-24 14:39:42 +08:00
|
|
|
|
## 其他
|
|
|
|
|
|
|
|
|
|
> 维护人员: youhong.ai
|
|
|
|
|
|
2022-11-23 19:20:03 +08:00
|
|
|
|
+ 缓存地址: `/commcache/cacheMonitor.jsp`
|
2022-11-24 14:39:42 +08:00
|
|
|
|
+ 移动端流程模拟地址: `/spa/workflow/static4mobile/index.html#/center/doing`
|
|
|
|
|
|
|
|
|
|
## 常用代码
|
|
|
|
|
|
|
|
|
|
### 前端
|
|
|
|
|
|
|
|
|
|
**获取用户信息**
|
|
|
|
|
> 维护人员:youhong.ai
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
const userInfo = JSON.parse(localStorage.getItem("theme-account"))
|
2022-11-24 14:59:07 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**获取url参数**
|
|
|
|
|
> 维护人员: youHong.ai
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
getQueryString = (name) => {
|
|
|
|
|
let reg = new RegExp("(^|&|\/?)" + name + "=([^&]*)(&|$)", "i");
|
|
|
|
|
let searchStr = window.location.href
|
|
|
|
|
if (searchStr.startsWith('&')) {
|
|
|
|
|
searchStr = searchStr.substr(1)
|
|
|
|
|
}
|
|
|
|
|
search = searchStr.match(reg)
|
|
|
|
|
if (search != null) {
|
|
|
|
|
return unescape(search[2]);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**ajax请求**
|
|
|
|
|
> 维护人员: youHong.ai
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
class ApiUtils {
|
|
|
|
|
static request = (url, type = "GET", data, isAsync = true, success = () => {
|
|
|
|
|
}, error = () => {
|
|
|
|
|
}, complete = () => {
|
|
|
|
|
}, contentType = 'application/json', beforeSend = () => {
|
|
|
|
|
}) => {
|
|
|
|
|
let options = {
|
|
|
|
|
url,
|
|
|
|
|
type,
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType,
|
|
|
|
|
async: isAsync,
|
|
|
|
|
data,
|
|
|
|
|
beforeSend,
|
|
|
|
|
success,
|
|
|
|
|
error,
|
|
|
|
|
complete,
|
|
|
|
|
}
|
|
|
|
|
if (contentType == 'application/json') {
|
|
|
|
|
options.data = JSON.stringify(data)
|
|
|
|
|
}
|
|
|
|
|
return $.ajax(options)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**通过js获取react组件,操作组件内部数据**
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
function FindReact(dom, traverseUp = 0) {
|
|
|
|
|
const key = Object.keys(dom).find(key => {
|
|
|
|
|
return key.startsWith("__reactFiber$") // react 17+
|
|
|
|
|
|| key.startsWith("__reactInternalInstance$"); // react <17
|
|
|
|
|
});
|
|
|
|
|
const domFiber = dom[key];
|
|
|
|
|
if (domFiber == null) return null;
|
|
|
|
|
|
|
|
|
|
// react <16
|
|
|
|
|
if (domFiber._currentElement) {
|
|
|
|
|
let compFiber = domFiber._currentElement._owner;
|
|
|
|
|
for (let i = 0; i < traverseUp; i++) {
|
|
|
|
|
compFiber = compFiber._currentElement._owner;
|
|
|
|
|
}
|
|
|
|
|
return compFiber._instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// react 16+
|
|
|
|
|
const GetCompFiber = fiber => {
|
|
|
|
|
let parentFiber = fiber.return;
|
|
|
|
|
while (typeof parentFiber.type == "string") {
|
|
|
|
|
parentFiber = parentFiber.return;
|
|
|
|
|
}
|
|
|
|
|
return parentFiber;
|
|
|
|
|
};
|
|
|
|
|
let compFiber = GetCompFiber(domFiber);
|
|
|
|
|
for (let i = 0; i < traverseUp; i++) {
|
|
|
|
|
compFiber = GetCompFiber(compFiber);
|
|
|
|
|
}
|
|
|
|
|
return compFiber.stateNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用法
|
|
|
|
|
const someElement = document.getElementById("someElement");
|
|
|
|
|
const myComp = FindReact(someElement);
|
|
|
|
|
myComp.setState({test1: test2});
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 数据库
|
|
|
|
|
|
|
|
|
|
**备份mysql数据库**
|
|
|
|
|
> 维护人员: youHong.ai
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
mysqldump -uroot -p'passowrd' --single-transaction -R -E --databases ecology_dev> /tmp/ecology_dev_back.sql
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 后端
|