[mod] 換位置
137
public/static/cocos-build/web-mobile/assets/internal/config.json
Normal file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"paths": {
|
||||
"30aC+Hnw1PF4pEcoY3kUYb": [
|
||||
"effects/builtin-2d-graphics",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"14TDKXr2NJ6LjvHPops74o": [
|
||||
"effects/builtin-2d-gray-sprite",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"f1h0LXVtJOta5JLZ1xCzfI": [
|
||||
"effects/builtin-2d-label",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"0ek66qC1NOQLjgYmi04HvX": [
|
||||
"effects/builtin-2d-spine",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"28dPjdQWxEQIG3VVl1Qm6T": [
|
||||
"effects/builtin-2d-sprite",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"82migssElAGb04Ws6NimQX": [
|
||||
"effects/builtin-3d-particle",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"2afAA24LNP4YmYiaVLiivs": [
|
||||
"effects/builtin-3d-trail",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"c0BAyVxX9JzZy8EjFrc9DU": [
|
||||
"effects/builtin-clear-stencil",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"6dkeWRTOBGXICfYQ7JUBnG": [
|
||||
"effects/builtin-unlit",
|
||||
"cc.EffectAsset"
|
||||
],
|
||||
"6fgBCSDDdPMInvyNlggls2": [
|
||||
"materials/builtin-2d-base",
|
||||
"cc.Material"
|
||||
],
|
||||
"a1U5RdJRFMFL57BdJC9H1X": [
|
||||
"materials/builtin-2d-graphics",
|
||||
"cc.Material"
|
||||
],
|
||||
"3ae7efMv1CLq2ilvUY/tQi": [
|
||||
"materials/builtin-2d-gray-sprite",
|
||||
"cc.Material"
|
||||
],
|
||||
"e0LYfU5ZlNFoAB4UiRrGUG": [
|
||||
"materials/builtin-2d-label",
|
||||
"cc.Material"
|
||||
],
|
||||
"7a/QZLET9IDreTiBfRn2PD": [
|
||||
"materials/builtin-2d-spine",
|
||||
"cc.Material"
|
||||
],
|
||||
"ecpdLyjvZBwrvm+cedCcQy": [
|
||||
"materials/builtin-2d-sprite",
|
||||
"cc.Material"
|
||||
],
|
||||
"43L6CczwNM/6GGmCYEQIoH": [
|
||||
"materials/builtin-3d-particle",
|
||||
"cc.Material"
|
||||
],
|
||||
"46bU+b5fROqIXVPG6aZWWK": [
|
||||
"materials/builtin-3d-trail",
|
||||
"cc.Material"
|
||||
],
|
||||
"cffgu4qBxEqa150o1DmRAy": [
|
||||
"materials/builtin-clear-stencil",
|
||||
"cc.Material"
|
||||
],
|
||||
"2aKWBXJHxKHLvrBUi2yYZQ": [
|
||||
"materials/builtin-unlit",
|
||||
"cc.Material"
|
||||
]
|
||||
},
|
||||
"uuids": [
|
||||
"02delMVqdBD70a/HSD99FK",
|
||||
"0ek66qC1NOQLjgYmi04HvX",
|
||||
"14TDKXr2NJ6LjvHPops74o",
|
||||
"28dPjdQWxEQIG3VVl1Qm6T",
|
||||
"2aKWBXJHxKHLvrBUi2yYZQ",
|
||||
"2afAA24LNP4YmYiaVLiivs",
|
||||
"30aC+Hnw1PF4pEcoY3kUYb",
|
||||
"3ae7efMv1CLq2ilvUY/tQi",
|
||||
"43L6CczwNM/6GGmCYEQIoH",
|
||||
"46bU+b5fROqIXVPG6aZWWK",
|
||||
"60AwGqM1dKELCGhPAR+jK6",
|
||||
"6dkeWRTOBGXICfYQ7JUBnG",
|
||||
"6fgBCSDDdPMInvyNlggls2",
|
||||
"7a/QZLET9IDreTiBfRn2PD",
|
||||
"82migssElAGb04Ws6NimQX",
|
||||
"a1U5RdJRFMFL57BdJC9H1X",
|
||||
"c0BAyVxX9JzZy8EjFrc9DU",
|
||||
"cffgu4qBxEqa150o1DmRAy",
|
||||
"e0LYfU5ZlNFoAB4UiRrGUG",
|
||||
"ecpdLyjvZBwrvm+cedCcQy",
|
||||
"f1h0LXVtJOta5JLZ1xCzfI"
|
||||
],
|
||||
"scenes": {},
|
||||
"redirect": [],
|
||||
"deps": [],
|
||||
"packs": {
|
||||
"0b6c4470e": [
|
||||
"02delMVqdBD70a/HSD99FK",
|
||||
"0ek66qC1NOQLjgYmi04HvX",
|
||||
"14TDKXr2NJ6LjvHPops74o",
|
||||
"28dPjdQWxEQIG3VVl1Qm6T",
|
||||
"2aKWBXJHxKHLvrBUi2yYZQ",
|
||||
"2afAA24LNP4YmYiaVLiivs",
|
||||
"30aC+Hnw1PF4pEcoY3kUYb",
|
||||
"3ae7efMv1CLq2ilvUY/tQi",
|
||||
"43L6CczwNM/6GGmCYEQIoH",
|
||||
"46bU+b5fROqIXVPG6aZWWK",
|
||||
"60AwGqM1dKELCGhPAR+jK6",
|
||||
"6dkeWRTOBGXICfYQ7JUBnG",
|
||||
"6fgBCSDDdPMInvyNlggls2",
|
||||
"7a/QZLET9IDreTiBfRn2PD",
|
||||
"82migssElAGb04Ws6NimQX",
|
||||
"a1U5RdJRFMFL57BdJC9H1X",
|
||||
"c0BAyVxX9JzZy8EjFrc9DU",
|
||||
"cffgu4qBxEqa150o1DmRAy",
|
||||
"e0LYfU5ZlNFoAB4UiRrGUG",
|
||||
"ecpdLyjvZBwrvm+cedCcQy",
|
||||
"f1h0LXVtJOta5JLZ1xCzfI"
|
||||
]
|
||||
},
|
||||
"name": "internal",
|
||||
"importBase": "import",
|
||||
"nativeBase": "native",
|
||||
"debug": true,
|
||||
"isZip": false,
|
||||
"encrypted": false
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
(function e(t, n, r) {
|
||||
function s(o, u) {
|
||||
if (!n[o]) {
|
||||
if (!t[o]) {
|
||||
var b = o.split("/");
|
||||
b = b[b.length - 1];
|
||||
if (!t[b]) {
|
||||
var a = "function" == typeof __require && __require;
|
||||
if (!u && a) return a(b, !0);
|
||||
if (i) return i(b, !0);
|
||||
throw new Error("Cannot find module '" + o + "'");
|
||||
}
|
||||
o = b;
|
||||
}
|
||||
var f = n[o] = {
|
||||
exports: {}
|
||||
};
|
||||
t[o][0].call(f.exports, function(e) {
|
||||
var n = t[o][1][e];
|
||||
return s(n || e);
|
||||
}, f, f.exports, e, t, n, r);
|
||||
}
|
||||
return n[o].exports;
|
||||
}
|
||||
var i = "function" == typeof __require && __require;
|
||||
for (var o = 0; o < r.length; o++) s(r[o]);
|
||||
return s;
|
||||
})({}, {}, []);
|
||||
|
After Width: | Height: | Size: 82 B |
|
After Width: | Height: | Size: 7.3 KiB |
50
public/static/cocos-build/web-mobile/assets/main/config.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"paths": {},
|
||||
"uuids": [
|
||||
"29FYIk+N1GYaeWH/q1NxQO",
|
||||
"2dL3kvpAxJu6GJ7RdqJG5J",
|
||||
"31vIlawANFZqnzLlSuHBfc",
|
||||
"41D7kWhyFGY7q4NDlzkazn",
|
||||
"6aoKpq6+5BVaCIpoemqt7E",
|
||||
"71VhFCTINJM6/Ky3oX9nBT",
|
||||
"a8Anh32NZGRZegUtSgEj26",
|
||||
"b4P/PCArtIdIH38t6mlw8Y",
|
||||
"e8Ueib+qJEhL6mXAHdnwbi",
|
||||
"e97GVMl6JHh5Ml5qEDdSGa",
|
||||
"ecpdLyjvZBwrvm+cedCcQy",
|
||||
"f0BIwQ8D5Ml7nTNQbh1YlS"
|
||||
],
|
||||
"scenes": {
|
||||
"db://assets/Scene/helloworld.fire": "2dL3kvpAxJu6GJ7RdqJG5J"
|
||||
},
|
||||
"redirect": [
|
||||
"ecpdLyjvZBwrvm+cedCcQy",
|
||||
0
|
||||
],
|
||||
"deps": [
|
||||
"internal"
|
||||
],
|
||||
"packs": {
|
||||
"03f133834": [
|
||||
"29FYIk+N1GYaeWH/q1NxQO",
|
||||
"2dL3kvpAxJu6GJ7RdqJG5J",
|
||||
"31vIlawANFZqnzLlSuHBfc",
|
||||
"41D7kWhyFGY7q4NDlzkazn",
|
||||
"e97GVMl6JHh5Ml5qEDdSGa",
|
||||
"f0BIwQ8D5Ml7nTNQbh1YlS"
|
||||
],
|
||||
"0e489d570": [
|
||||
"6aoKpq6+5BVaCIpoemqt7E",
|
||||
"71VhFCTINJM6/Ky3oX9nBT",
|
||||
"a8Anh32NZGRZegUtSgEj26",
|
||||
"b4P/PCArtIdIH38t6mlw8Y",
|
||||
"e8Ueib+qJEhL6mXAHdnwbi"
|
||||
]
|
||||
},
|
||||
"name": "main",
|
||||
"importBase": "import",
|
||||
"nativeBase": "native",
|
||||
"debug": true,
|
||||
"isZip": false,
|
||||
"encrypted": false
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "cc.Texture2D",
|
||||
"data": "0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1"
|
||||
}
|
||||
89
public/static/cocos-build/web-mobile/assets/main/index.js
Normal file
@@ -0,0 +1,89 @@
|
||||
window.__require = function e(t, n, r) {
|
||||
function s(o, u) {
|
||||
if (!n[o]) {
|
||||
if (!t[o]) {
|
||||
var b = o.split("/");
|
||||
b = b[b.length - 1];
|
||||
if (!t[b]) {
|
||||
var a = "function" == typeof __require && __require;
|
||||
if (!u && a) return a(b, !0);
|
||||
if (i) return i(b, !0);
|
||||
throw new Error("Cannot find module '" + o + "'");
|
||||
}
|
||||
o = b;
|
||||
}
|
||||
var f = n[o] = {
|
||||
exports: {}
|
||||
};
|
||||
t[o][0].call(f.exports, function(e) {
|
||||
var n = t[o][1][e];
|
||||
return s(n || e);
|
||||
}, f, f.exports, e, t, n, r);
|
||||
}
|
||||
return n[o].exports;
|
||||
}
|
||||
var i = "function" == typeof __require && __require;
|
||||
for (var o = 0; o < r.length; o++) s(r[o]);
|
||||
return s;
|
||||
}({
|
||||
HelloWorld: [ function(require, module, exports) {
|
||||
"use strict";
|
||||
cc._RF.push(module, "fdc7afxuBxOA7RfBuV+NSmm", "HelloWorld");
|
||||
"use strict";
|
||||
var __extends = this && this.__extends || function() {
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(d, b) {
|
||||
d.__proto__ = b;
|
||||
} || function(d, b) {
|
||||
for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
|
||||
};
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function(d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() {
|
||||
this.constructor = d;
|
||||
}
|
||||
d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
}();
|
||||
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
|
||||
var HelloWorld = function(_super) {
|
||||
__extends(HelloWorld, _super);
|
||||
function HelloWorld() {
|
||||
var _this = null !== _super && _super.apply(this, arguments) || this;
|
||||
_this.Label = null;
|
||||
_this.Text = "hello";
|
||||
_this.Btn = null;
|
||||
return _this;
|
||||
}
|
||||
HelloWorld.prototype.onLoad = function() {
|
||||
var self = this;
|
||||
this.Label.string = this.Text;
|
||||
window["eventBus"].on("SendContent", function(content) {
|
||||
self.Label.string = content;
|
||||
});
|
||||
};
|
||||
HelloWorld.prototype.onClickBtn = function() {
|
||||
window["eventBus"].emit("Alert", "hello");
|
||||
};
|
||||
__decorate([ property(cc.Label) ], HelloWorld.prototype, "Label", void 0);
|
||||
__decorate([ property ], HelloWorld.prototype, "Text", void 0);
|
||||
__decorate([ property(cc.Button) ], HelloWorld.prototype, "Btn", void 0);
|
||||
HelloWorld = __decorate([ ccclass ], HelloWorld);
|
||||
return HelloWorld;
|
||||
}(cc.Component);
|
||||
exports.default = HelloWorld;
|
||||
cc._RF.pop();
|
||||
}, {} ]
|
||||
}, {}, [ "HelloWorld" ]);
|
||||
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 82 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
103781
public/static/cocos-build/web-mobile/cocos2d-js.js
Normal file
BIN
public/static/cocos-build/web-mobile/favicon.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
90
public/static/cocos-build/web-mobile/index.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Cocos Creator | hello_world</title>
|
||||
|
||||
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
||||
<meta name="viewport"
|
||||
content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1"/>
|
||||
|
||||
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
|
||||
<!-- force webkit on 360 -->
|
||||
<meta name="renderer" content="webkit"/>
|
||||
<meta name="force-rendering" content="webkit"/>
|
||||
<!-- force edge on IE -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<meta name="msapplication-tap-highlight" content="no">
|
||||
|
||||
<!-- force full screen on some browser -->
|
||||
<meta name="full-screen" content="yes"/>
|
||||
<meta name="x5-fullscreen" content="true"/>
|
||||
<meta name="360-fullscreen" content="true"/>
|
||||
|
||||
<!-- force screen orientation on some browser -->
|
||||
<meta name="screen-orientation" content=""/>
|
||||
<meta name="x5-orientation" content="">
|
||||
|
||||
<!--fix fireball/issues/3568 -->
|
||||
<!--<meta name="browsermode" content="application">-->
|
||||
<meta name="x5-page-mode" content="app">
|
||||
|
||||
<!--<link rel="apple-touch-icon" href=".png" />-->
|
||||
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="style-mobile.css"/>
|
||||
<link rel="icon" href="favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
||||
<div id="splash">
|
||||
<div class="progress-bar stripes">
|
||||
<span style="width: 0%"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="src/settings.js" charset="utf-8"></script>
|
||||
|
||||
<script src="main.js" charset="utf-8"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
// open web debugger console
|
||||
if (typeof VConsole !== 'undefined') {
|
||||
window.vConsole = new VConsole();
|
||||
}
|
||||
|
||||
var debug = window._CCSettings.debug;
|
||||
var splash = document.getElementById('splash');
|
||||
splash.style.display = 'block';
|
||||
|
||||
function loadScript (moduleName, cb) {
|
||||
function scriptLoaded () {
|
||||
document.body.removeChild(domScript);
|
||||
domScript.removeEventListener('load', scriptLoaded, false);
|
||||
cb && cb();
|
||||
};
|
||||
var domScript = document.createElement('script');
|
||||
domScript.async = true;
|
||||
domScript.src = moduleName;
|
||||
domScript.addEventListener('load', scriptLoaded, false);
|
||||
document.body.appendChild(domScript);
|
||||
}
|
||||
|
||||
loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.js', function () {
|
||||
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
||||
loadScript(debug ? 'physics.js' : 'physics-min.js', window.boot);
|
||||
}
|
||||
else {
|
||||
window.boot();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
144
public/static/cocos-build/web-mobile/main.js
Normal file
@@ -0,0 +1,144 @@
|
||||
window.boot = function () {
|
||||
var settings = window._CCSettings;
|
||||
window._CCSettings = undefined;
|
||||
var onProgress = null;
|
||||
|
||||
var RESOURCES = cc.AssetManager.BuiltinBundleName.RESOURCES;
|
||||
var INTERNAL = cc.AssetManager.BuiltinBundleName.INTERNAL;
|
||||
var MAIN = cc.AssetManager.BuiltinBundleName.MAIN;
|
||||
function setLoadingDisplay () {
|
||||
// Loading splash scene
|
||||
var splash = document.getElementById('splash');
|
||||
var progressBar = splash.querySelector('.progress-bar span');
|
||||
onProgress = function (finish, total) {
|
||||
var percent = 100 * finish / total;
|
||||
if (progressBar) {
|
||||
progressBar.style.width = percent.toFixed(2) + '%';
|
||||
}
|
||||
};
|
||||
splash.style.display = 'block';
|
||||
progressBar.style.width = '0%';
|
||||
|
||||
cc.director.once(cc.Director.EVENT_AFTER_SCENE_LAUNCH, function () {
|
||||
splash.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
var onStart = function () {
|
||||
|
||||
cc.view.enableRetina(true);
|
||||
cc.view.resizeWithBrowserSize(true);
|
||||
|
||||
if (cc.sys.isBrowser) {
|
||||
setLoadingDisplay();
|
||||
}
|
||||
|
||||
if (cc.sys.isMobile) {
|
||||
if (settings.orientation === 'landscape') {
|
||||
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
else if (settings.orientation === 'portrait') {
|
||||
cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
|
||||
}
|
||||
cc.view.enableAutoFullScreen([
|
||||
cc.sys.BROWSER_TYPE_BAIDU,
|
||||
cc.sys.BROWSER_TYPE_BAIDU_APP,
|
||||
cc.sys.BROWSER_TYPE_WECHAT,
|
||||
cc.sys.BROWSER_TYPE_MOBILE_QQ,
|
||||
cc.sys.BROWSER_TYPE_MIUI,
|
||||
cc.sys.BROWSER_TYPE_HUAWEI,
|
||||
cc.sys.BROWSER_TYPE_UC,
|
||||
].indexOf(cc.sys.browserType) < 0);
|
||||
}
|
||||
|
||||
// Limit downloading max concurrent task to 2,
|
||||
// more tasks simultaneously may cause performance draw back on some android system / browsers.
|
||||
// You can adjust the number based on your own test result, you have to set it before any loading process to take effect.
|
||||
if (cc.sys.isBrowser && cc.sys.os === cc.sys.OS_ANDROID) {
|
||||
cc.assetManager.downloader.maxConcurrency = 2;
|
||||
cc.assetManager.downloader.maxRequestsPerFrame = 2;
|
||||
}
|
||||
|
||||
var launchScene = settings.launchScene;
|
||||
var bundle = cc.assetManager.bundles.find(function (b) {
|
||||
return b.getSceneInfo(launchScene);
|
||||
});
|
||||
|
||||
bundle.loadScene(launchScene, null, onProgress,
|
||||
function (err, scene) {
|
||||
if (!err) {
|
||||
cc.director.runSceneImmediate(scene);
|
||||
if (cc.sys.isBrowser) {
|
||||
// show canvas
|
||||
var canvas = document.getElementById('GameCanvas');
|
||||
canvas.style.visibility = '';
|
||||
var div = document.getElementById('GameDiv');
|
||||
if (div) {
|
||||
div.style.backgroundImage = '';
|
||||
}
|
||||
console.log('Success to load scene: ' + launchScene);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
var option = {
|
||||
id: 'GameCanvas',
|
||||
debugMode: settings.debug ? cc.debug.DebugMode.INFO : cc.debug.DebugMode.ERROR,
|
||||
showFPS: settings.debug,
|
||||
frameRate: 60,
|
||||
groupList: settings.groupList,
|
||||
collisionMatrix: settings.collisionMatrix,
|
||||
};
|
||||
|
||||
cc.assetManager.init({
|
||||
bundleVers: settings.bundleVers,
|
||||
remoteBundles: settings.remoteBundles,
|
||||
server: settings.server
|
||||
});
|
||||
|
||||
var bundleRoot = [INTERNAL];
|
||||
settings.hasResourcesBundle && bundleRoot.push(RESOURCES);
|
||||
|
||||
var count = 0;
|
||||
function cb (err) {
|
||||
if (err) return console.error(err.message, err.stack);
|
||||
count++;
|
||||
if (count === bundleRoot.length + 1) {
|
||||
cc.assetManager.loadBundle(MAIN, function (err) {
|
||||
if (!err) cc.game.run(option, onStart);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cc.assetManager.loadScript(settings.jsList.map(function (x) { return 'src/' + x;}), cb);
|
||||
|
||||
for (var i = 0; i < bundleRoot.length; i++) {
|
||||
cc.assetManager.loadBundle(bundleRoot[i], cb);
|
||||
}
|
||||
};
|
||||
|
||||
if (window.jsb) {
|
||||
var isRuntime = (typeof loadRuntime === 'function');
|
||||
if (isRuntime) {
|
||||
require('src/settings.js');
|
||||
require('src/cocos2d-runtime.js');
|
||||
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
||||
require('src/physics.js');
|
||||
}
|
||||
require('jsb-adapter/engine/index.js');
|
||||
}
|
||||
else {
|
||||
require('src/settings.js');
|
||||
require('src/cocos2d-jsb.js');
|
||||
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
||||
require('src/physics.js');
|
||||
}
|
||||
require('jsb-adapter/jsb-engine.js');
|
||||
}
|
||||
|
||||
cc.macro.CLEANUP_IMAGE_CACHE = true;
|
||||
window.boot();
|
||||
}
|
||||
9886
public/static/cocos-build/web-mobile/physics.js
Normal file
BIN
public/static/cocos-build/web-mobile/splash.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
19
public/static/cocos-build/web-mobile/src/settings.js
Normal file
@@ -0,0 +1,19 @@
|
||||
window._CCSettings = {
|
||||
platform: "web-mobile",
|
||||
groupList: [
|
||||
"default"
|
||||
],
|
||||
collisionMatrix: [
|
||||
[
|
||||
true
|
||||
]
|
||||
],
|
||||
hasResourcesBundle: false,
|
||||
hasStartSceneBundle: false,
|
||||
remoteBundles: [],
|
||||
subpackages: [],
|
||||
launchScene: "db://assets/Scene/helloworld.fire",
|
||||
orientation: "",
|
||||
debug: true,
|
||||
jsList: []
|
||||
};
|
||||
116
public/static/cocos-build/web-mobile/style-desktop.css
Normal file
@@ -0,0 +1,116 @@
|
||||
body {
|
||||
cursor: default;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
font-family: Helvetica, Verdana, Arial, sans-serif;
|
||||
}
|
||||
|
||||
body, canvas, div {
|
||||
outline: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Remove spin of input type number */
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
/* display: none; <- Crashes Chrome on hover */
|
||||
-webkit-appearance: none;
|
||||
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
|
||||
}
|
||||
|
||||
#Cocos2dGameContainer {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
canvas {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
a:active, a:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
p.header {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
p.footer {
|
||||
font-size: x-small;
|
||||
}
|
||||
|
||||
#splash {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
background: #171717 url(./splash.png) no-repeat center;
|
||||
background-size: 350px;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
background-color: #1a1a1a;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 80%;
|
||||
height: 5px;
|
||||
width: 300px;
|
||||
margin: 0 -150px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
|
||||
}
|
||||
|
||||
.progress-bar span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
|
||||
transition: width .4s ease-in-out;
|
||||
background-color: #3dc5de;
|
||||
}
|
||||
|
||||
.stripes span {
|
||||
background-size: 30px 30px;
|
||||
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
|
||||
animation: animate-stripes 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes animate-stripes {
|
||||
0% {background-position: 0 0;} 100% {background-position: 60px 0;}
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
text-shadow: 3px 3px 15px;
|
||||
}
|
||||
|
||||
#GameDiv {
|
||||
width: 800px;
|
||||
height: 450px;
|
||||
margin: 0 auto;
|
||||
background: black;
|
||||
position: relative;
|
||||
border: 3px solid black;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 5px 40px #333
|
||||
}
|
||||
124
public/static/cocos-build/web-mobile/style-mobile.css
Normal file
@@ -0,0 +1,124 @@
|
||||
html {
|
||||
-ms-touch-action: none;
|
||||
}
|
||||
|
||||
body, canvas, div {
|
||||
display: block;
|
||||
outline: none;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Remove spin of input type number */
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
/* display: none; <- Crashes Chrome on hover */
|
||||
-webkit-appearance: none;
|
||||
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
|
||||
cursor: default;
|
||||
color: #888;
|
||||
background-color: #333;
|
||||
|
||||
text-align: center;
|
||||
font-family: Helvetica, Verdana, Arial, sans-serif;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
/* fix bug: https://github.com/cocos-creator/2d-tasks/issues/791 */
|
||||
/* overflow cannot be applied in Cocos2dGameContainer,
|
||||
otherwise child elements will be hidden when Cocos2dGameContainer rotated 90 deg */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#Cocos2dGameContainer {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-align: center;
|
||||
-webkit-box-pack: center;
|
||||
}
|
||||
|
||||
canvas {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
a:active, a:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
p.header {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
p.footer {
|
||||
font-size: x-small;
|
||||
}
|
||||
|
||||
#splash {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #171717 url(./splash.png) no-repeat center;
|
||||
background-size: 45%;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
position: absolute;
|
||||
left: 27.5%;
|
||||
top: 80%;
|
||||
height: 3px;
|
||||
padding: 2px;
|
||||
width: 45%;
|
||||
border-radius: 7px;
|
||||
box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
|
||||
}
|
||||
|
||||
.progress-bar span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: 3px;
|
||||
transition: width .4s ease-in-out;
|
||||
background-color: #3dc5de;
|
||||
}
|
||||
|
||||
.stripes span {
|
||||
background-size: 30px 30px;
|
||||
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
|
||||
animation: animate-stripes 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes animate-stripes {
|
||||
0% {background-position: 0 0;} 100% {background-position: 60px 0;}
|
||||
}
|
||||
64
public/static/cocos-loader/creator-load.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/* eslint-disable no-undef */
|
||||
const GAME_INIT = (cbFN) => {
|
||||
var settings = window._CCSettings;
|
||||
// window._CCSettings = undefined;
|
||||
var onProgress = null;
|
||||
|
||||
var RESOURCES = cc.AssetManager.BuiltinBundleName.RESOURCES;
|
||||
var INTERNAL = cc.AssetManager.BuiltinBundleName.INTERNAL;
|
||||
var MAIN = cc.AssetManager.BuiltinBundleName.MAIN;
|
||||
|
||||
var jsList = settings.jsList
|
||||
|
||||
if (jsList) {
|
||||
jsList = jsList.map(function (x) {
|
||||
return './static/cocos-build/web-mobile/src/' + x
|
||||
})
|
||||
}
|
||||
|
||||
var option = {
|
||||
id: 'GameCanvas',
|
||||
debugMode: settings.debug ? cc.debug.DebugMode.INFO : cc.debug.DebugMode.ERROR,
|
||||
showFPS: settings.debug,
|
||||
frameRate: 60,
|
||||
groupList: settings.groupList,
|
||||
collisionMatrix: settings.collisionMatrix,
|
||||
}
|
||||
|
||||
// init assets
|
||||
cc.AssetLibrary.init({
|
||||
bundleVers: settings.bundleVers,
|
||||
remoteBundles: settings.remoteBundles,
|
||||
server: settings.server
|
||||
})
|
||||
|
||||
var bundleRoot = [INTERNAL];
|
||||
settings.hasResourcesBundle && bundleRoot.push(RESOURCES);
|
||||
|
||||
var count = 0;
|
||||
function cb(err) {
|
||||
if (err) return console.error(err.message, err.stack);
|
||||
count++;
|
||||
if (count === bundleRoot.length + 1) {
|
||||
cc.assetManager.loadBundle(MAIN, function (err) {
|
||||
// if (!err) cc.game.run(option, onStart);
|
||||
if (!err)
|
||||
cc.game.run(option, () => {
|
||||
cbFN && cbFN()
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cc.assetManager.loadScript(settings.jsList.map(function (x) { return 'src/' + x; }), cb);
|
||||
|
||||
for (var i = 0; i < bundleRoot.length; i++) {
|
||||
cc.assetManager.loadBundle(bundleRoot[i], cb);
|
||||
}
|
||||
|
||||
// cc.game.run(option, () => {
|
||||
// cb && cb()
|
||||
// })
|
||||
}
|
||||
|
||||
export default GAME_INIT
|
||||
7
public/static/css/element-variables.scss
Normal file
@@ -0,0 +1,7 @@
|
||||
/* 改变主题色变量 */
|
||||
|
||||
$--color-primary: #f3d031;
|
||||
/* 改变 icon 字体路径变量,必需 */
|
||||
|
||||
$--font-path: '~element-ui/lib/theme-chalk/fonts';
|
||||
@import "~element-ui/packages/theme-chalk/src/index";
|
||||
1418
public/static/css/reset.css
Normal file
BIN
public/static/img/cover/helloworld1.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
public/static/img/cover/helloworld2.jpg
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
public/static/img/head.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/static/img/loading-yy.gif
Normal file
|
After Width: | Height: | Size: 460 KiB |
BIN
public/static/img/nodata.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
public/static/img/wordBg.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
179
public/static/js/EventBus.js
Normal file
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* 实现发布-订阅模式下的消息传输机制,支持命名空间与离线事件
|
||||
* @param {string} [key] 事件的名称
|
||||
* @param {function} [fn] 事件的回调
|
||||
* @param {string} [last] 是否只执行最后一次绑定的消息 last ==“last”时只执行最后一次绑定的消息,否则执行之前所有绑定的消息
|
||||
*
|
||||
* @example
|
||||
* 1.常规
|
||||
* eventBus.on('click',function(a){
|
||||
* console.log(a) // 输出 :1
|
||||
* })
|
||||
* eventBus.emit('click',1)
|
||||
*
|
||||
* 2. 先发布后订阅
|
||||
* eventBus.emit('click',1)
|
||||
* eventBus.on('click',function(a){
|
||||
* console.log(a) // 输出 :1
|
||||
* })
|
||||
*
|
||||
* 3.使用命名空间
|
||||
* eventBus.create('namespace1').on('click',function(a){
|
||||
* console.log(a) // 输出 :1
|
||||
* })
|
||||
* eventBus.create('namespace1').emit('click',1)
|
||||
*
|
||||
* auth by guoqiang
|
||||
* 注意:支持离线事件可能会带来一些副作用,比如意外的某个页面发布了某个消息,这时如果另一个订阅了这个消息,这个消息的回调会立即执行,而且大多请况下,回调的参数会出问题。在逻辑没理清之前不建议先发布再订阅
|
||||
* 注意:支持离线事件可能会带来一些副作用,比如意外的某个页面发布了某个消息,这时如果另一个订阅了这个消息,这个消息的回调会立即执行,而且大多请况下,回调的参数会出问题。在逻辑没理清之前不建议先发布再订阅
|
||||
* 注意:支持离线事件可能会带来一些副作用,比如意外的某个页面发布了某个消息,这时如果另一个订阅了这个消息,这个消息的回调会立即执行,而且大多请况下,回调的参数会出问题。在逻辑没理清之前不建议先发布再订阅
|
||||
*/
|
||||
(function(window, undefined) {
|
||||
var _subscribe = null,
|
||||
_publish = null,
|
||||
_unsubscribe = null,
|
||||
_shift = Array.prototype.shift, // 删除数组的第一个 元素,并返回这个元素
|
||||
_unshift = Array.prototype.unshift, // 在数组的开头添加一个或者多个元素,并返回数组新的length值
|
||||
namespaceCache = {},
|
||||
_create = null,
|
||||
each = function(ary, fn) {
|
||||
var ret = null;
|
||||
for (var i = 0, len = ary.length; i < len; i++) {
|
||||
var n = ary[i];
|
||||
ret = fn.call(n, i, n);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
// 订阅消息名称为:'+key+'
|
||||
_subscribe = function(key, fn, cache) {
|
||||
if (!cache[key]) {
|
||||
cache[key] = [];
|
||||
}
|
||||
cache[key].push(fn);
|
||||
};
|
||||
|
||||
// 取消订阅(取消全部或者指定消息)
|
||||
_unsubscribe = function(key, cache, fn) {
|
||||
if (cache[key]) {
|
||||
if (fn) {
|
||||
for (var i = cache[key].length; i >= 0; i--) {
|
||||
if (cache[key][i] === fn) {
|
||||
cache[key].splice(i, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cache[key] = [];
|
||||
}
|
||||
} else if (!key) {
|
||||
for (var key in cache) {
|
||||
delete cache[key];
|
||||
}
|
||||
} else {
|
||||
console.log("不存在该消息的监听:" + key);
|
||||
}
|
||||
};
|
||||
|
||||
// 发布消息
|
||||
_publish = function() {
|
||||
var cache = _shift.call(arguments),
|
||||
key = _shift.call(arguments),
|
||||
args = arguments,
|
||||
_self = this,
|
||||
ret = null,
|
||||
stack = cache[key];
|
||||
|
||||
if (!stack || !stack.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
return each(stack, function() {
|
||||
return this.apply(_self, args);
|
||||
});
|
||||
};
|
||||
|
||||
// 创建命名空间
|
||||
_create = function(namespace) {
|
||||
var namespace = namespace || "default";
|
||||
var cache = {},
|
||||
offlineStack = {}, // 离线事件,用于先发布后订阅,只执行一次
|
||||
ret = {
|
||||
on: function(key, fn, last) {
|
||||
_subscribe(key, fn, cache);
|
||||
if (!offlineStack[key]) {
|
||||
offlineStack[key] = null;
|
||||
return;
|
||||
}
|
||||
if (last === "last") {
|
||||
// 指定执行离线队列的最后一个函数,执行完成之后删除
|
||||
offlineStack[key].length && offlineStack[key].pop()(); // [].pop => 删除一个数组中的最后的一个元素,并且返回这个元素
|
||||
} else {
|
||||
each(offlineStack[key], function() {
|
||||
this();
|
||||
});
|
||||
}
|
||||
offlineStack[key] = null;
|
||||
},
|
||||
one: function(key, fn, last) {
|
||||
_unsubscribe(key, cache);
|
||||
this.on(key, fn, last);
|
||||
},
|
||||
off: function(key, fn) {
|
||||
_unsubscribe(key, cache, fn);
|
||||
},
|
||||
emit: function() {
|
||||
var fn = null,
|
||||
args = null,
|
||||
key = _shift.call(arguments),
|
||||
_self = this;
|
||||
|
||||
_unshift.call(arguments, cache, key);
|
||||
args = arguments;
|
||||
fn = function() {
|
||||
return _publish.apply(_self, args);
|
||||
};
|
||||
|
||||
if (offlineStack && offlineStack[key] === undefined) {
|
||||
offlineStack[key] = [];
|
||||
return offlineStack[key].push(fn);
|
||||
}
|
||||
return fn();
|
||||
}
|
||||
};
|
||||
|
||||
return namespace
|
||||
? namespaceCache[namespace]
|
||||
? namespaceCache[namespace]
|
||||
: (namespaceCache[namespace] = ret)
|
||||
: ret;
|
||||
};
|
||||
|
||||
window.eventBus = {
|
||||
create: _create, // 创建命名空间
|
||||
one: function(key, fn, last) {
|
||||
// 订阅消息,只能单一对象订阅
|
||||
var namespace = "default";
|
||||
var pubsub = this.create(namespace);
|
||||
pubsub.one(key, fn, last);
|
||||
},
|
||||
on: function(key, fn, last) {
|
||||
// 订阅消息,可多对象同时订阅
|
||||
var namespace = "default";
|
||||
var pubsub = this.create(namespace);
|
||||
pubsub.on(key, fn, last);
|
||||
},
|
||||
off: function(key, fn, namespace) {
|
||||
// 取消订阅,(取消全部或指定消息)
|
||||
namespace = "default";
|
||||
var pubsub = this.create(namespace);
|
||||
console.trace("");
|
||||
pubsub.off(key, fn);
|
||||
},
|
||||
emit: function(key, fn) {
|
||||
// 发布消息
|
||||
var namespace = "default";
|
||||
var pubsub = this.create(namespace);
|
||||
pubsub.emit.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
})(window, undefined);
|
||||
141
public/static/js/common.js
Normal file
@@ -0,0 +1,141 @@
|
||||
// import { rootPath } from '../../src/api/apiConfig'
|
||||
import axios from 'axios'
|
||||
import { Message, Notification } from 'element-ui'
|
||||
/**
|
||||
* post请求
|
||||
* @DateTime 2018-4-10
|
||||
* @param {[string]} url [地址]
|
||||
* @param {[object]} data [数据]
|
||||
* @param {{object}} options 这个参数供扩展使用,暂时没有加
|
||||
*/
|
||||
export const post = (url, data, options = { }) => {
|
||||
if (!url) {
|
||||
console.log(new Error('地址是必须的'))
|
||||
return false
|
||||
}
|
||||
return axios(Object.assign({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: data
|
||||
}, options)).then(res => {
|
||||
return Promise.resolve(res)
|
||||
}, res => {
|
||||
return Promise.reject(res)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* get请求
|
||||
* @DateTime 2018-4-10
|
||||
* @param {[string]} url [地址]
|
||||
* @param {[object]} data [数据]
|
||||
*/
|
||||
export const get = (url, data) => {
|
||||
if (!url) {
|
||||
console.log(new Error('地址是必须的'))
|
||||
return false
|
||||
}
|
||||
// const baseUrl = rootPath + url
|
||||
return axios({
|
||||
method: 'GET',
|
||||
url: url,
|
||||
data: data
|
||||
}).then(res => {
|
||||
return Promise.resolve(res)
|
||||
}, res => {
|
||||
return Promise.reject(res)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 中部的alert
|
||||
* @DateTime 2018-4-10
|
||||
* @param {[string]} msg [要提示的信息]
|
||||
*/
|
||||
export const msgbox = {
|
||||
success (msg) {
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'success'
|
||||
})
|
||||
},
|
||||
warning (msg) {
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'warning'
|
||||
})
|
||||
},
|
||||
error (msg) {
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 右上角提示框
|
||||
* @DateTime 2018-4-10
|
||||
* @param {[string]} msg [要提示的信息]
|
||||
*/
|
||||
export const notice = {
|
||||
success (msg) {
|
||||
Notification({
|
||||
title: '成功',
|
||||
message: msg,
|
||||
type: 'success'
|
||||
})
|
||||
},
|
||||
warning (msg) {
|
||||
Notification({
|
||||
title: '警告',
|
||||
message: msg,
|
||||
type: 'warning'
|
||||
})
|
||||
},
|
||||
error (msg) {
|
||||
Notification({
|
||||
title: '错误',
|
||||
message: msg,
|
||||
type: 'error'
|
||||
// duration: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳转为格式化时间
|
||||
* @DateTime 2018-4-10
|
||||
* @param {[date]} timestamp [时间戳]
|
||||
* @param {[string]} formats [时间格式]
|
||||
*/
|
||||
export const formatDate = (timestamp, formats) => {
|
||||
/*
|
||||
formats格式包括
|
||||
1. Y-M-D
|
||||
2. Y-M-D h:m:s
|
||||
3. Y年M月D日
|
||||
4. Y年M月D日 h时m分
|
||||
5. Y年M月D日 h时m分s秒
|
||||
示例:console.log(formatDate(1500305226034, 'Y年M月D日 h:m:s')) ==> 2017年07月17日 23:27:06
|
||||
*/
|
||||
formats = formats || 'Y-M-D'
|
||||
var myDate = timestamp ? new Date(timestamp) : new Date()
|
||||
var year = myDate.getFullYear()
|
||||
var month = formatDigit(myDate.getMonth() + 1)
|
||||
var day = formatDigit(myDate.getDate())
|
||||
var hour = formatDigit(myDate.getHours())
|
||||
var minute = formatDigit(myDate.getMinutes())
|
||||
var second = formatDigit(myDate.getSeconds())
|
||||
return formats.replace(/Y|M|D|h|m|s/g, function (matches) {
|
||||
return ({
|
||||
Y: year,
|
||||
M: month,
|
||||
D: day,
|
||||
h: hour,
|
||||
m: minute,
|
||||
s: second
|
||||
})[matches]
|
||||
})
|
||||
// 小于10补0
|
||||
function formatDigit (n) {
|
||||
return n.toString().replace(/^(\d)$/, '0$1')
|
||||
}
|
||||
}
|
||||