@youngbeen/angle-ctrl
Advanced tools
| export interface LogParams { | ||
| isSave?: boolean; | ||
| line?: string | number; | ||
| compName?: string; | ||
| funcName?: string; | ||
| attach?: any; | ||
| [propName: string]: any; | ||
| } | ||
| declare type DebugType = 0 | 1 | 2; | ||
| declare const _default: { | ||
| log(info?: string, params?: LogParams): void; | ||
| warn(info: any, params: any): void; | ||
| error(info: any, params: any): void; | ||
| debugOn(mode?: DebugType): void; | ||
| debugOff(): void; | ||
| cheatDebugClick(count: any, interval?: number, mode?: DebugType): void; | ||
| }; | ||
| export default _default; |
+228
| // this controller is about to provide functions for debugging controll | ||
| import logCtrl from './LogCtrl' | ||
| let debug: DebugType = 0 // debug模式 | ||
| let cheatCounts: number = 0 // cheat debug点击的累计次数 | ||
| let tcCheatDebug: any = null // cheat debug time ctrl | ||
| // 定义shape | ||
| export interface LogParams { | ||
| isSave?: boolean // 是否记录到log中 | ||
| line?: string | number // 行数 | ||
| compName?: string // 所在组件名 | ||
| funcName?: string // 所在函数名 | ||
| attach?: any // 附加信息 | ||
| [propName: string]: any | ||
| } | ||
| // 定义type | ||
| type DebugType = 0 | 1 | 2 // 0 - 关闭debug,1 - 初级debug(仅alert警告和错误), 2 - 严格debug(alert所有信息) | ||
| export default { | ||
| // system log -- 信息,[ 是否记录到log中,所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: log方法默认不会记录到日志中 | ||
| log (info: string = '', params?: LogParams): void { | ||
| let isSave: boolean = false | ||
| let line: string | number = '' | ||
| let compName: string = '' | ||
| let funcName: string = '' | ||
| let attach: any = '' | ||
| let msg: string = info | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = true | ||
| } | ||
| if (params.line) { | ||
| line = params.line.toString() | ||
| msg += `[line:${line}]` | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName | ||
| msg += `[comp:${compName}]` | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName | ||
| msg += `[func:${funcName}]` | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach | ||
| } | ||
| } | ||
| console.log(msg) | ||
| if (isSave) { | ||
| logCtrl.saveLog(info, 'info', line, compName, funcName, attach) | ||
| } | ||
| if (debug > 1) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg) | ||
| } | ||
| }, | ||
| // system warn -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: warn方法只自动记录日志,不主动发送到后台 | ||
| warn (info, params) { | ||
| let line = '' | ||
| let compName = '' | ||
| let funcName = '' | ||
| let attach = '' | ||
| let msg = info | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line | ||
| msg += `[line:${line}]` | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName | ||
| msg += `[comp:${compName}]` | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName | ||
| msg += `[func:${funcName}]` | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach | ||
| } | ||
| } | ||
| console.warn(msg) | ||
| logCtrl.saveLog(info, 'warn', line, compName, funcName, attach) | ||
| if (debug) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg) | ||
| } | ||
| }, | ||
| // system error -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: error方法会自动记录,并自动发送到后台 | ||
| error (info, params) { | ||
| let line = '' | ||
| let compName = '' | ||
| let funcName = '' | ||
| let attach = '' | ||
| let msg = info | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line | ||
| msg += `[line:${line}]` | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName | ||
| msg += `[comp:${compName}]` | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName | ||
| msg += `[func:${funcName}]` | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach | ||
| } | ||
| } | ||
| console.warn(msg) | ||
| logCtrl.saveLog(info, 'error', line, compName, funcName, attach) | ||
| // 发生错误,立即发送信息到日志系统 | ||
| logCtrl.sendLog() | ||
| if (debug) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg) | ||
| } | ||
| }, | ||
| // // freeze background scroll | ||
| // freezeBgScroll() { | ||
| // System.isFreezeBgScroll = true | ||
| // // to be robust, we should add no-scroll in html and body tag as well | ||
| // $('html').addClass('no-scroll') | ||
| // $('body').addClass('no-scroll') | ||
| // }, | ||
| // // resume background scroll | ||
| // resumeBgScroll() { | ||
| // System.isFreezeBgScroll = false | ||
| // $('html').removeClass('no-scroll') | ||
| // $('body').removeClass('no-scroll') | ||
| // }, | ||
| // open debug mode -- [mode = 1 | 2] | ||
| debugOn (mode: DebugType = 1) { | ||
| debug = mode | ||
| window.localStorage.debug = debug | ||
| window.alert(`debug模式调整为${mode === 2 ? '严格模式' : '开启'}`) | ||
| }, | ||
| debugOff () { | ||
| debug = 0 | ||
| window.localStorage.debug = debug | ||
| window.alert(`debug模式调整为关闭`) | ||
| }, | ||
| // open debugging mode cheat -- trigger click counts, [interval], [mode] | ||
| cheatDebugClick (count, interval = 1000, mode: DebugType = 1) { | ||
| cheatCounts++ | ||
| if (cheatCounts >= count) { | ||
| // 切换 cheat debug | ||
| if (debug) { | ||
| debug = 0 | ||
| } else { | ||
| debug = mode | ||
| } | ||
| window.localStorage.debug = debug | ||
| window.alert('debug模式调整为开启') | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug) | ||
| } | ||
| cheatCounts = 0 | ||
| } else { | ||
| // if (System.cheatCounts >= 2) window.alert(111) | ||
| // 还未达到cheat debug条件 | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug) | ||
| } | ||
| tcCheatDebug = setTimeout(() => { | ||
| // 规定时间内没有重复操作,清除所有参数 | ||
| cheatCounts = 0 | ||
| clearTimeout(tcCheatDebug) | ||
| }, interval) | ||
| } | ||
| } | ||
| // // open debugging mode cheat by maze clicking -- click index | ||
| // cheatMazeDebug(index) { | ||
| // // 设定maze cheat需要判定的个数 | ||
| // console.log('进入maze check') | ||
| // const mazeCount = 3 | ||
| // System.cheatMazeMap.push(index) | ||
| // let flag = true | ||
| // for (let i = 0; i < System.cheatMazeMap.length; i++) { | ||
| // if (System.cheatMazeMap[i] !== (i + 1)) { | ||
| // flag = false | ||
| // break | ||
| // } | ||
| // } | ||
| // if (!flag) { | ||
| // // 存在非法的maze code | ||
| // console.log('非法 maze code') | ||
| // System.cheatMazeMap = [] | ||
| // } else { | ||
| // // 全部是合法的code | ||
| // if (System.cheatMazeMap.length === mazeCount) { | ||
| // // 输入的maze code已经达到标准 | ||
| // System.cheatMazeMap = [] | ||
| // System.debug = !System.debug | ||
| // localStorage.debug = System.debug | ||
| // window.alert('debug模式调整为' + System.debug) | ||
| // } else { | ||
| // // 输入的maze code还不到标准 | ||
| // // do nothing | ||
| // console.log('maze code 正确,继续加油') | ||
| // } | ||
| // } | ||
| // } | ||
| } |
| export declare const timeCtrl: { | ||
| countDown({ total, step, tick, end }: { | ||
| total: number; | ||
| step: number; | ||
| tick: import("./TimeCtrl").Callback; | ||
| end: import("./TimeCtrl").Callback; | ||
| }): void; | ||
| countUp({ start, total, step, tick, end }: { | ||
| start: number; | ||
| total: number; | ||
| step: number; | ||
| tick: import("./TimeCtrl").Callback; | ||
| end: import("./TimeCtrl").Callback; | ||
| }): void; | ||
| }; | ||
| export declare const logCtrl: { | ||
| saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void; | ||
| sendLog(): void; | ||
| }; | ||
| export declare const debugCtrl: { | ||
| log(info?: string, params?: import("./DebugCtrl").LogParams): void; | ||
| warn(info: any, params: any): void; | ||
| error(info: any, params: any): void; | ||
| debugOn(mode?: 0 | 2 | 1): void; | ||
| debugOff(): void; | ||
| cheatDebugClick(count: any, interval?: number, mode?: 0 | 2 | 1): void; | ||
| }; |
| // entry js | ||
| import TimeCtrl from './TimeCtrl' | ||
| import LogCtrl from './LogCtrl' | ||
| import DebugCtrl from './DebugCtrl' | ||
| export const timeCtrl = TimeCtrl | ||
| export const logCtrl = LogCtrl | ||
| export const debugCtrl = DebugCtrl |
| declare const _default: { | ||
| saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void; | ||
| sendLog(): void; | ||
| }; | ||
| export default _default; |
| // this controller is about to provide functions for log controll | ||
| // import { dateUtil } from '@youngbeen/angle-util' | ||
| // require('@youngbeen/ums-tracking') | ||
| let logs = [] // 日志信息 | ||
| const tagRandoms = Math.floor(Math.random() * 10e13) // 用于标识某访问的唯一标识符组成部分的随机数 | ||
| let tagTime: Date | number = new Date() | ||
| tagTime = tagTime.getTime() // 用于标识某访问的唯一标识符组成部分的时间戳 | ||
| export default { | ||
| // 保存日志到历史记录 -- 信息内容,信息类型,[ 行数,所在组件名,所在函数名,附加信息 ] | ||
| saveLog (msg, type, line = '', compName = '', funcName = '', attach = '') { | ||
| if (msg && type) { | ||
| let now: Date | number = new Date() | ||
| now = now.getTime() | ||
| // now = dateUtil.getDateTime(now) | ||
| logs = [...logs, { | ||
| msg, | ||
| type, | ||
| clientTime: now, | ||
| compName, | ||
| funcName, | ||
| line, | ||
| attach | ||
| }] | ||
| } | ||
| }, | ||
| // 发送日志到日志系统 -- | ||
| sendLog () { | ||
| if (logs.length) { | ||
| const tag = `${tagTime}-${tagRandoms}` // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用 | ||
| // 使用tracking方法发送日志 | ||
| // if (window.tracking) { | ||
| // window.tracking('UMS_FELOG_ERRORLOG', { | ||
| // tag, | ||
| // historyLogs: logs | ||
| // }, 'fe_errorlog') | ||
| // } | ||
| // 使用图片发送日志 | ||
| // let url = `https://someurl?type=UMS_FELOG&content=LOGSTART>>${encodeURIComponent(JSON.stringify(content))}<<LOGEND` | ||
| // let oImage = new Image() | ||
| // oImage.src = url | ||
| // oImage = null | ||
| } | ||
| } | ||
| } |
| interface CallbackData { | ||
| leftCount?: number; | ||
| count?: number; | ||
| [propName: string]: any; | ||
| } | ||
| export interface Callback { | ||
| (data: CallbackData): any; | ||
| } | ||
| declare const _default: { | ||
| countDown({ total, step, tick, end }: { | ||
| total: number; | ||
| step: number; | ||
| tick: Callback; | ||
| end: Callback; | ||
| }): void; | ||
| countUp({ start, total, step, tick, end }: { | ||
| start: number; | ||
| total: number; | ||
| step: number; | ||
| tick: Callback; | ||
| end: Callback; | ||
| }): void; | ||
| }; | ||
| export default _default; |
| // this controller is about to provide functions for time controll | ||
| // 定义shape | ||
| interface CallbackData { | ||
| leftCount?: number | ||
| count?: number | ||
| [propName: string]: any | ||
| } | ||
| export interface Callback { | ||
| (data: CallbackData): any | ||
| } | ||
| export default { | ||
| // auto counting down -- { [total], [step], [tick], [end] } | ||
| countDown ({ total = 60, step = 1000, tick = null, end = null }: { total: number, step: number, tick: Callback, end: Callback }): void { | ||
| total > 0 ? total : total = 60 | ||
| step > 0 ? step : step = 1000 | ||
| let tickCallback: Callback = tick || function (): void { | ||
| // console.log('tick', result.leftCount) | ||
| } | ||
| let endCallback: Callback = end || function (): void { | ||
| // console.log('end the counting') | ||
| } | ||
| let tc: any = setInterval(function (): void { | ||
| if (total > 0) { | ||
| // time still left | ||
| tickCallback({ leftCount: total }) | ||
| total-- | ||
| } else { | ||
| // counts end | ||
| endCallback({ leftCount: total }) | ||
| clearInterval(tc) | ||
| } | ||
| }, step) | ||
| }, | ||
| // auto counting up -- { [start], [total], [step], [tick], [end] } | ||
| countUp ({ start = 0, total = 60, step = 1000, tick = null, end = null }: { start: number, total: number, step: number, tick: Callback, end: Callback }): void { | ||
| if (start > total) { | ||
| // invalid start , total setting | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)') | ||
| return | ||
| } | ||
| let now: number = start | ||
| step > 0 ? step : step = 1000 | ||
| let tickCallback: Callback = tick || function (): void { | ||
| // console.log('tick', result.count) | ||
| } | ||
| let endCallback: Callback = end || function (): void { | ||
| // console.log('end the counting') | ||
| } | ||
| let tc: any = setInterval(function (): void { | ||
| if (now < total) { | ||
| // count continue | ||
| tickCallback({ count: now }) | ||
| now++ | ||
| } else { | ||
| // counts end | ||
| endCallback({ count: now }) | ||
| clearInterval(tc) | ||
| } | ||
| }, step) | ||
| } | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var LogCtrl_1 = require("./LogCtrl"); | ||
| var debug = 0; | ||
| var cheatCounts = 0; | ||
| var tcCheatDebug = null; | ||
| exports.default = { | ||
| log: function log() { | ||
| var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var params = arguments[1]; | ||
| var isSave = false; | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = true; | ||
| } | ||
| if (params.line) { | ||
| line = params.line.toString(); | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.log(msg); | ||
| if (isSave) { | ||
| LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach); | ||
| } | ||
| if (debug > 1) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| warn: function warn(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| error: function error(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach); | ||
| LogCtrl_1.default.sendLog(); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| debugOn: function debugOn() { | ||
| var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
| debug = mode; | ||
| window.localStorage.debug = debug; | ||
| window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A" + (mode === 2 ? '严格模式' : '开启')); | ||
| }, | ||
| debugOff: function debugOff() { | ||
| debug = 0; | ||
| window.localStorage.debug = debug; | ||
| window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED"); | ||
| }, | ||
| cheatDebugClick: function cheatDebugClick(count) { | ||
| var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
| var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
| cheatCounts++; | ||
| if (cheatCounts >= count) { | ||
| if (debug) { | ||
| debug = 0; | ||
| } else { | ||
| debug = mode; | ||
| } | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug模式调整为开启'); | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| cheatCounts = 0; | ||
| } else { | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| tcCheatDebug = setTimeout(function () { | ||
| cheatCounts = 0; | ||
| clearTimeout(tcCheatDebug); | ||
| }, interval); | ||
| } | ||
| } | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var TimeCtrl_1 = require("./TimeCtrl"); | ||
| var DebugCtrl_1 = require("./DebugCtrl"); | ||
| exports.timeCtrl = TimeCtrl_1.default; | ||
| exports.debugCtrl = DebugCtrl_1.default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| countDown: function countDown(_ref) { | ||
| var _ref$total = _ref.total, | ||
| total = _ref$total === undefined ? 60 : _ref$total, | ||
| _ref$step = _ref.step, | ||
| step = _ref$step === undefined ? 1000 : _ref$step, | ||
| _ref$tick = _ref.tick, | ||
| tick = _ref$tick === undefined ? null : _ref$tick, | ||
| _ref$end = _ref.end, | ||
| end = _ref$end === undefined ? null : _ref$end; | ||
| total > 0 ? total : total = 60; | ||
| step > 0 ? step : step = 1000; | ||
| var tickCallback = tick || function () {}; | ||
| var endCallback = end || function () {}; | ||
| var tc = setInterval(function () { | ||
| if (total > 0) { | ||
| tickCallback({ leftCount: total }); | ||
| total--; | ||
| } else { | ||
| endCallback({ leftCount: total }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| }, | ||
| countUp: function countUp(_ref2) { | ||
| var _ref2$start = _ref2.start, | ||
| start = _ref2$start === undefined ? 0 : _ref2$start, | ||
| _ref2$total = _ref2.total, | ||
| total = _ref2$total === undefined ? 60 : _ref2$total, | ||
| _ref2$step = _ref2.step, | ||
| step = _ref2$step === undefined ? 1000 : _ref2$step, | ||
| _ref2$tick = _ref2.tick, | ||
| tick = _ref2$tick === undefined ? null : _ref2$tick, | ||
| _ref2$end = _ref2.end, | ||
| end = _ref2$end === undefined ? null : _ref2$end; | ||
| if (start > total) { | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)'); | ||
| return; | ||
| } | ||
| var now = start; | ||
| step > 0 ? step : step = 1000; | ||
| var tickCallback = tick || function () {}; | ||
| var endCallback = end || function () {}; | ||
| var tc = setInterval(function () { | ||
| if (now < total) { | ||
| tickCallback({ count: now }); | ||
| now++; | ||
| } else { | ||
| endCallback({ count: now }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| } | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var LogCtrl_1 = require("./LogCtrl"); | ||
| var debug = 0; | ||
| var cheatCounts = 0; | ||
| var tcCheatDebug = null; | ||
| exports.default = { | ||
| log: function log() { | ||
| var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var params = arguments[1]; | ||
| var isSave = false; | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = true; | ||
| } | ||
| if (params.line) { | ||
| line = params.line.toString(); | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.log(msg); | ||
| if (isSave) { | ||
| LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach); | ||
| } | ||
| if (debug > 1) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| warn: function warn(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| error: function error(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach); | ||
| LogCtrl_1.default.sendLog(); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| debugOn: function debugOn() { | ||
| var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
| debug = mode; | ||
| window.localStorage.debug = debug; | ||
| window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A" + (mode === 2 ? '严格模式' : '开启')); | ||
| }, | ||
| debugOff: function debugOff() { | ||
| debug = 0; | ||
| window.localStorage.debug = debug; | ||
| window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED"); | ||
| }, | ||
| cheatDebugClick: function cheatDebugClick(count) { | ||
| var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
| var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
| cheatCounts++; | ||
| if (cheatCounts >= count) { | ||
| if (debug) { | ||
| debug = 0; | ||
| } else { | ||
| debug = mode; | ||
| } | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug模式调整为开启'); | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| cheatCounts = 0; | ||
| } else { | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| tcCheatDebug = setTimeout(function () { | ||
| cheatCounts = 0; | ||
| clearTimeout(tcCheatDebug); | ||
| }, interval); | ||
| } | ||
| } | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var TimeCtrl_1 = require("./TimeCtrl"); | ||
| var LogCtrl_1 = require("./LogCtrl"); | ||
| var DebugCtrl_1 = require("./DebugCtrl"); | ||
| exports.timeCtrl = TimeCtrl_1.default; | ||
| exports.logCtrl = LogCtrl_1.default; | ||
| exports.debugCtrl = DebugCtrl_1.default; |
| "use strict"; | ||
| function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var logs = []; | ||
| var tagRandoms = Math.floor(Math.random() * 10e13); | ||
| var tagTime = new Date(); | ||
| tagTime = tagTime.getTime(); | ||
| exports.default = { | ||
| saveLog: function saveLog(msg, type) { | ||
| var line = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
| var compName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; | ||
| var funcName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; | ||
| var attach = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ''; | ||
| if (msg && type) { | ||
| var now = new Date(); | ||
| now = now.getTime(); | ||
| logs = [].concat(_toConsumableArray(logs), [{ | ||
| msg: msg, | ||
| type: type, | ||
| clientTime: now, | ||
| compName: compName, | ||
| funcName: funcName, | ||
| line: line, | ||
| attach: attach | ||
| }]); | ||
| } | ||
| }, | ||
| sendLog: function sendLog() { | ||
| if (logs.length) { | ||
| var tag = tagTime + "-" + tagRandoms; | ||
| } | ||
| } | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| countDown: function countDown(_ref) { | ||
| var _ref$total = _ref.total, | ||
| total = _ref$total === undefined ? 60 : _ref$total, | ||
| _ref$step = _ref.step, | ||
| step = _ref$step === undefined ? 1000 : _ref$step, | ||
| _ref$tick = _ref.tick, | ||
| tick = _ref$tick === undefined ? null : _ref$tick, | ||
| _ref$end = _ref.end, | ||
| end = _ref$end === undefined ? null : _ref$end; | ||
| total > 0 ? total : total = 60; | ||
| step > 0 ? step : step = 1000; | ||
| var tickCallback = tick || function () {}; | ||
| var endCallback = end || function () {}; | ||
| var tc = setInterval(function () { | ||
| if (total > 0) { | ||
| tickCallback({ leftCount: total }); | ||
| total--; | ||
| } else { | ||
| endCallback({ leftCount: total }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| }, | ||
| countUp: function countUp(_ref2) { | ||
| var _ref2$start = _ref2.start, | ||
| start = _ref2$start === undefined ? 0 : _ref2$start, | ||
| _ref2$total = _ref2.total, | ||
| total = _ref2$total === undefined ? 60 : _ref2$total, | ||
| _ref2$step = _ref2.step, | ||
| step = _ref2$step === undefined ? 1000 : _ref2$step, | ||
| _ref2$tick = _ref2.tick, | ||
| tick = _ref2$tick === undefined ? null : _ref2$tick, | ||
| _ref2$end = _ref2.end, | ||
| end = _ref2$end === undefined ? null : _ref2$end; | ||
| if (start > total) { | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)'); | ||
| return; | ||
| } | ||
| var now = start; | ||
| step > 0 ? step : step = 1000; | ||
| var tickCallback = tick || function () {}; | ||
| var endCallback = end || function () {}; | ||
| var tc = setInterval(function () { | ||
| if (now < total) { | ||
| tickCallback({ count: now }); | ||
| now++; | ||
| } else { | ||
| endCallback({ count: now }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| } | ||
| }; |
| export interface LogParams { | ||
| isSave?: boolean; | ||
| line?: string | number; | ||
| compName?: string; | ||
| funcName?: string; | ||
| attach?: any; | ||
| [propName: string]: any; | ||
| } | ||
| declare type DebugType = 0 | 1 | 2; | ||
| declare const _default: { | ||
| log(info?: string, params?: LogParams): void; | ||
| warn(info: any, params: any): void; | ||
| error(info: any, params: any): void; | ||
| debugOn(mode?: DebugType): void; | ||
| debugOff(): void; | ||
| cheatDebugClick(count: any, interval?: number, mode?: DebugType): void; | ||
| }; | ||
| export default _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const LogCtrl_1 = require("./LogCtrl"); | ||
| let debug = 0; | ||
| let cheatCounts = 0; | ||
| let tcCheatDebug = null; | ||
| exports.default = { | ||
| log(info = '', params) { | ||
| let isSave = false; | ||
| let line = ''; | ||
| let compName = ''; | ||
| let funcName = ''; | ||
| let attach = ''; | ||
| let msg = info; | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = true; | ||
| } | ||
| if (params.line) { | ||
| line = params.line.toString(); | ||
| msg += `[line:${line}]`; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += `[comp:${compName}]`; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += `[func:${funcName}]`; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.log(msg); | ||
| if (isSave) { | ||
| LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach); | ||
| } | ||
| if (debug > 1) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| warn(info, params) { | ||
| let line = ''; | ||
| let compName = ''; | ||
| let funcName = ''; | ||
| let attach = ''; | ||
| let msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += `[line:${line}]`; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += `[comp:${compName}]`; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += `[func:${funcName}]`; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| error(info, params) { | ||
| let line = ''; | ||
| let compName = ''; | ||
| let funcName = ''; | ||
| let attach = ''; | ||
| let msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += `[line:${line}]`; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += `[comp:${compName}]`; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += `[func:${funcName}]`; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach); | ||
| LogCtrl_1.default.sendLog(); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| debugOn(mode = 1) { | ||
| debug = mode; | ||
| window.localStorage.debug = debug; | ||
| window.alert(`debug模式调整为${mode === 2 ? '严格模式' : '开启'}`); | ||
| }, | ||
| debugOff() { | ||
| debug = 0; | ||
| window.localStorage.debug = debug; | ||
| window.alert(`debug模式调整为关闭`); | ||
| }, | ||
| cheatDebugClick(count, interval = 1000, mode = 1) { | ||
| cheatCounts++; | ||
| if (cheatCounts >= count) { | ||
| if (debug) { | ||
| debug = 0; | ||
| } | ||
| else { | ||
| debug = mode; | ||
| } | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug模式调整为开启'); | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| cheatCounts = 0; | ||
| } | ||
| else { | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| tcCheatDebug = setTimeout(() => { | ||
| cheatCounts = 0; | ||
| clearTimeout(tcCheatDebug); | ||
| }, interval); | ||
| } | ||
| } | ||
| }; |
| export declare const timeCtrl: { | ||
| countDown({ total, step, tick, end }: { | ||
| total: number; | ||
| step: number; | ||
| tick: import("./TimeCtrl").Callback; | ||
| end: import("./TimeCtrl").Callback; | ||
| }): void; | ||
| countUp({ start, total, step, tick, end }: { | ||
| start: number; | ||
| total: number; | ||
| step: number; | ||
| tick: import("./TimeCtrl").Callback; | ||
| end: import("./TimeCtrl").Callback; | ||
| }): void; | ||
| }; | ||
| export declare const logCtrl: { | ||
| saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void; | ||
| sendLog(): void; | ||
| }; | ||
| export declare const debugCtrl: { | ||
| log(info?: string, params?: import("./DebugCtrl").LogParams): void; | ||
| warn(info: any, params: any): void; | ||
| error(info: any, params: any): void; | ||
| debugOn(mode?: 0 | 2 | 1): void; | ||
| debugOff(): void; | ||
| cheatDebugClick(count: any, interval?: number, mode?: 0 | 2 | 1): void; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const TimeCtrl_1 = require("./TimeCtrl"); | ||
| const LogCtrl_1 = require("./LogCtrl"); | ||
| const DebugCtrl_1 = require("./DebugCtrl"); | ||
| exports.timeCtrl = TimeCtrl_1.default; | ||
| exports.logCtrl = LogCtrl_1.default; | ||
| exports.debugCtrl = DebugCtrl_1.default; |
| declare const _default: { | ||
| saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void; | ||
| sendLog(): void; | ||
| }; | ||
| export default _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| let logs = []; | ||
| const tagRandoms = Math.floor(Math.random() * 10e13); | ||
| let tagTime = new Date(); | ||
| tagTime = tagTime.getTime(); | ||
| exports.default = { | ||
| saveLog(msg, type, line = '', compName = '', funcName = '', attach = '') { | ||
| if (msg && type) { | ||
| let now = new Date(); | ||
| now = now.getTime(); | ||
| logs = [...logs, { | ||
| msg, | ||
| type, | ||
| clientTime: now, | ||
| compName, | ||
| funcName, | ||
| line, | ||
| attach | ||
| }]; | ||
| } | ||
| }, | ||
| sendLog() { | ||
| if (logs.length) { | ||
| const tag = `${tagTime}-${tagRandoms}`; | ||
| } | ||
| } | ||
| }; |
| interface CallbackData { | ||
| leftCount?: number; | ||
| count?: number; | ||
| [propName: string]: any; | ||
| } | ||
| export interface Callback { | ||
| (data: CallbackData): any; | ||
| } | ||
| declare const _default: { | ||
| countDown({ total, step, tick, end }: { | ||
| total: number; | ||
| step: number; | ||
| tick: Callback; | ||
| end: Callback; | ||
| }): void; | ||
| countUp({ start, total, step, tick, end }: { | ||
| start: number; | ||
| total: number; | ||
| step: number; | ||
| tick: Callback; | ||
| end: Callback; | ||
| }): void; | ||
| }; | ||
| export default _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| countDown({ total = 60, step = 1000, tick = null, end = null }) { | ||
| total > 0 ? total : total = 60; | ||
| step > 0 ? step : step = 1000; | ||
| let tickCallback = tick || function () { | ||
| }; | ||
| let endCallback = end || function () { | ||
| }; | ||
| let tc = setInterval(function () { | ||
| if (total > 0) { | ||
| tickCallback({ leftCount: total }); | ||
| total--; | ||
| } | ||
| else { | ||
| endCallback({ leftCount: total }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| }, | ||
| countUp({ start = 0, total = 60, step = 1000, tick = null, end = null }) { | ||
| if (start > total) { | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)'); | ||
| return; | ||
| } | ||
| let now = start; | ||
| step > 0 ? step : step = 1000; | ||
| let tickCallback = tick || function () { | ||
| }; | ||
| let endCallback = end || function () { | ||
| }; | ||
| let tc = setInterval(function () { | ||
| if (now < total) { | ||
| tickCallback({ count: now }); | ||
| now++; | ||
| } | ||
| else { | ||
| endCallback({ count: now }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| } | ||
| }; |
| { | ||
| "compileOnSave": true, | ||
| "compilerOptions": { | ||
| "declaration": true, | ||
| // "lib": [ | ||
| // "dom", "es6", "dom.iterable", "scripthost" | ||
| // ], | ||
| "listEmittedFiles": true, | ||
| "module": "commonjs", | ||
| "moduleResolution": "Node", | ||
| // "outDir": "./test", | ||
| "removeComments": true, | ||
| "target": "es6" | ||
| }, | ||
| "include": [ | ||
| "src/**/*" | ||
| ], | ||
| "exclude": [ | ||
| "node_modules", | ||
| "**/*.spec.ts" | ||
| ] | ||
| } |
+138
-230
@@ -1,237 +0,145 @@ | ||
| 'use strict'; | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| var _LogCtrl = require('./LogCtrl'); | ||
| var _LogCtrl2 = _interopRequireDefault(_LogCtrl); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
| // import System from '../models/System' | ||
| // import $ from 'jQuery' | ||
| var debug = 0; // debug模式, 0 - 关闭debug,1 - 初级debug(仅alert警告和错误), 2 - 严格debug(alert所有信息) | ||
| // this controller is about to provide functions for debugging controll | ||
| var cheatCounts = 0; // cheat debug点击的累计次数 | ||
| var tcCheatDebug = null; // cheat debug time ctrl | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var LogCtrl_1 = require("./LogCtrl"); | ||
| var debug = 0; | ||
| var cheatCounts = 0; | ||
| var tcCheatDebug = null; | ||
| exports.default = { | ||
| // system log -- 信息,[ 是否记录到log中,所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: log方法默认不会记录到日志中 | ||
| log: function log(info, params) { | ||
| var isSave = false; | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| log: function log() { | ||
| var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var params = arguments[1]; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = params.isSave; | ||
| } | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += '[line:' + line + ']'; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += '[comp:' + compName + ']'; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += '[func:' + funcName + ']'; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| var isSave = false; | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = true; | ||
| } | ||
| if (params.line) { | ||
| line = params.line.toString(); | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.log(msg); | ||
| if (isSave) { | ||
| LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach); | ||
| } | ||
| if (debug > 1) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| warn: function warn(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| error: function error(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += "[line:" + line + "]"; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += "[comp:" + compName + "]"; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += "[func:" + funcName + "]"; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach); | ||
| LogCtrl_1.default.sendLog(); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| debugOn: function debugOn() { | ||
| var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
| console.log(msg); | ||
| if (isSave) { | ||
| _LogCtrl2.default.saveLog(info, 'info', line, compName, funcName, attach); | ||
| } | ||
| debug = mode; | ||
| window.localStorage.debug = debug; | ||
| window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A" + (mode === 2 ? '严格模式' : '开启')); | ||
| }, | ||
| debugOff: function debugOff() { | ||
| debug = 0; | ||
| window.localStorage.debug = debug; | ||
| window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED"); | ||
| }, | ||
| cheatDebugClick: function cheatDebugClick(count) { | ||
| var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
| var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
| if (debug > 1) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg); | ||
| cheatCounts++; | ||
| if (cheatCounts >= count) { | ||
| if (debug) { | ||
| debug = 0; | ||
| } else { | ||
| debug = mode; | ||
| } | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug模式调整为开启'); | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| cheatCounts = 0; | ||
| } else { | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| tcCheatDebug = setTimeout(function () { | ||
| cheatCounts = 0; | ||
| clearTimeout(tcCheatDebug); | ||
| }, interval); | ||
| } | ||
| } | ||
| }, | ||
| // system warn -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: warn方法只自动记录日志,不主动发送到后台 | ||
| warn: function warn(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += '[line:' + line + ']'; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += '[comp:' + compName + ']'; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += '[func:' + funcName + ']'; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| _LogCtrl2.default.saveLog(info, 'warn', line, compName, funcName, attach); | ||
| if (debug) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| // system error -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: error方法会自动记录,并自动发送到后台 | ||
| error: function error(info, params) { | ||
| var line = ''; | ||
| var compName = ''; | ||
| var funcName = ''; | ||
| var attach = ''; | ||
| var msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += '[line:' + line + ']'; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += '[comp:' + compName + ']'; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += '[func:' + funcName + ']'; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| _LogCtrl2.default.saveLog(info, 'error', line, compName, funcName, attach); | ||
| // 发生错误,立即发送信息到日志系统 | ||
| _LogCtrl2.default.sendLog(); | ||
| if (debug) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| // // freeze background scroll | ||
| // freezeBgScroll() { | ||
| // System.isFreezeBgScroll = true | ||
| // // to be robust, we should add no-scroll in html and body tag as well | ||
| // $('html').addClass('no-scroll') | ||
| // $('body').addClass('no-scroll') | ||
| // }, | ||
| // // resume background scroll | ||
| // resumeBgScroll() { | ||
| // System.isFreezeBgScroll = false | ||
| // $('html').removeClass('no-scroll') | ||
| // $('body').removeClass('no-scroll') | ||
| // }, | ||
| // open debug mode -- [mode = 1 | 2] | ||
| debugOn: function debugOn() { | ||
| var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
| debug = mode; | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug\u6A21\u5F0F\u8C03\u6574\u4E3A' + (mode === 2 ? '严格模式' : '开启')); | ||
| }, | ||
| debugOff: function debugOff() { | ||
| debug = 0; | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED'); | ||
| }, | ||
| // open debugging mode cheat -- trigger click counts, [interval], [mode] | ||
| cheatDebugClick: function cheatDebugClick(count) { | ||
| var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
| var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
| cheatCounts++; | ||
| if (cheatCounts >= count) { | ||
| // 切换 cheat debug | ||
| if (debug) { | ||
| debug = 0; | ||
| } else { | ||
| debug = mode; | ||
| } | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug模式调整为开启'); | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| cheatCounts = 0; | ||
| } else { | ||
| // if (System.cheatCounts >= 2) window.alert(111) | ||
| // 还未达到cheat debug条件 | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| tcCheatDebug = setTimeout(function () { | ||
| // 规定时间内没有重复操作,清除所有参数 | ||
| cheatCounts = 0; | ||
| clearTimeout(tcCheatDebug); | ||
| }, interval); | ||
| } | ||
| } | ||
| // // open debugging mode cheat by maze clicking -- click index | ||
| // cheatMazeDebug(index) { | ||
| // // 设定maze cheat需要判定的个数 | ||
| // console.log('进入maze check') | ||
| // const mazeCount = 3 | ||
| // System.cheatMazeMap.push(index) | ||
| // let flag = true | ||
| // for (let i = 0; i < System.cheatMazeMap.length; i++) { | ||
| // if (System.cheatMazeMap[i] !== (i + 1)) { | ||
| // flag = false | ||
| // break | ||
| // } | ||
| // } | ||
| // if (!flag) { | ||
| // // 存在非法的maze code | ||
| // console.log('非法 maze code') | ||
| // System.cheatMazeMap = [] | ||
| // } else { | ||
| // // 全部是合法的code | ||
| // if (System.cheatMazeMap.length === mazeCount) { | ||
| // // 输入的maze code已经达到标准 | ||
| // System.cheatMazeMap = [] | ||
| // System.debug = !System.debug | ||
| // localStorage.debug = System.debug | ||
| // window.alert('debug模式调整为' + System.debug) | ||
| // } else { | ||
| // // 输入的maze code还不到标准 | ||
| // // do nothing | ||
| // console.log('maze code 正确,继续加油') | ||
| // } | ||
| // } | ||
| // } | ||
| }; |
+8
-23
@@ -1,24 +0,9 @@ | ||
| 'use strict'; | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.debugCtrl = exports.logCtrl = exports.timeCtrl = undefined; | ||
| var _TimeCtrl = require('./TimeCtrl'); | ||
| var _TimeCtrl2 = _interopRequireDefault(_TimeCtrl); | ||
| var _LogCtrl = require('./LogCtrl'); | ||
| var _LogCtrl2 = _interopRequireDefault(_LogCtrl); | ||
| var _DebugCtrl = require('./DebugCtrl'); | ||
| var _DebugCtrl2 = _interopRequireDefault(_DebugCtrl); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
| var timeCtrl = exports.timeCtrl = _TimeCtrl2.default; // entry js | ||
| var logCtrl = exports.logCtrl = _LogCtrl2.default; | ||
| var debugCtrl = exports.debugCtrl = _DebugCtrl2.default; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var TimeCtrl_1 = require("./TimeCtrl"); | ||
| var LogCtrl_1 = require("./LogCtrl"); | ||
| var DebugCtrl_1 = require("./DebugCtrl"); | ||
| exports.timeCtrl = TimeCtrl_1.default; | ||
| exports.logCtrl = LogCtrl_1.default; | ||
| exports.debugCtrl = DebugCtrl_1.default; |
+29
-54
@@ -1,61 +0,36 @@ | ||
| 'use strict'; | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
| var _angleUtil = require('@youngbeen/angle-util'); | ||
| function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } // this controller is about to provide functions for log controll | ||
| require('@youngbeen/ums-tracking'); | ||
| var logs = []; // 日志信息 | ||
| var tagRandoms = Math.floor(Math.random() * 10e13); // 用于标识某访问的唯一标识符组成部分的随机数 | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var logs = []; | ||
| var tagRandoms = Math.floor(Math.random() * 10e13); | ||
| var tagTime = new Date(); | ||
| tagTime = tagTime.getTime(); // 用于标识某访问的唯一标识符组成部分的时间戳 | ||
| tagTime = tagTime.getTime(); | ||
| exports.default = { | ||
| // 保存日志到历史记录 -- 信息内容,信息类型,[ 行数,所在组件名,所在函数名,附加信息 ] | ||
| saveLog: function saveLog(msg, type) { | ||
| var line = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
| var compName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; | ||
| var funcName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; | ||
| var attach = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ''; | ||
| saveLog: function saveLog(msg, type) { | ||
| var line = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
| var compName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; | ||
| var funcName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; | ||
| var attach = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ''; | ||
| if (msg && type) { | ||
| var now = new Date(); | ||
| now = now.getTime(); | ||
| now = _angleUtil.dateUtil.getDateTime(now); | ||
| logs = [].concat(_toConsumableArray(logs), [{ | ||
| msg: msg, | ||
| type: type, | ||
| clientTime: now, | ||
| compName: compName, | ||
| funcName: funcName, | ||
| line: line, | ||
| attach: attach | ||
| }]); | ||
| if (msg && type) { | ||
| var now = new Date(); | ||
| now = now.getTime(); | ||
| logs = [].concat(_toConsumableArray(logs), [{ | ||
| msg: msg, | ||
| type: type, | ||
| clientTime: now, | ||
| compName: compName, | ||
| funcName: funcName, | ||
| line: line, | ||
| attach: attach | ||
| }]); | ||
| } | ||
| }, | ||
| sendLog: function sendLog() { | ||
| if (logs.length) { | ||
| var tag = tagTime + "-" + tagRandoms; | ||
| } | ||
| } | ||
| }, | ||
| // 发送日志到日志系统 -- | ||
| sendLog: function sendLog() { | ||
| if (logs.length) { | ||
| var tag = tagTime + '-' + tagRandoms; // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用 | ||
| // 使用tracking方法发送日志 | ||
| if (window.tracking) { | ||
| window.tracking('UMS_FELOG_ERRORLOG', { | ||
| tag: tag, | ||
| historyLogs: logs | ||
| }, 'fe_errorlog'); | ||
| } | ||
| // 使用图片发送日志 | ||
| // let url = `https://someurl?type=UMS_FELOG&content=LOGSTART>>${encodeURIComponent(JSON.stringify(content))}<<LOGEND` | ||
| // let oImage = new Image() | ||
| // oImage.src = url | ||
| // oImage = null | ||
| } | ||
| } | ||
| }; |
+2
-2
| { | ||
| "name": "@youngbeen/angle-ctrl", | ||
| "version": "1.0.9", | ||
| "version": "1.0.10-rc1", | ||
| "description": "The controllers used in angle-FE team", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
| "scripts": { | ||
| "compile": "babel -d ./ src/", | ||
| "compile": "tsc && babel -d ./ src/", | ||
| "prepare": "npm run compile", | ||
@@ -18,0 +18,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
+137
-216
@@ -1,217 +0,138 @@ | ||
| // this controller is about to provide functions for debugging controll | ||
| import logCtrl from './LogCtrl' | ||
| // import System from '../models/System' | ||
| // import $ from 'jQuery' | ||
| let debug = 0 // debug模式, 0 - 关闭debug,1 - 初级debug(仅alert警告和错误), 2 - 严格debug(alert所有信息) | ||
| let cheatCounts = 0 // cheat debug点击的累计次数 | ||
| let tcCheatDebug = null // cheat debug time ctrl | ||
| export default { | ||
| // system log -- 信息,[ 是否记录到log中,所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: log方法默认不会记录到日志中 | ||
| log (info, params) { | ||
| let isSave = false | ||
| let line = '' | ||
| let compName = '' | ||
| let funcName = '' | ||
| let attach = '' | ||
| let msg = info | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = params.isSave | ||
| } | ||
| if (params.line) { | ||
| line = params.line | ||
| msg += `[line:${line}]` | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName | ||
| msg += `[comp:${compName}]` | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName | ||
| msg += `[func:${funcName}]` | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach | ||
| } | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const LogCtrl_1 = require("./LogCtrl"); | ||
| let debug = 0; | ||
| let cheatCounts = 0; | ||
| let tcCheatDebug = null; | ||
| exports.default = { | ||
| log(info = '', params) { | ||
| let isSave = false; | ||
| let line = ''; | ||
| let compName = ''; | ||
| let funcName = ''; | ||
| let attach = ''; | ||
| let msg = info; | ||
| if (params) { | ||
| if (params.isSave) { | ||
| isSave = true; | ||
| } | ||
| if (params.line) { | ||
| line = params.line.toString(); | ||
| msg += `[line:${line}]`; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += `[comp:${compName}]`; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += `[func:${funcName}]`; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.log(msg); | ||
| if (isSave) { | ||
| LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach); | ||
| } | ||
| if (debug > 1) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| warn(info, params) { | ||
| let line = ''; | ||
| let compName = ''; | ||
| let funcName = ''; | ||
| let attach = ''; | ||
| let msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += `[line:${line}]`; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += `[comp:${compName}]`; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += `[func:${funcName}]`; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| error(info, params) { | ||
| let line = ''; | ||
| let compName = ''; | ||
| let funcName = ''; | ||
| let attach = ''; | ||
| let msg = info; | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line; | ||
| msg += `[line:${line}]`; | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName; | ||
| msg += `[comp:${compName}]`; | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName; | ||
| msg += `[func:${funcName}]`; | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach; | ||
| } | ||
| } | ||
| console.warn(msg); | ||
| LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach); | ||
| LogCtrl_1.default.sendLog(); | ||
| if (debug) { | ||
| window.alert(msg); | ||
| } | ||
| }, | ||
| debugOn(mode = 1) { | ||
| debug = mode; | ||
| window.localStorage.debug = debug; | ||
| window.alert(`debug模式调整为${mode === 2 ? '严格模式' : '开启'}`); | ||
| }, | ||
| debugOff() { | ||
| debug = 0; | ||
| window.localStorage.debug = debug; | ||
| window.alert(`debug模式调整为关闭`); | ||
| }, | ||
| cheatDebugClick(count, interval = 1000, mode = 1) { | ||
| cheatCounts++; | ||
| if (cheatCounts >= count) { | ||
| if (debug) { | ||
| debug = 0; | ||
| } | ||
| else { | ||
| debug = mode; | ||
| } | ||
| window.localStorage.debug = debug; | ||
| window.alert('debug模式调整为开启'); | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| cheatCounts = 0; | ||
| } | ||
| else { | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug); | ||
| } | ||
| tcCheatDebug = setTimeout(() => { | ||
| cheatCounts = 0; | ||
| clearTimeout(tcCheatDebug); | ||
| }, interval); | ||
| } | ||
| } | ||
| console.log(msg) | ||
| if (isSave) { | ||
| logCtrl.saveLog(info, 'info', line, compName, funcName, attach) | ||
| } | ||
| if (debug > 1) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg) | ||
| } | ||
| }, | ||
| // system warn -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: warn方法只自动记录日志,不主动发送到后台 | ||
| warn (info, params) { | ||
| let line = '' | ||
| let compName = '' | ||
| let funcName = '' | ||
| let attach = '' | ||
| let msg = info | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line | ||
| msg += `[line:${line}]` | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName | ||
| msg += `[comp:${compName}]` | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName | ||
| msg += `[func:${funcName}]` | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach | ||
| } | ||
| } | ||
| console.warn(msg) | ||
| logCtrl.saveLog(info, 'warn', line, compName, funcName, attach) | ||
| if (debug) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg) | ||
| } | ||
| }, | ||
| // system error -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ] | ||
| // NOTE: error方法会自动记录,并自动发送到后台 | ||
| error (info, params) { | ||
| let line = '' | ||
| let compName = '' | ||
| let funcName = '' | ||
| let attach = '' | ||
| let msg = info | ||
| if (params) { | ||
| if (params.line) { | ||
| line = params.line | ||
| msg += `[line:${line}]` | ||
| } | ||
| if (params.compName) { | ||
| compName = params.compName | ||
| msg += `[comp:${compName}]` | ||
| } | ||
| if (params.funcName) { | ||
| funcName = params.funcName | ||
| msg += `[func:${funcName}]` | ||
| } | ||
| if (params.attach) { | ||
| attach = params.attach | ||
| } | ||
| } | ||
| console.warn(msg) | ||
| logCtrl.saveLog(info, 'error', line, compName, funcName, attach) | ||
| // 发生错误,立即发送信息到日志系统 | ||
| logCtrl.sendLog() | ||
| if (debug) { | ||
| // 调试模式打开,打开alert方式 | ||
| window.alert(msg) | ||
| } | ||
| }, | ||
| // // freeze background scroll | ||
| // freezeBgScroll() { | ||
| // System.isFreezeBgScroll = true | ||
| // // to be robust, we should add no-scroll in html and body tag as well | ||
| // $('html').addClass('no-scroll') | ||
| // $('body').addClass('no-scroll') | ||
| // }, | ||
| // // resume background scroll | ||
| // resumeBgScroll() { | ||
| // System.isFreezeBgScroll = false | ||
| // $('html').removeClass('no-scroll') | ||
| // $('body').removeClass('no-scroll') | ||
| // }, | ||
| // open debug mode -- [mode = 1 | 2] | ||
| debugOn (mode = 1) { | ||
| debug = mode | ||
| window.localStorage.debug = debug | ||
| window.alert(`debug模式调整为${mode === 2 ? '严格模式' : '开启'}`) | ||
| }, | ||
| debugOff () { | ||
| debug = 0 | ||
| window.localStorage.debug = debug | ||
| window.alert(`debug模式调整为关闭`) | ||
| }, | ||
| // open debugging mode cheat -- trigger click counts, [interval], [mode] | ||
| cheatDebugClick (count, interval = 1000, mode = 1) { | ||
| cheatCounts++ | ||
| if (cheatCounts >= count) { | ||
| // 切换 cheat debug | ||
| if (debug) { | ||
| debug = 0 | ||
| } else { | ||
| debug = mode | ||
| } | ||
| window.localStorage.debug = debug | ||
| window.alert('debug模式调整为开启') | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug) | ||
| } | ||
| cheatCounts = 0 | ||
| } else { | ||
| // if (System.cheatCounts >= 2) window.alert(111) | ||
| // 还未达到cheat debug条件 | ||
| if (tcCheatDebug) { | ||
| clearTimeout(tcCheatDebug) | ||
| } | ||
| tcCheatDebug = setTimeout(() => { | ||
| // 规定时间内没有重复操作,清除所有参数 | ||
| cheatCounts = 0 | ||
| clearTimeout(tcCheatDebug) | ||
| }, interval) | ||
| } | ||
| } | ||
| // // open debugging mode cheat by maze clicking -- click index | ||
| // cheatMazeDebug(index) { | ||
| // // 设定maze cheat需要判定的个数 | ||
| // console.log('进入maze check') | ||
| // const mazeCount = 3 | ||
| // System.cheatMazeMap.push(index) | ||
| // let flag = true | ||
| // for (let i = 0; i < System.cheatMazeMap.length; i++) { | ||
| // if (System.cheatMazeMap[i] !== (i + 1)) { | ||
| // flag = false | ||
| // break | ||
| // } | ||
| // } | ||
| // if (!flag) { | ||
| // // 存在非法的maze code | ||
| // console.log('非法 maze code') | ||
| // System.cheatMazeMap = [] | ||
| // } else { | ||
| // // 全部是合法的code | ||
| // if (System.cheatMazeMap.length === mazeCount) { | ||
| // // 输入的maze code已经达到标准 | ||
| // System.cheatMazeMap = [] | ||
| // System.debug = !System.debug | ||
| // localStorage.debug = System.debug | ||
| // window.alert('debug模式调整为' + System.debug) | ||
| // } else { | ||
| // // 输入的maze code还不到标准 | ||
| // // do nothing | ||
| // console.log('maze code 正确,继续加油') | ||
| // } | ||
| // } | ||
| // } | ||
| } | ||
| }; |
+8
-8
@@ -1,8 +0,8 @@ | ||
| // entry js | ||
| import TimeCtrl from './TimeCtrl' | ||
| import LogCtrl from './LogCtrl' | ||
| import DebugCtrl from './DebugCtrl' | ||
| export const timeCtrl = TimeCtrl | ||
| export const logCtrl = LogCtrl | ||
| export const debugCtrl = DebugCtrl | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const TimeCtrl_1 = require("./TimeCtrl"); | ||
| const LogCtrl_1 = require("./LogCtrl"); | ||
| const DebugCtrl_1 = require("./DebugCtrl"); | ||
| exports.timeCtrl = TimeCtrl_1.default; | ||
| exports.logCtrl = LogCtrl_1.default; | ||
| exports.debugCtrl = DebugCtrl_1.default; |
+27
-47
@@ -1,48 +0,28 @@ | ||
| // this controller is about to provide functions for log controll | ||
| import { dateUtil } from '@youngbeen/angle-util' | ||
| require('@youngbeen/ums-tracking') | ||
| let logs = [] // 日志信息 | ||
| const tagRandoms = Math.floor(Math.random() * 10e13) // 用于标识某访问的唯一标识符组成部分的随机数 | ||
| let tagTime = new Date() | ||
| tagTime = tagTime.getTime() // 用于标识某访问的唯一标识符组成部分的时间戳 | ||
| export default { | ||
| // 保存日志到历史记录 -- 信息内容,信息类型,[ 行数,所在组件名,所在函数名,附加信息 ] | ||
| saveLog (msg, type, line = '', compName = '', funcName = '', attach = '') { | ||
| if (msg && type) { | ||
| let now = new Date() | ||
| now = now.getTime() | ||
| now = dateUtil.getDateTime(now) | ||
| logs = [...logs, { | ||
| msg, | ||
| type, | ||
| clientTime: now, | ||
| compName, | ||
| funcName, | ||
| line, | ||
| attach | ||
| }] | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| let logs = []; | ||
| const tagRandoms = Math.floor(Math.random() * 10e13); | ||
| let tagTime = new Date(); | ||
| tagTime = tagTime.getTime(); | ||
| exports.default = { | ||
| saveLog(msg, type, line = '', compName = '', funcName = '', attach = '') { | ||
| if (msg && type) { | ||
| let now = new Date(); | ||
| now = now.getTime(); | ||
| logs = [...logs, { | ||
| msg, | ||
| type, | ||
| clientTime: now, | ||
| compName, | ||
| funcName, | ||
| line, | ||
| attach | ||
| }]; | ||
| } | ||
| }, | ||
| sendLog() { | ||
| if (logs.length) { | ||
| const tag = `${tagTime}-${tagRandoms}`; | ||
| } | ||
| } | ||
| }, | ||
| // 发送日志到日志系统 -- | ||
| sendLog () { | ||
| if (logs.length) { | ||
| const tag = `${tagTime}-${tagRandoms}` // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用 | ||
| // 使用tracking方法发送日志 | ||
| if (window.tracking) { | ||
| window.tracking('UMS_FELOG_ERRORLOG', { | ||
| tag, | ||
| historyLogs: logs | ||
| }, 'fe_errorlog') | ||
| } | ||
| // 使用图片发送日志 | ||
| // let url = `https://someurl?type=UMS_FELOG&content=LOGSTART>>${encodeURIComponent(JSON.stringify(content))}<<LOGEND` | ||
| // let oImage = new Image() | ||
| // oImage.src = url | ||
| // oImage = null | ||
| } | ||
| } | ||
| } | ||
| }; |
+42
-65
@@ -1,67 +0,44 @@ | ||
| // this controller is about to provide functions for time controll | ||
| export default { | ||
| // auto counting down -- { [total], [step], [tick], [end] } | ||
| countDown (params) { | ||
| if (params) { | ||
| let total = params.total || 60 | ||
| total > 0 ? parseInt(total) : total = 60 | ||
| let step = params.step || 1000 | ||
| step > 0 ? parseInt(step) : step = 1000 | ||
| let tickCallback = params.tick || function (result) { | ||
| // console.log('tick', result.leftCount) | ||
| } | ||
| let endCallback = params.end || function (result) { | ||
| // console.log('end the counting') | ||
| } | ||
| let tc = setInterval(function () { | ||
| if (total > 0) { | ||
| // time still left | ||
| tickCallback({ leftCount: total }) | ||
| total-- | ||
| } else { | ||
| // counts end | ||
| endCallback({ leftCount: total }) | ||
| clearInterval(tc) | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| countDown({ total = 60, step = 1000, tick = null, end = null }) { | ||
| total > 0 ? total : total = 60; | ||
| step > 0 ? step : step = 1000; | ||
| let tickCallback = tick || function () { | ||
| }; | ||
| let endCallback = end || function () { | ||
| }; | ||
| let tc = setInterval(function () { | ||
| if (total > 0) { | ||
| tickCallback({ leftCount: total }); | ||
| total--; | ||
| } | ||
| else { | ||
| endCallback({ leftCount: total }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| }, | ||
| countUp({ start = 0, total = 60, step = 1000, tick = null, end = null }) { | ||
| if (start > total) { | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)'); | ||
| return; | ||
| } | ||
| }, step) | ||
| let now = start; | ||
| step > 0 ? step : step = 1000; | ||
| let tickCallback = tick || function () { | ||
| }; | ||
| let endCallback = end || function () { | ||
| }; | ||
| let tc = setInterval(function () { | ||
| if (now < total) { | ||
| tickCallback({ count: now }); | ||
| now++; | ||
| } | ||
| else { | ||
| endCallback({ count: now }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| } | ||
| }, | ||
| // auto counting up -- { [start], [total], [step], [tick], [end] } | ||
| countUp (params) { | ||
| if (params) { | ||
| let start = params.start || 0 | ||
| start = parseInt(start) | ||
| let total = params.total || 60 | ||
| total = parseInt(total) | ||
| if (start > total) { | ||
| // invalid start , total setting | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)') | ||
| return false | ||
| } | ||
| let now = start | ||
| let step = params.step || 1000 | ||
| step > 0 ? parseInt(step) : step = 1000 | ||
| let tickCallback = params.tick || function (result) { | ||
| // console.log('tick', result.count) | ||
| } | ||
| let endCallback = params.end || function (result) { | ||
| // console.log('end the counting') | ||
| } | ||
| let tc = setInterval(function () { | ||
| if (now < total) { | ||
| // count continue | ||
| tickCallback({ count: now }) | ||
| now++ | ||
| } else { | ||
| // counts end | ||
| endCallback({ count: now }) | ||
| clearInterval(tc) | ||
| } | ||
| }, step) | ||
| } | ||
| } | ||
| } | ||
| }; |
+52
-66
@@ -1,73 +0,59 @@ | ||
| 'use strict'; | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| // this controller is about to provide functions for time controll | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = { | ||
| // auto counting down -- { [total], [step], [tick], [end] } | ||
| countDown: function countDown(params) { | ||
| if (params) { | ||
| var total = params.total || 60; | ||
| total > 0 ? parseInt(total) : total = 60; | ||
| var step = params.step || 1000; | ||
| step > 0 ? parseInt(step) : step = 1000; | ||
| var tickCallback = params.tick || function (result) { | ||
| // console.log('tick', result.leftCount) | ||
| }; | ||
| var endCallback = params.end || function (result) { | ||
| // console.log('end the counting') | ||
| }; | ||
| countDown: function countDown(_ref) { | ||
| var _ref$total = _ref.total, | ||
| total = _ref$total === undefined ? 60 : _ref$total, | ||
| _ref$step = _ref.step, | ||
| step = _ref$step === undefined ? 1000 : _ref$step, | ||
| _ref$tick = _ref.tick, | ||
| tick = _ref$tick === undefined ? null : _ref$tick, | ||
| _ref$end = _ref.end, | ||
| end = _ref$end === undefined ? null : _ref$end; | ||
| var tc = setInterval(function () { | ||
| if (total > 0) { | ||
| // time still left | ||
| tickCallback({ leftCount: total }); | ||
| total--; | ||
| } else { | ||
| // counts end | ||
| endCallback({ leftCount: total }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| } | ||
| }, | ||
| total > 0 ? total : total = 60; | ||
| step > 0 ? step : step = 1000; | ||
| var tickCallback = tick || function () {}; | ||
| var endCallback = end || function () {}; | ||
| var tc = setInterval(function () { | ||
| if (total > 0) { | ||
| tickCallback({ leftCount: total }); | ||
| total--; | ||
| } else { | ||
| endCallback({ leftCount: total }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| }, | ||
| countUp: function countUp(_ref2) { | ||
| var _ref2$start = _ref2.start, | ||
| start = _ref2$start === undefined ? 0 : _ref2$start, | ||
| _ref2$total = _ref2.total, | ||
| total = _ref2$total === undefined ? 60 : _ref2$total, | ||
| _ref2$step = _ref2.step, | ||
| step = _ref2$step === undefined ? 1000 : _ref2$step, | ||
| _ref2$tick = _ref2.tick, | ||
| tick = _ref2$tick === undefined ? null : _ref2$tick, | ||
| _ref2$end = _ref2.end, | ||
| end = _ref2$end === undefined ? null : _ref2$end; | ||
| // auto counting up -- { [start], [total], [step], [tick], [end] } | ||
| countUp: function countUp(params) { | ||
| if (params) { | ||
| var start = params.start || 0; | ||
| start = parseInt(start); | ||
| var total = params.total || 60; | ||
| total = parseInt(total); | ||
| if (start > total) { | ||
| // invalid start , total setting | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)'); | ||
| return false; | ||
| } | ||
| var now = start; | ||
| var step = params.step || 1000; | ||
| step > 0 ? parseInt(step) : step = 1000; | ||
| var tickCallback = params.tick || function (result) { | ||
| // console.log('tick', result.count) | ||
| }; | ||
| var endCallback = params.end || function (result) { | ||
| // console.log('end the counting') | ||
| }; | ||
| var tc = setInterval(function () { | ||
| if (now < total) { | ||
| // count continue | ||
| tickCallback({ count: now }); | ||
| now++; | ||
| } else { | ||
| // counts end | ||
| endCallback({ count: now }); | ||
| clearInterval(tc); | ||
| if (start > total) { | ||
| console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)'); | ||
| return; | ||
| } | ||
| }, step); | ||
| var now = start; | ||
| step > 0 ? step : step = 1000; | ||
| var tickCallback = tick || function () {}; | ||
| var endCallback = end || function () {}; | ||
| var tc = setInterval(function () { | ||
| if (now < total) { | ||
| tickCallback({ count: now }); | ||
| now++; | ||
| } else { | ||
| endCallback({ count: now }); | ||
| clearInterval(tc); | ||
| } | ||
| }, step); | ||
| } | ||
| } | ||
| }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
57768
109.05%35
218.18%1591
145.52%3
50%1
Infinity%