123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- const api = {
- getGraph:'/api/ltkg/kg/getGraph',
- getNode:'/api/ltkg/kg/getNode',
- getSchema:'/api/ltkg/kg/getSchema',
- getTree:'/api/ltkg/kg/getTree',
- entity_predict:'api/ltkg/nlp/getNlp',
- getMrInfo:'/api/ltkg/presetInfo/getMrInfo',
- getAnswer:'/api/ltkg/qa/charBot',
- getTerm:'/api/ltkg/term/getTerm',
- check:'http://192.168.2.121:7010/test/testStandConvert',
- };
- const getUrlArgObject = function(name) {//
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- var q = window.location.pathname.substr(1).match(reg_rewrite);
- if (r != null) {
- return decodeURIComponent(r[2]);
- } else if (q != null) {
- return decodeURIComponent(q[2]);
- } else {
- return null;
- }
- }
- const post = function (url, data,pId) {
- const securityCode = getUrlArgObject("code");
- const appKeyId = getUrlArgObject("appI");
- const appKeySecret = getUrlArgObject("appS");
- const productId = getUrlArgObject("productId");
- return new Promise((resolve, reject) => {
- $.ajax({
- method: 'post',
- url: url,
- data: JSON.stringify(data),
- contentType: "application/json; charset=UTF-8",
- beforeSend: function (xmlHttp) {
- xmlHttp.setRequestHeader("If-Modified-Since", "0");
- xmlHttp.setRequestHeader("Cache-Control", "no-cache");
- xmlHttp.setRequestHeader("appKeyId", appKeyId);
- xmlHttp.setRequestHeader("appKeySecret", appKeySecret);
- xmlHttp.setRequestHeader("securityCode", securityCode);
- xmlHttp.setRequestHeader("productId", productId);
- },
- success: function (res) {
- resolve({ data: res });
- },
- error: function (error) {
- reject(error);
- },
- });
- });
- }
- module.exports ={
- post,
- api,
- getUrlArgObject
- }
|