[关闭]
@xiaoqq 2018-05-24T09:09:14.000000Z 字数 4105 阅读 1226

工具类配置技巧

唯品花


WebStorm中配置Less和css压缩

  1. 使用npm 全局安装lessc:npm install less -g;
  2. 打开webstorm→file→settings→Tools→file watching,添加less的watcher
  3. 关键在于配置路径:

    只需要把Output paths to refresh更改为:$ProjectFileDir$\webapp\css\$FileDirName$\$FileNameWithoutExtension$.css

新增:着陆页更改为: $ProjectFileDir$\webapp\publicity\mh52016111601\$FileNameWithoutExtension$.css

  1. 对CSS压缩可以使用YUI,首先下载jar文件,参数设置为:$FileName$ -o $FileNameWithoutExtension$.css, Workding Directory设置为:$ProjectFileDir$\webapp\css\$FileDirName$\, Output paths设置为:$ProjectFileDir$\webapp\css\$FileDirName$\$FileNameWithoutExtension$.css

Charles使用帮助:

由于在fiddler在本机使用存在诸多问题,经同事介绍,决定使用charles

  1. 破解:我使用的是Charles4.x,直接从这篇博客上下载jar包替换即可;

  2. 设置HTTPS|HTTP代理:点击某个域,右键,Enable SSL Proxying

  3. 移动端访问http://charlesproxy.com/getssl 安装证书。

Sublime使用中遇到的问题:

  1. 经常使用install package没有反应,解决方法是,在Setting-User中配置:

    1. "channels":
    2. [
    3. "https://raw.githubusercontent.com/AceLiu/channel_v3.json/master/channel_v3.json"
    4. ],
  2. 使用4个空格代替tab:"translate_tabs_to_spaces": true,

  3. 使用虚线显示空格: "draw_white_space": "all",

商详页开发步骤

  1. 拷贝一份ftl并且命名为xxx02.ftl;
  2. 由于backId不能变,所以默认着陆页在2016091603.less/js上修改,而商详页在2016091602.less/js上修改;
  3. 删除商详页的商品展示,并且在最上面加上头<#include "_titleOrigin.ftl" encoding="utf-8" parse="true">

常用Git命令

撤销commit并与线上版本保持同步: git reset --hard origin/F061_XYT_167097606
删除新增的所有问题: git clean -df

weinre使用

  1. 安装weinre
  2. 运行weinre --httpPort 8181 --boundHost -all-

Http-server 启动Https服务

生成证书

  1. openssl genrsa 1024 > d:/private.pem
  2. openssl req -new -key d:/private.pem -out d:/csr.pem
  3. openssl x509 -req -days 365 -in d:/csr.pem -signkey d:/private.pem -out d://file.crt
  1. http-server --cert d:\file.crt --key d:\private.pem --ssl --cors -p 443

调试

Charles添加跨域响应头

1. Ctrl + Alt + R,打开Rewrite面板;
2. Enable Rewrite,新增规则;
3. 配置上面:Location: https://mxfd.vipstatic.com/* 
4. 配置下面:
    a. Remove Header Access-Control-Allow-Origin, where设置为Response
    b. Add Header Access-Control-Allow-Origin *, where设置为Response

Fiddler添加跨域响应头

1. Ctrl + R安装脚本编辑器;
2. 找到函数static function OnBeforeResponse(oSession: Session);
3. 在函数中添加oSession.oResponse["Access-Control-Allow-Origin"] = "*";
4. 保存

FreeMarker 转JSON

  1. <#-- ftl中的对象转换成json,只转换hash 数组 类型数据-->
  2. <#function objectToJsonFunction object>
  3. <#if object??>
  4. <#if object?is_enumerable>
  5. <#local json = '['>
  6. <#list object as item>
  7. <#if item?is_number >
  8. <#if item_index &gt; 0 && json != "[" >
  9. <#local json = json +',' >
  10. </#if>
  11. <#local json = json + '${item}'>
  12. <#elseif item?is_string>
  13. <#if item_index &gt; 0 && json != "[" >
  14. <#local json = json +',' >
  15. </#if>
  16. <#local json = json + '"${item?html!""?js_string}"'>
  17. <#elseif item?is_boolean >
  18. <#if item_index &gt; 0 && json != "[" >
  19. <#local json = json +',' >
  20. </#if>
  21. <#local json = json + '${item?string("true", "false")}'>
  22. <#elseif item?is_enumerable && !(item?is_method) >
  23. <#if item_index &gt; 0 && json != "[" >
  24. <#local json = json +',' >
  25. </#if>
  26. <#local json = json + objectToJsonFunction(item)>
  27. <#elseif item?is_hash>
  28. <#if item_index &gt; 0 && json != "[" >
  29. <#local json = json +',' >
  30. </#if>
  31. <#local json = json + objectToJsonFunction(item)>
  32. </#if>
  33. </#list>
  34. <#return json + ']'>
  35. <#elseif object?is_hash>
  36. <#local json = "{">
  37. <#assign keys = object?keys>
  38. <#list keys as key>
  39. <#if object[key]?? && !(object[key]?is_method) && key != "class">
  40. <#if object[key]?is_number>
  41. <#if key_index &gt; 0 && json != "{" >
  42. <#local json = json +',' >
  43. </#if>
  44. <#local json = json + '"${key}": ${object[key]}'>
  45. <#elseif object[key]?is_string>
  46. <#if key_index &gt; 0 && json != "{" >
  47. <#local json = json +',' >
  48. </#if>
  49. <#local json = json + '"${key}": "${object[key]?html!""?js_string}"'>
  50. <#elseif object[key]?is_boolean >
  51. <#if key_index &gt; 0 && json != "{" >
  52. <#local json = json +',' >
  53. </#if>
  54. <#local json = json + '"${key}": ${object[key]?string("true", "false")}'>
  55. <#elseif object[key]?is_enumerable >
  56. <#if key_index &gt; 0 && json != "{" >
  57. <#local json = json +',' >
  58. </#if>
  59. <#local json = json + '"${key}":'+ objectToJsonFunction(object[key])>
  60. <#elseif object[key]?is_hash>
  61. <#if key_index &gt; 0 && json != "{" >
  62. <#local json = json +',' >
  63. </#if>
  64. <#local json = json + '"${key}":'+ objectToJsonFunction(object[key])>
  65. </#if>
  66. </#if>
  67. </#list>
  68. <#return json +"}">
  69. </#if>
  70. <#else>
  71. <#return "{}">
  72. </#if>
  73. </#function>

FreeMarker 判断多个变量是否为空

如果传入的参数,有一个为空或不存在,则返回false,否则返回true

  1. <#--判断所有传入的参数是否为空-->
  2. <#function isArrNull datas...>
  3. <#list datas as data>
  4. <#if !(data?? && data != "")>
  5. <#return false>
  6. </#if>
  7. </#list>
  8. <#return true>
  9. </#function>

使用方法:

  1. <#--格式化地区数据-->
  2. <#if isArrNull(stayProvince, stayCity, stayRegion, stayProvinceName, stayCityName, stayRegionName)>
  3. <#assign
  4. addressCode = "${stayProvince},${stayCity},${stayRegion}"
  5. addressValue = "${stayProvinceName},${stayCityName},${stayRegionName}"
  6. >
  7. </#if>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注