完成打包工具项目;部分bug更新。
This commit is contained in:
parent
88ba24077c
commit
d701cb486a
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,7 +24,7 @@ ipch/
|
|||||||
*.dvi
|
*.dvi
|
||||||
*.log
|
*.log
|
||||||
*.ps
|
*.ps
|
||||||
|
modules.json
|
||||||
*.sdf
|
*.sdf
|
||||||
*.opensdf
|
*.opensdf
|
||||||
|
|
||||||
@ -73,3 +73,4 @@ deploy/
|
|||||||
*.crx
|
*.crx
|
||||||
/Mobile12306New/js/_dev
|
/Mobile12306New/js/_dev
|
||||||
/Mobile12306New/css/_dev
|
/Mobile12306New/css/_dev
|
||||||
|
wwwroot/
|
@ -18,6 +18,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RwTicketAssistantV2", "RwTi
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mobile12306New", "Mobile12306New\Mobile12306New.csproj", "{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mobile12306New", "Mobile12306New\Mobile12306New.csproj", "{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildTools", "BuildTools", "{F6960416-F825-4800-8FD4-C72908A4A6CC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeployTools", "DeployTools\DeployTools.csproj", "{E958D106-A3EE-46AF-B3E5-E62FC96F2F94}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -40,6 +44,10 @@ Global
|
|||||||
{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4B41EA5E-B7CD-4FC6-B9E3-9AE5222695F6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E958D106-A3EE-46AF-B3E5-E62FC96F2F94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E958D106-A3EE-46AF-B3E5-E62FC96F2F94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E958D106-A3EE-46AF-B3E5-E62FC96F2F94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E958D106-A3EE-46AF-B3E5-E62FC96F2F94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
BIN
BuildTools/AjaxMinifier.exe
Normal file
BIN
BuildTools/AjaxMinifier.exe
Normal file
Binary file not shown.
BIN
BuildTools/compiler.jar
Normal file
BIN
BuildTools/compiler.jar
Normal file
Binary file not shown.
6
DeployTools/App.config
Normal file
6
DeployTools/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="minifyCmdPath" value="C:\Software\nodejs\minify.cmd"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
73
DeployTools/DeployTools.csproj
Normal file
73
DeployTools/DeployTools.csproj
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{E958D106-A3EE-46AF-B3E5-E62FC96F2F94}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>DeployTools</RootNamespace>
|
||||||
|
<AssemblyName>DeployTools</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||||
|
<RestorePackages>true</RestorePackages>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.configuration" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
424
DeployTools/Program.cs
Normal file
424
DeployTools/Program.cs
Normal file
@ -0,0 +1,424 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace DeployTools
|
||||||
|
{
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static string _projectRoot;
|
||||||
|
static string _sourceDirectory;
|
||||||
|
static string _destinationDirectory;
|
||||||
|
|
||||||
|
static string _ajaxminiTool;
|
||||||
|
|
||||||
|
static Dictionary<string, string> _sourceFiles;
|
||||||
|
static Dictionary<string, string> _moduleMap;
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
_projectRoot = Path.GetFullPath(Path.Combine(Assembly.GetExecutingAssembly().Location, @"..\..\..\.."));
|
||||||
|
_sourceDirectory = Path.Combine(_projectRoot, "Web12306");
|
||||||
|
_destinationDirectory = Path.Combine(_projectRoot, "wwwroot");
|
||||||
|
_ajaxminiTool = Path.Combine(_projectRoot, "BuildTools\\AjaxMinifier.exe");
|
||||||
|
_moduleMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
//1.创建目标目录
|
||||||
|
Console.WriteLine("正在准备目标目录....");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Directory.Exists(_destinationDirectory))
|
||||||
|
Directory.Delete(_destinationDirectory, true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
Directory.CreateDirectory(_destinationDirectory);
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
//2.创建文件列表
|
||||||
|
Console.WriteLine("正在扫描文件列表...");
|
||||||
|
CreateFileList();
|
||||||
|
Console.WriteLine("文件总数: {0}", _sourceFiles.Count);
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
//3.复制文件
|
||||||
|
Console.WriteLine("正在将文件复制到目标目录...");
|
||||||
|
CopySourceFiles();
|
||||||
|
|
||||||
|
//4.合并处理css文件
|
||||||
|
Console.WriteLine("正在合并样式表文件...");
|
||||||
|
ProcessCss("css\\index.css");
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
//5.处理js文件
|
||||||
|
ProcessScriptFiles();
|
||||||
|
|
||||||
|
//6.合并js文件
|
||||||
|
CombineScript();
|
||||||
|
|
||||||
|
//7.压缩html
|
||||||
|
ProcessHtml();
|
||||||
|
|
||||||
|
//8.写入记录
|
||||||
|
WriteModuleMap();
|
||||||
|
|
||||||
|
//9.清理目录
|
||||||
|
CleanupDirectory();
|
||||||
|
|
||||||
|
Console.WriteLine(_projectRoot);
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CleanupDirectory()
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在清理目标目录...");
|
||||||
|
|
||||||
|
foreach (var directory in Directory.GetDirectories(_destinationDirectory))
|
||||||
|
{
|
||||||
|
CleanupDirectory(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("清理目标目录完成");
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CleanupDirectory(string path)
|
||||||
|
{
|
||||||
|
var directorys = Directory.GetDirectories(path);
|
||||||
|
foreach (var directory in directorys)
|
||||||
|
{
|
||||||
|
CleanupDirectory(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.GetDirectories(path).Length > 0 || Directory.GetFiles(path).Length > 0)
|
||||||
|
return;
|
||||||
|
Directory.Delete(path);
|
||||||
|
Console.WriteLine("\t已删除空目录 {0}", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WriteModuleMap()
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在写入模块列表记录...");
|
||||||
|
|
||||||
|
var file = "modules.json";
|
||||||
|
var fullFile = Path.Combine(_projectRoot, file);
|
||||||
|
File.WriteAllText(fullFile, JsonConvert.SerializeObject(_moduleMap.Select(s => new
|
||||||
|
{
|
||||||
|
module = s.Key,
|
||||||
|
path = s.Value
|
||||||
|
}).ToArray()));
|
||||||
|
|
||||||
|
Console.WriteLine("模块列表记录完成");
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessHtml()
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在处理HTML页面文件...");
|
||||||
|
|
||||||
|
var htmlFiles = new[] { "index.html" };
|
||||||
|
foreach (var htmlFile in htmlFiles)
|
||||||
|
{
|
||||||
|
Console.Write("正在处理文件 {0} ...", htmlFile);
|
||||||
|
ProcessHtml(htmlFile);
|
||||||
|
Console.WriteLine("完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("HTML页面文件处理完成");
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessHtml(string file)
|
||||||
|
{
|
||||||
|
var fileFull = Path.GetFullPath(Path.Combine(_destinationDirectory, file));
|
||||||
|
var content = File.ReadAllText(fileFull);
|
||||||
|
|
||||||
|
//处理模板
|
||||||
|
content = Regex.Replace(content, @"<script[^>]*?type=['""]?text/x-dot-template['""]?[^>]*?>[\w\W]+?</script>", _ =>
|
||||||
|
{
|
||||||
|
var tpl = _.Value;
|
||||||
|
return Regex.Replace(tpl, @"[\t\s\r\n]{2,}", " ");
|
||||||
|
}, RegexOptions.IgnoreCase);
|
||||||
|
File.WriteAllText(fileFull, content);
|
||||||
|
|
||||||
|
//使用uglify 压缩
|
||||||
|
var psi = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings["minifyCmdPath"], "\"" + fileFull + "\"")
|
||||||
|
{
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
StandardOutputEncoding = Encoding.UTF8
|
||||||
|
};
|
||||||
|
var p = Process.Start(psi);
|
||||||
|
content = p.StandardOutput.ReadToEnd();
|
||||||
|
File.WriteAllText(fileFull, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CombineScript()
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在合并脚本文件...");
|
||||||
|
|
||||||
|
var targetHtml = "index.html";
|
||||||
|
var targetFullHtml = Path.Combine(_destinationDirectory, targetHtml);
|
||||||
|
var targetContent = File.ReadAllText(targetFullHtml);
|
||||||
|
|
||||||
|
var scripts = _sourceFiles.Keys.ToArray().Where(s => s.EndsWith(".js", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
//处理script标签
|
||||||
|
var allScriptTags = new List<string>();
|
||||||
|
targetContent = Regex.Replace(targetContent, @"<script.*?src=['""]?([^\s'"">]+?)['""\s>].*?</script>", _ =>
|
||||||
|
{
|
||||||
|
allScriptTags.Add(Path.GetFullPath(Path.Combine(_destinationDirectory, _.Groups[1].Value)));
|
||||||
|
return string.Empty;
|
||||||
|
});
|
||||||
|
//插入新的脚本
|
||||||
|
targetContent = targetContent.Replace("</body>", "<script src=\"js/lib.js?v" + DateTime.Now.ToString("yyyyMMddhhmmss") + "\"></script>");
|
||||||
|
File.WriteAllText(targetFullHtml, targetContent);
|
||||||
|
|
||||||
|
//合并脚本库
|
||||||
|
var extLibs = allScriptTags.Take(allScriptTags.Count - 1).ToArray();
|
||||||
|
var extLibContent = string.Join(";", extLibs.Select(s =>
|
||||||
|
{
|
||||||
|
var path = Path.Combine(_destinationDirectory, s);
|
||||||
|
var content = File.ReadAllText(path);
|
||||||
|
File.Delete(path);
|
||||||
|
return content;
|
||||||
|
}));
|
||||||
|
//页面脚本
|
||||||
|
var scriptsHash = new HashSet<string>(allScriptTags, StringComparer.OrdinalIgnoreCase);
|
||||||
|
var pageLibContent = string.Join(";", scripts.Select(s =>
|
||||||
|
{
|
||||||
|
var path = Path.GetFullPath(Path.Combine(_destinationDirectory, s));
|
||||||
|
if (scriptsHash.Contains(path))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var content = File.ReadAllText(path);
|
||||||
|
File.Delete(path);
|
||||||
|
return content;
|
||||||
|
}).Where(s => !string.IsNullOrEmpty(s)));
|
||||||
|
|
||||||
|
//引导脚本
|
||||||
|
var bootScriptFile = Path.GetFullPath(Path.Combine(_destinationDirectory, allScriptTags.Last()));
|
||||||
|
var bootScript = File.ReadAllText(bootScriptFile);
|
||||||
|
File.Delete(bootScriptFile);
|
||||||
|
|
||||||
|
var extLibFile = "js/lib.js";
|
||||||
|
var extLibFullFile = Path.Combine(_destinationDirectory, extLibFile);
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllText(extLibFullFile, string.Join(";", new[] { extLibContent, pageLibContent, bootScript }));
|
||||||
|
|
||||||
|
Console.WriteLine("脚本文件合并完成");
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessScriptFiles()
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在处理脚本文件...");
|
||||||
|
foreach (var file in _sourceFiles.Where(s => s.Key.EndsWith(".js", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
RewriteModuleId(file.Key);
|
||||||
|
|
||||||
|
//压缩
|
||||||
|
CompressScript(file.Key);
|
||||||
|
}
|
||||||
|
Console.WriteLine("脚本文件处理完成");
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CompressScript(string filepath)
|
||||||
|
{
|
||||||
|
Console.Write("正在压缩 " + filepath + "...");
|
||||||
|
filepath = Path.GetFullPath(Path.Combine(_destinationDirectory, filepath));
|
||||||
|
Process.Start(new ProcessStartInfo(_ajaxminiTool, "-comments:none -esc:true \"" + filepath + "\" -out \"" + filepath + "\"")
|
||||||
|
{
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden
|
||||||
|
}).WaitForExit();
|
||||||
|
|
||||||
|
Console.WriteLine("压缩完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RewriteModuleId(string filepath)
|
||||||
|
{
|
||||||
|
Console.Write("正在处理文件 {0}", filepath);
|
||||||
|
|
||||||
|
filepath = Path.GetFullPath(Path.Combine(_destinationDirectory, filepath));
|
||||||
|
var folder = Path.GetDirectoryName(filepath);
|
||||||
|
|
||||||
|
var content = File.ReadAllText(filepath);
|
||||||
|
|
||||||
|
//是否是模块?
|
||||||
|
var depList = new List<string>();
|
||||||
|
if (Regex.IsMatch(content, @"^[\r\n\s]*(define\()\s*(function\s*\()", RegexOptions.IgnoreCase))
|
||||||
|
{
|
||||||
|
var hash = GetModuleId(filepath);
|
||||||
|
Console.WriteLine("正在处理...");
|
||||||
|
Console.WriteLine("\t模块ID:{0}", hash);
|
||||||
|
|
||||||
|
//替换内容,并获得所有的模块ID
|
||||||
|
content = Regex.Replace(content, @"([\r\n=\s]require\s*\(\s*['""])([^'""]+)(['""]\))", _ =>
|
||||||
|
{
|
||||||
|
var path = Path.GetFullPath(Path.Combine(folder, _.Groups[2].Value));
|
||||||
|
var id = GetModuleId(path);
|
||||||
|
depList.Add(id);
|
||||||
|
Console.WriteLine("\t依赖模块ID:{0}", id);
|
||||||
|
return _.Groups[1].Value + id + _.Groups[3].Value;
|
||||||
|
}, RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
content = Regex.Replace(content, @"^[\r\n\s]*(define\()\s*(function\s*\()", _ => _.Groups[1].Value + "\"" + hash + "\",[" + string.Join(",", depList.Select(s => "\"" + s + "\"")) + "]," + _.Groups[2].Value, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("非模块,已跳过");
|
||||||
|
}
|
||||||
|
content = Regex.Replace(content, @"(seajs\.use\s*\(\s*['""])([^'""]+)(['""]\))", _ =>
|
||||||
|
{
|
||||||
|
var path = Path.GetFullPath(Path.Combine(folder, _.Groups[2].Value));
|
||||||
|
var id = GetModuleId(path);
|
||||||
|
depList.Add(id);
|
||||||
|
Console.WriteLine("\t依赖模块ID:{0}", id);
|
||||||
|
return _.Groups[1].Value + id + _.Groups[3].Value;
|
||||||
|
}, RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
File.WriteAllText(filepath, content);
|
||||||
|
Console.WriteLine("已处理完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetModuleId(string path)
|
||||||
|
{
|
||||||
|
if (!path.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
|
||||||
|
path += ".js";
|
||||||
|
|
||||||
|
if (_moduleMap.ContainsKey(path))
|
||||||
|
return _moduleMap[path];
|
||||||
|
|
||||||
|
var hash = string.Join("", MD5CryptoServiceProvider.Create().ComputeHash(Encoding.UTF8.GetBytes(path.ToLower())).Select(s => s.ToString("X2")).ToArray());
|
||||||
|
_moduleMap.Add(path, hash);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessCss(string cssfile)
|
||||||
|
{
|
||||||
|
Console.Write("正在处理 " + cssfile + "...");
|
||||||
|
var content = ImportCssFile(cssfile);
|
||||||
|
var fullPath = Path.Combine(_destinationDirectory, cssfile);
|
||||||
|
|
||||||
|
//corrent reference
|
||||||
|
content = Regex.Replace(content, @"url\(['""]?(?!data:)([^?'""]+?)(\?[^'""\)]*?)?['""]?\)", _ =>
|
||||||
|
{
|
||||||
|
var extag = _.Groups[2].Success ? _.Groups[2].Value : "";
|
||||||
|
return "url(\"" + GetRelativePath(Path.GetDirectoryName(cssfile), GetTargetSubPath(_.Groups[1].Value)).Replace('\\', '/').ToLower() + extag + "\")";
|
||||||
|
}, RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
File.WriteAllText(Path.Combine(_destinationDirectory, cssfile), content);
|
||||||
|
Console.WriteLine("合并完成");
|
||||||
|
|
||||||
|
Console.Write("正在压缩 " + cssfile + "...");
|
||||||
|
Process.Start(new ProcessStartInfo(_ajaxminiTool, "-comments:none \"" + fullPath + "\" -out \"" + fullPath + "\"")
|
||||||
|
{
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden
|
||||||
|
}).WaitForExit();
|
||||||
|
|
||||||
|
Console.WriteLine("压缩完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetRelativePath(string basePath, string secondPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(secondPath) || string.IsNullOrEmpty(basePath))
|
||||||
|
return secondPath;
|
||||||
|
|
||||||
|
var ps1 = basePath.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var ps2 = secondPath.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
var upperBound = Math.Min(ps1.Length, ps2.Length);
|
||||||
|
var startIndex = Enumerable.Range(0, upperBound).FirstOrDefault(s => string.Compare(ps1[s], ps2[s], true) != 0);
|
||||||
|
|
||||||
|
if (startIndex == 0)
|
||||||
|
return "/" + secondPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
if (ps1.Length == startIndex && ps2.Length <= startIndex)
|
||||||
|
return "./";
|
||||||
|
|
||||||
|
return string.Join(Path.AltDirectorySeparatorChar.ToString(), Enumerable.Repeat("..", ps1.Length - startIndex).Concat(ps2.Skip(startIndex)).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetProjectSubPath(string path)
|
||||||
|
{
|
||||||
|
var removeLength = _sourceDirectory.EndsWith("\\") ? _sourceDirectory.Length : _sourceDirectory.Length + 1;
|
||||||
|
return path.Remove(0, removeLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetTargetSubPath(string path)
|
||||||
|
{
|
||||||
|
var removeLength = _destinationDirectory.EndsWith("\\") ? _destinationDirectory.Length : _destinationDirectory.Length + 1;
|
||||||
|
return path.Remove(0, removeLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修正CSS文件引用路径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">要修正的css文件路径</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
static string ImportCssFile(string filePath)
|
||||||
|
{
|
||||||
|
var fullPath = Path.Combine(_destinationDirectory, filePath);
|
||||||
|
var content = File.ReadAllText(fullPath);
|
||||||
|
var directory = Path.GetDirectoryName(fullPath);
|
||||||
|
|
||||||
|
File.Delete(fullPath);
|
||||||
|
|
||||||
|
//import
|
||||||
|
content = Regex.Replace(content, @"@import\s+url\(['""]?(?!data:)([^?'""]+?)(\?[^'""\)]*?)?['""]?\);?", _ => ImportCssFile(Path.GetFullPath(Path.Combine(directory, _.Groups[1].Value.Replace('/', '\\')))), RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
//reference
|
||||||
|
content = Regex.Replace(content, @"url\(['""]?(?!data:)([^?'""]+?)(\?[^'""\)]*?)?['""]?\)", _ =>
|
||||||
|
{
|
||||||
|
var extag = _.Groups[2].Success ? _.Groups[2].Value : "";
|
||||||
|
var path = _.Groups[1].Value.Replace('/', '\\');
|
||||||
|
if (path[0] == '\\')
|
||||||
|
path = Path.Combine(_destinationDirectory, path.Remove(0, 1));
|
||||||
|
else
|
||||||
|
path = Path.Combine(directory, path);
|
||||||
|
return string.Format("url(\"{0}{1}\")", Path.GetFullPath(path), extag);
|
||||||
|
}, RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CreateFileList()
|
||||||
|
{
|
||||||
|
var include = new[] { @".*\.*?\.(jpg|gif|png|html|js|svg|eot|ttf|woff|otf|css)$" };
|
||||||
|
var fileter = new[] { @"^(scripts|bin)\.*" };
|
||||||
|
|
||||||
|
var allfiles = Directory.GetFiles(_sourceDirectory, "*.*", SearchOption.AllDirectories).ToDictionary(GetProjectSubPath, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
//过滤
|
||||||
|
_sourceFiles = allfiles.Where(s => include.Any(y => Regex.IsMatch(s.Key, y, RegexOptions.IgnoreCase)) && !fileter.Any(y => Regex.IsMatch(s.Key, y, RegexOptions.IgnoreCase)))
|
||||||
|
.ToDictionary(s => s.Key, s => s.Value, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CopySourceFiles()
|
||||||
|
{
|
||||||
|
foreach (var file in _sourceFiles)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\t正在复制:{0}", file.Key);
|
||||||
|
|
||||||
|
var target = Path.Combine(_destinationDirectory, file.Key).ToLower();
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(target));
|
||||||
|
File.Copy(file.Value, target);
|
||||||
|
}
|
||||||
|
Console.WriteLine("复制完成");
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
DeployTools/Properties/AssemblyInfo.cs
Normal file
36
DeployTools/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// 有关程序集的常规信息通过以下
|
||||||
|
// 特性集控制。更改这些特性值可修改
|
||||||
|
// 与程序集关联的信息。
|
||||||
|
[assembly: AssemblyTitle("DeployTools")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Fish")]
|
||||||
|
[assembly: AssemblyProduct("DeployTools")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Fish 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// 将 ComVisible 设置为 false 使此程序集中的类型
|
||||||
|
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
||||||
|
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||||
|
[assembly: Guid("62150c48-31d6-406f-aa19-7770188bd334")]
|
||||||
|
|
||||||
|
// 程序集的版本信息由下面四个值组成:
|
||||||
|
//
|
||||||
|
// 主版本
|
||||||
|
// 次版本
|
||||||
|
// 生成号
|
||||||
|
// 修订号
|
||||||
|
//
|
||||||
|
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||||
|
// 方法是按如下所示使用“*”:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
4
DeployTools/packages.config
Normal file
4
DeployTools/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net40" />
|
||||||
|
</packages>
|
2529
Web12306/Scripts/typings/chrome.d.ts
vendored
Normal file
2529
Web12306/Scripts/typings/chrome.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -165,7 +165,6 @@
|
|||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
<Content Include="images\autorefresh.png" />
|
<Content Include="images\autorefresh.png" />
|
||||||
<Content Include="images\cat.png" />
|
<Content Include="images\cat.png" />
|
||||||
<Content Include="images\code.png" />
|
|
||||||
<Content Include="images\css-sprite.mkm" />
|
<Content Include="images\css-sprite.mkm" />
|
||||||
<Content Include="images\loading.gif" />
|
<Content Include="images\loading.gif" />
|
||||||
<Content Include="images\css-sprite.png" />
|
<Content Include="images\css-sprite.png" />
|
||||||
@ -176,7 +175,6 @@
|
|||||||
<Content Include="images\search-box-bg.png" />
|
<Content Include="images\search-box-bg.png" />
|
||||||
<Content Include="images\ticket-submit-info-arrow-w.png" />
|
<Content Include="images\ticket-submit-info-arrow-w.png" />
|
||||||
<Content Include="images\ticket-submit-info-arrow.png" />
|
<Content Include="images\ticket-submit-info-arrow.png" />
|
||||||
<Content Include="images\ticket-submit-qr.png" />
|
|
||||||
<Content Include="index.html" />
|
<Content Include="index.html" />
|
||||||
<Content Include="js\account\keepalive.js" />
|
<Content Include="js\account\keepalive.js" />
|
||||||
<Content Include="js\account\sessionMgr.js" />
|
<Content Include="js\account\sessionMgr.js" />
|
||||||
@ -186,7 +184,6 @@
|
|||||||
<Content Include="css\fa\fonts\fontawesome-webfont.woff" />
|
<Content Include="css\fa\fonts\fontawesome-webfont.woff" />
|
||||||
<Content Include="css\fa\fonts\FontAwesome.otf" />
|
<Content Include="css\fa\fonts\FontAwesome.otf" />
|
||||||
<Content Include="chatservers.json" />
|
<Content Include="chatservers.json" />
|
||||||
<None Include="js\docs\chrome-api-vsdoc.js" />
|
|
||||||
<Content Include="js\data.js" />
|
<Content Include="js\data.js" />
|
||||||
<Content Include="js\modules\doT.js" />
|
<Content Include="js\modules\doT.js" />
|
||||||
<Content Include="js\otn\orderprocess.js" />
|
<Content Include="js\otn\orderprocess.js" />
|
||||||
@ -255,6 +252,7 @@
|
|||||||
<Content Include="packages.config" />
|
<Content Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<TypeScriptCompile Include="Scripts\typings\chrome.d.ts" />
|
||||||
<TypeScriptCompile Include="Scripts\typings\jquery\jquery.d.ts" />
|
<TypeScriptCompile Include="Scripts\typings\jquery\jquery.d.ts" />
|
||||||
<TypeScriptCompile Include="Scripts\typings\underscore.d.ts" />
|
<TypeScriptCompile Include="Scripts\typings\underscore.d.ts" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -139,7 +139,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.options-param .options-train-selectorwarp table {
|
.options-param .options-train-selectorwarp table {
|
||||||
width: 500px;
|
width: 550px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.options-param .options-train-selectorwarp table th {
|
.options-param .options-train-selectorwarp table th {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
@ -14,8 +14,6 @@
|
|||||||
if (sessionStorage["_passenger"])
|
if (sessionStorage["_passenger"])
|
||||||
passengers = JSON.parse(sessionStorage["_passenger"]);
|
passengers = JSON.parse(sessionStorage["_passenger"]);
|
||||||
|
|
||||||
//var LoginUser = require("./LoginUser.js");
|
|
||||||
|
|
||||||
var SessionMgr = function () {
|
var SessionMgr = function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
var _passengerInLoad = null;
|
var _passengerInLoad = null;
|
||||||
|
@ -118,7 +118,10 @@
|
|||||||
chrome.runtime.sendMessage(window.targetExtensionId, { action: "getStorage" }, function (m) {
|
chrome.runtime.sendMessage(window.targetExtensionId, { action: "getStorage" }, function (m) {
|
||||||
window.storage = m.detail;
|
window.storage = m.detail;
|
||||||
|
|
||||||
seajs.use("ui/" + pagename);
|
//TODO: 因为压缩需要mark所有的页面名,所以不可以用变量计算。
|
||||||
|
if (pagename === "index")
|
||||||
|
seajs.use("ui/index");
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
start.fail(function () {
|
start.fail(function () {
|
||||||
|
1132
Web12306/js/docs/chrome-api-vsdoc.js
vendored
1132
Web12306/js/docs/chrome-api-vsdoc.js
vendored
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
|||||||
// 2011, Laura Doktorova, https://github.com/olado/doT
|
// 2011, Laura Doktorova, https://github.com/olado/doT
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
(function () {
|
(function (window) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var doT = {
|
var doT = {
|
||||||
@ -25,15 +25,14 @@
|
|||||||
},
|
},
|
||||||
template: undefined, //fn, compile template
|
template: undefined, //fn, compile template
|
||||||
compile: undefined //fn, for express
|
compile: undefined //fn, for express
|
||||||
}, global;
|
};
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && module.exports) {
|
if (typeof module !== 'undefined' && module.exports) {
|
||||||
module.exports = doT;
|
module.exports = doT;
|
||||||
} else if (typeof define === 'function' && define.amd) {
|
} else if (typeof define === 'function' && define.amd) {
|
||||||
define(function () { return doT; });
|
define(function () { return doT; });
|
||||||
} else {
|
} else {
|
||||||
global = (function () { return this || (0, eval)('this'); }());
|
window.doT = doT;
|
||||||
global.doT = doT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function encodeHTMLSource() {
|
function encodeHTMLSource() {
|
||||||
@ -170,4 +169,4 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}());
|
})(window);
|
||||||
|
@ -100,109 +100,109 @@ var emit = seajs.emit = function(name, data) {
|
|||||||
* util-path.js - The utilities for operating path such as id, uri
|
* util-path.js - The utilities for operating path such as id, uri
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var DIRNAME_RE = /[^?#]*\//
|
var DIRNAME_RE = /[^?#]*\//;
|
||||||
|
|
||||||
var DOT_RE = /\/\.\//g
|
var DOT_RE = /\/\.\//g;
|
||||||
var DOUBLE_DOT_RE = /\/[^/]+\/\.\.\//
|
var DOUBLE_DOT_RE = /\/[^/]+\/\.\.\//;
|
||||||
var DOUBLE_SLASH_RE = /([^:/])\/\//g
|
var DOUBLE_SLASH_RE = /([^:/])\/\//g;
|
||||||
|
|
||||||
// Extract the directory portion of a path
|
// Extract the directory portion of a path
|
||||||
// dirname("a/b/c.js?t=123#xx/zz") ==> "a/b/"
|
// dirname("a/b/c.js?t=123#xx/zz") ==> "a/b/"
|
||||||
// ref: http://jsperf.com/regex-vs-split/2
|
// ref: http://jsperf.com/regex-vs-split/2
|
||||||
function dirname(path) {
|
function dirname(path) {
|
||||||
return path.match(DIRNAME_RE)[0]
|
return path.match(DIRNAME_RE)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonicalize a path
|
// Canonicalize a path
|
||||||
// realpath("http://test.com/a//./b/../c") ==> "http://test.com/a/c"
|
// realpath("http://test.com/a//./b/../c") ==> "http://test.com/a/c"
|
||||||
function realpath(path) {
|
function realpath(path) {
|
||||||
// /a/b/./c/./d ==> /a/b/c/d
|
// /a/b/./c/./d ==> /a/b/c/d
|
||||||
path = path.replace(DOT_RE, "/")
|
path = path.replace(DOT_RE, "/");
|
||||||
|
|
||||||
// a/b/c/../../d ==> a/b/../d ==> a/d
|
// a/b/c/../../d ==> a/b/../d ==> a/d
|
||||||
while (path.match(DOUBLE_DOT_RE)) {
|
while (path.match(DOUBLE_DOT_RE)) {
|
||||||
path = path.replace(DOUBLE_DOT_RE, "/")
|
path = path.replace(DOUBLE_DOT_RE, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
// a//b/c ==> a/b/c
|
// a//b/c ==> a/b/c
|
||||||
path = path.replace(DOUBLE_SLASH_RE, "$1/")
|
path = path.replace(DOUBLE_SLASH_RE, "$1/");
|
||||||
|
|
||||||
return path
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize an id
|
// Normalize an id
|
||||||
// normalize("path/to/a") ==> "path/to/a.js"
|
// normalize("path/to/a") ==> "path/to/a.js"
|
||||||
// NOTICE: substring is faster than negative slice and RegExp
|
// NOTICE: substring is faster than negative slice and RegExp
|
||||||
function normalize(path) {
|
function normalize(path) {
|
||||||
var last = path.length - 1
|
var last = path.length - 1;
|
||||||
var lastC = path.charAt(last)
|
var lastC = path.charAt(last);
|
||||||
|
|
||||||
// If the uri ends with `#`, just return it without '#'
|
// If the uri ends with `#`, just return it without '#'
|
||||||
if (lastC === "#") {
|
if (lastC === "#") {
|
||||||
return path.substring(0, last)
|
return path.substring(0, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (path.substring(last - 2) === ".js" ||
|
return (path.substring(last - 2) === ".js" ||
|
||||||
path.indexOf("?") > 0 ||
|
path.indexOf("?") > 0 ||
|
||||||
path.substring(last - 3) === ".css" ||
|
path.substring(last - 3) === ".css" ||
|
||||||
lastC === "/") ? path : path + ".js"
|
lastC === "/") ? path : path + ".js";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var PATHS_RE = /^([^/:]+)(\/.+)$/
|
var PATHS_RE = /^([^/:]+)(\/.+)$/;
|
||||||
var VARS_RE = /{([^{]+)}/g
|
var VARS_RE = /{([^{]+)}/g;
|
||||||
|
|
||||||
function parseAlias(id) {
|
function parseAlias(id) {
|
||||||
var alias = data.alias
|
var alias = data.alias;
|
||||||
return alias && isString(alias[id]) ? alias[id] : id
|
return alias && isString(alias[id]) ? alias[id] : id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsePaths(id) {
|
function parsePaths(id) {
|
||||||
var paths = data.paths
|
var paths = data.paths;
|
||||||
var m
|
var m;
|
||||||
|
|
||||||
if (paths && (m = id.match(PATHS_RE)) && isString(paths[m[1]])) {
|
if (paths && (m = id.match(PATHS_RE)) && isString(paths[m[1]])) {
|
||||||
id = paths[m[1]] + m[2]
|
id = paths[m[1]] + m[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return id
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseVars(id) {
|
function parseVars(id) {
|
||||||
var vars = data.vars
|
var vars = data.vars;
|
||||||
|
|
||||||
if (vars && id.indexOf("{") > -1) {
|
if (vars && id.indexOf("{") > -1) {
|
||||||
id = id.replace(VARS_RE, function (m, key) {
|
id = id.replace(VARS_RE, function (m, key) {
|
||||||
return isString(vars[key]) ? vars[key] : m
|
return isString(vars[key]) ? vars[key] : m;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return id
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseMap(uri) {
|
function parseMap(uri) {
|
||||||
var map = data.map
|
var map = data.map;
|
||||||
var ret = uri
|
var ret = uri;
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
for (var i = 0, len = map.length; i < len; i++) {
|
for (var i = 0, len = map.length; i < len; i++) {
|
||||||
var rule = map[i]
|
var rule = map[i];
|
||||||
|
|
||||||
ret = isFunction(rule) ?
|
ret = isFunction(rule) ?
|
||||||
(rule(uri) || uri) :
|
(rule(uri) || uri) :
|
||||||
uri.replace(rule[0], rule[1])
|
uri.replace(rule[0], rule[1]);
|
||||||
|
|
||||||
// Only apply the first matched rule
|
// Only apply the first matched rule
|
||||||
if (ret !== uri) break
|
if (ret !== uri) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var ABSOLUTE_RE = /^\/\/.|:\//
|
var ABSOLUTE_RE = /^\/\/.|:\//;
|
||||||
var ROOT_DIR_RE = /^.*?\/\/.*?\//
|
var ROOT_DIR_RE = /^.*?\/\/.*?\//;
|
||||||
|
|
||||||
function addBase(id, refUri) {
|
function addBase(id, refUri) {
|
||||||
var ret
|
var ret
|
||||||
@ -442,20 +442,20 @@ seajs.request = request
|
|||||||
* ref: tests/research/parse-dependencies/test.html
|
* ref: tests/research/parse-dependencies/test.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var REQUIRE_RE = /"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^\/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g
|
var REQUIRE_RE = /"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^\/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g;
|
||||||
var SLASH_RE = /\\\\/g
|
var SLASH_RE = /\\\\/g;
|
||||||
|
|
||||||
function parseDependencies(code) {
|
function parseDependencies(code) {
|
||||||
var ret = []
|
var ret = [];
|
||||||
|
|
||||||
code.replace(SLASH_RE, "")
|
code.replace(SLASH_RE, "")
|
||||||
.replace(REQUIRE_RE, function(m, m1, m2) {
|
.replace(REQUIRE_RE, function(m, m1, m2) {
|
||||||
if (m2) {
|
if (m2) {
|
||||||
ret.push(m2)
|
ret.push(m2);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
return ret
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -867,7 +867,7 @@ seajs.require = function(id) {
|
|||||||
* config.js - The configuration for the loader
|
* config.js - The configuration for the loader
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var BASE_RE = /^(.+?\/)(\?\?)?(seajs\/)+/
|
var BASE_RE = /^(.+?\/)(\?\?)?(seajs\/)+/;
|
||||||
|
|
||||||
// The root path to use for id2uri parsing
|
// The root path to use for id2uri parsing
|
||||||
// If loaderUri is `http://test.com/libs/seajs/[??][seajs/1.2.3/]sea.js`, the
|
// If loaderUri is `http://test.com/libs/seajs/[??][seajs/1.2.3/]sea.js`, the
|
||||||
@ -889,7 +889,7 @@ data.preload = (function() {
|
|||||||
|
|
||||||
// Convert `seajs-xxx` to `seajs-xxx=1`
|
// Convert `seajs-xxx` to `seajs-xxx=1`
|
||||||
// NOTE: use `seajs-xxx=1` flag in uri or cookie to preload `seajs-xxx`
|
// NOTE: use `seajs-xxx=1` flag in uri or cookie to preload `seajs-xxx`
|
||||||
var str = location.search.replace(/(seajs-\w+)(&|$)/g, "$1=1$2")
|
var str = location.search.replace(/(seajs-\w+)(&|$)/g, "$1=1$2");
|
||||||
|
|
||||||
// Add cookie string
|
// Add cookie string
|
||||||
str += " " + doc.cookie
|
str += " " + doc.cookie
|
||||||
|
@ -217,7 +217,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
document.addEventListener("networkOrCertificationError", function () {
|
document.addEventListener("networkOrCertificationError", function () {
|
||||||
//TODO UI
|
//TODO UI
|
||||||
alert("无法访问12306,可能是网络错误或证书错误,请直接访问12306试试!如果正常的话请回来刷新本页!");
|
mp.alert("无法访问12306,可能是网络错误或证书错误,请直接访问12306试试!如果正常的话请回来刷新本页!");
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -84,20 +84,20 @@
|
|||||||
var loadLoginAsyncSuggest = function () {
|
var loadLoginAsyncSuggest = function () {
|
||||||
that.fireEvent("loadSuggest");
|
that.fireEvent("loadSuggest");
|
||||||
|
|
||||||
loginTip.setState("loading", "正在获得登录随机码...");
|
loginTip.setState("loading", "正在登录中...");
|
||||||
ajax.sendPost("login/loginUserAsyn?random=" + new Date().getTime(), "leftTicket/init", {
|
ajax.sendPost("login/loginUserAsyn?random=" + new Date().getTime(), "leftTicket/init", {
|
||||||
"loginUserDTO.user_name": un,
|
"loginUserDTO.user_name": un,
|
||||||
"userDTO.password": pwd,
|
"userDTO.password": pwd,
|
||||||
"randCode": randcode
|
"randCode": randcode
|
||||||
}, "json", function () {
|
}, "json", function () {
|
||||||
if (!this.model.data || !this.model.data.status) {
|
if (!this.model.data || !this.model.data.status) {
|
||||||
loginFailed(this.model.data.loginFail);
|
loginFailed((this.model.data && this.model.data.loginFail) || (this.model.messages || ["未知错误"]).join(","));
|
||||||
} else {
|
} else {
|
||||||
realName = this.model.data.username;
|
realName = this.model.data.username;
|
||||||
submitLoginInfo();
|
submitLoginInfo();
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function () {
|
||||||
loginFailed("无法加载随机码");
|
loginFailed("网络错误,请重试");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var submitLoginInfo = function () {
|
var submitLoginInfo = function () {
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
renderUnreadNotice();
|
renderUnreadNotice();
|
||||||
};
|
};
|
||||||
var closeNotice = function () {
|
var closeNotice = function () {
|
||||||
|
if (!savedNotice || !savedNotice.items) return;
|
||||||
|
|
||||||
$("section.search-tips-container").fadeOut();
|
$("section.search-tips-container").fadeOut();
|
||||||
savedNotice.lastReadId = savedNotice.items[0].id;
|
savedNotice.lastReadId = savedNotice.items[0].id;
|
||||||
resetUnreadItems();
|
resetUnreadItems();
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
if (options.closeOnAction || this.cancel) {
|
if (options.closeOnAction || this.cancel) {
|
||||||
btn.click(function (e) {
|
btn.click(function (e) {
|
||||||
if (e.isDefaultPrevented)
|
if (e.cancel)
|
||||||
return;
|
return;
|
||||||
hideModalDialog();
|
hideModalDialog();
|
||||||
});
|
});
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
var config = exports.data[type];
|
var config = exports.data[type];
|
||||||
var imageEle = target.find("span");
|
var imageEle = target.find("span");
|
||||||
|
|
||||||
imageEle.css({ "background-image": "url(../../images/loading.gif", "background-size": "auto" });
|
imageEle.css({ "background-image": "url(/images/loading.gif)", "background-size": "auto" });
|
||||||
ajax.loadImage(config.url, config.refer, function (e) {
|
ajax.loadImage(config.url, config.refer, function (e) {
|
||||||
imageEle.css({ "background-image": "url(" + this.url + ")", "background-size": "100% 100%" });
|
imageEle.css({ "background-image": "url(" + this.url + ")", "background-size": "100% 100%" });
|
||||||
|
|
||||||
(target.is(".verify-code") ? target.closest("div, p, td") : target).find(":text").val("").each(function () { this.focus(); });
|
(target.is(".verify-code") ? target.closest("div, p, td") : target).find(":text").val("").each(function () { this.focus(); });
|
||||||
}, function () {
|
}, function () {
|
||||||
imageEle.css({ "background-image": "url(../../images/loading.gif", "background-size": "auto" });
|
imageEle.css({ "background-image": "url(/images/loading.gif)", "background-size": "auto" });
|
||||||
document.dispatchEvent(new CustomEvent("verifyCodeLoadFailed"));
|
document.dispatchEvent(new CustomEvent("verifyCodeLoadFailed"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user