3.2 ATM and Background language cooperative work scheme--Debugging mode

Source: Internet
Author: User
Tags script tag

JSON file

~/blog/user/account/1.0.0 folder output of the map file, 1.0.0/exports under the import file dependencies are generated in maps
{
"Settings": {
"Port": 1234,
"Debugparam": "Debugid",
"Domain": "http://cn-style.gcimg.net/static"
},
"Maps": {
"User/account:1.0.0/help.css": {
"CSS": [
"/core/reset/1.0.0/reset_e5b6e95.css",
"/user/account/1.0.0/account_2e2d290.css",
"/user/account/1.0.0/exports/help_5751a04.css"
],
"Loader": "",
"JS": [],
"Onlycss": True
},
"User/account:1.0.0/login": {
"CSS": [
"/core/reset/1.0.0/reset_e5b6e95.css",
"/user/account/1.0.0/account_2e2d290.css",
"/user/account/1.0.0/css/login_9fa75f4.css"
],
"Loader": "/lib/loader/1.0.0/loader_aa23401.js",
"JS": [
"/user/account/1.0.0/account_8c2acc1.js",
"/user/account/1.0.0/exports/login_1074d04.js"
],
"Onlycss": false,
"Map": "Atmjs.setmap ({\" _alias\ ": {},\" alias\ ": {\" user/account:1.0.0/other/ajax\ ": \"/user/account/1.0.0/other/ Ajax_49ac7f5.js\ "},\" pkg\ ": {},\" cssdeps\ ": {}});"
},
"User/account:1.0.0/reg": {
"CSS": [
"/core/reset/1.0.0/reset_e5b6e95.css",
"/user/account/1.0.0/account_2e2d290.css",
"/user/account/1.0.0/css/reg_a005dbe.css"
],
"Loader": "/lib/loader/1.0.0/loader_aa23401.js",
"JS": [
"/user/account/1.0.0/account_8c2acc1.js",
"/user/account/1.0.0/exports/reg_0d22604.js"
],
"Onlycss": false
}
}
}

1. When the landing page is online, I want to use the online page (assuming the access address is: http://url/login.html) to call the local JS/CSS resources to debug, how to implement

The value of Debugparam in the Settings field in the JSON file is Debugid, so we can access the

Http://url/login.html?debugId or

Http://url/login.html?debugId=true

To invoke the 127.0.0.1 resource, because the online program cannot get to the local map file, so here is more tangled, the final solution is this:

The local node environment provides a call to JS and a CSS interface, the corresponding resources will be merged into a file

Therefore, if you are debugging mode

CSS should be like this, without having to think about Deps.css's content

<link rel= "stylesheet" type= "Text/css" href= "http://127.0.0.1:1234/debug?id=user/account:1.0.0/login&type= css&domain=http://127.0.0.1:1234/dev&timestamp=1437033687 "/>

In the same way, JS should eventually be

<script type= "Text/javascript" id= "Atmjsnode" data-base= "Http://127.0.0.1:1234/dev" src= "http://127.0.0.1:1234/ debug?id=user/account:1.0.0/login&type=js&timestamp=1437033687 "></script><script type=" text /javascript ">atmjs.use (' User/account:1.0.0/login ') </script>

The ID in the parameter is the portal file ID, timestamp is to prevent caching, type indicates whether the file is JS or CSS type

2. Now debug mode all call is 127.0.0.1 on the resources, then the problem comes, if you go to debug a mobile site, with a mobile phone must not debug debugging mode

So we're going to try to replace 127.0.0.1 with an IP that the phone can access, like 192.168.1.100

Therefore, we use

http://url/login.html?debugId=192.168.1.100

To debug

Then the corresponding CSS and JS call, to become the following like this

<link rel= "stylesheet" type= "Text/css" href= "http://192.168.1.100:1234/debug?id=user/account:1.0.0/login& type=css&domain=http://192.168.1.100:1234/dev&timestamp=1437034561 "/><script type=" text/ JavaScript "id=" Atmjsnode "data-base=" Http://192.168.1.100:1234/dev "src=" Http://192.168.1.100:1234/debug?id=user /account:1.0.0/login&type=js&timestamp=1437034561 "></script><script type=" Text/javascript " >atmjs.use (' User/account:1.0.0/login ') </script>

  

So the values of the Data-base values in the domain and script tags in the parameters are so derived

$port = 1234;   Settings.port
$debugId = ' Debugid '; Settings.debugparam$debugid = $_request[$debugId];if ($debugId = = ' true ' | | empty ($DEBUGID)) { $debugId = $this- >debugid = ' 127.0.0.1 ';} else{ $debugId = $this->debugid = $debugId;} $domain = '/http '. $debugId. ': ' $port. ' /dev ';

The debug address prefixes for SRC and href are obtained in this way

$port = 1234;   Settings.port$debugid = $_request[' Debugid '];if ($debugId = = ' true ' | | empty ($DEBUGID)) {    $debugId = $this Debugid = ' 127.0.0.1 ';} else{    $debugId = $this->debugid = $debugId;} $prefix = '/http '. $debugId. ': ' $port. ' /debug ';

Similarly, if the portal file is a CSS file, the script tag cannot be output

3.2 ATM and Background language cooperative work scheme--Debugging mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.