mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-05 05:18:12 +08:00
fix time js
This commit is contained in:
parent
df63bc4177
commit
1e5f70dc68
@ -1,5 +1,5 @@
|
|||||||
import axios from "./config";
|
import axios from "./config";
|
||||||
import { parseTime } from "@/utils/time";
|
import { parseTime } from "@/utils/const";
|
||||||
import echarts from "echarts";
|
import echarts from "echarts";
|
||||||
|
|
||||||
// node 列表
|
// node 列表
|
||||||
|
@ -67,10 +67,9 @@
|
|||||||
<script>
|
<script>
|
||||||
import { systemInfo, uploadUpgradeFile, changelog, checkVersion, remoteUpgrade, uploadUpgradeFileMerge } from "@/api/system";
|
import { systemInfo, uploadUpgradeFile, changelog, checkVersion, remoteUpgrade, uploadUpgradeFileMerge } from "@/api/system";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import MarkdownItVue from "markdown-it-vue";
|
import MarkdownItVue from "markdown-it-vue";
|
||||||
import "markdown-it-vue/dist/markdown-it-vue.css";
|
import "markdown-it-vue/dist/markdown-it-vue.css";
|
||||||
import { RESTART_UPGRADE_WAIT_TIME_COUNT } from "@/utils/const";
|
import { RESTART_UPGRADE_WAIT_TIME_COUNT, parseTime } from "@/utils/const";
|
||||||
import { uploadPieces } from "@/utils/upload-pieces";
|
import { uploadPieces } from "@/utils/upload-pieces";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -108,9 +108,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import BuildLog from "./log";
|
import BuildLog from "./log";
|
||||||
import { deleteBuildHistory, downloadBuildFile, downloadBuildLog, getBuildListAll, geteBuildHistory, releaseMethodMap, rollback, statusMap, triggerBuildTypeMap } from "@/api/build-info";
|
import { deleteBuildHistory, downloadBuildFile, downloadBuildLog, getBuildListAll, geteBuildHistory, releaseMethodMap, rollback, statusMap, triggerBuildTypeMap } from "@/api/build-info";
|
||||||
import { formatDuration, parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, formatDuration, parseTime } from "@/utils/const";
|
||||||
|
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -957,9 +957,8 @@ import {
|
|||||||
import { afterOptList, afterOptListSimple, getDishPatchListAll } from "@/api/dispatch";
|
import { afterOptList, afterOptListSimple, getDishPatchListAll } from "@/api/dispatch";
|
||||||
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
||||||
import { getSshListAll } from "@/api/ssh";
|
import { getSshListAll } from "@/api/ssh";
|
||||||
import { itemGroupBy, parseTime } from "@/utils/time";
|
|
||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY, itemGroupBy, parseTime } from "@/utils/const";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import { dockerSwarmListAll, dockerSwarmServicesList } from "@/api/docker-swarm";
|
import { dockerSwarmListAll, dockerSwarmServicesList } from "@/api/docker-swarm";
|
||||||
import { getScriptListAll } from "@/api/server-script";
|
import { getScriptListAll } from "@/api/server-script";
|
||||||
|
@ -731,8 +731,19 @@ import {
|
|||||||
} from "@/api/dispatch";
|
} from "@/api/dispatch";
|
||||||
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
||||||
import { getProjectData, javaModes, noFileModes, runModeList, getRuningProjectInfo, getProjectGroupAll } from "@/api/node-project";
|
import { getProjectData, javaModes, noFileModes, runModeList, getRuningProjectInfo, getProjectGroupAll } from "@/api/node-project";
|
||||||
import { itemGroupBy, parseTime, renderSize, formatDuration } from "@/utils/time";
|
import {
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, PROJECT_DSL_DEFATUL, readJsonStrField, concurrentExecution, randomStr } from "@/utils/const";
|
CHANGE_PAGE,
|
||||||
|
COMPUTED_PAGINATION,
|
||||||
|
PAGE_DEFAULT_LIST_QUERY,
|
||||||
|
PROJECT_DSL_DEFATUL,
|
||||||
|
readJsonStrField,
|
||||||
|
concurrentExecution,
|
||||||
|
randomStr,
|
||||||
|
itemGroupBy,
|
||||||
|
parseTime,
|
||||||
|
renderSize,
|
||||||
|
formatDuration,
|
||||||
|
} from "@/utils/const";
|
||||||
import FileRead from "@/pages/node/node-layout/project/project-file-read";
|
import FileRead from "@/pages/node/node-layout/project/project-file-read";
|
||||||
import { uploadPieces } from "@/utils/upload-pieces";
|
import { uploadPieces } from "@/utils/upload-pieces";
|
||||||
import CustomSelect from "@/components/customSelect";
|
import CustomSelect from "@/components/customSelect";
|
||||||
|
@ -73,9 +73,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getNodeListAll } from "@/api/node";
|
import { getNodeListAll } from "@/api/node";
|
||||||
import { dispatchStatusMap, getDishPatchListAll, getDishPatchLogList } from "@/api/dispatch";
|
import { dispatchStatusMap, getDishPatchListAll, getDishPatchLogList } from "@/api/dispatch";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, readJsonStrField, parseTime } from "@/utils/const";
|
||||||
|
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, readJsonStrField } from "@/utils/const";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -116,9 +116,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { deleteLogRead, editLogRead, getLogReadList } from "@/api/log-read";
|
import { deleteLogRead, editLogRead, getLogReadList } from "@/api/log-read";
|
||||||
import { itemGroupBy, parseTime } from "@/utils/time";
|
|
||||||
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, itemGroupBy, parseTime } from "@/utils/const";
|
||||||
|
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
import logReadView from "./logReadView";
|
import logReadView from "./logReadView";
|
||||||
|
@ -121,9 +121,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
||||||
import { itemGroupBy } from "@/utils/time";
|
|
||||||
import { getFileList } from "@/api/node-project";
|
import { getFileList } from "@/api/node-project";
|
||||||
import { getWebSocketUrl } from "@/utils/const";
|
import { getWebSocketUrl, itemGroupBy } from "@/utils/const";
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
import viewPre from "@/components/logView/view-pre";
|
import viewPre from "@/components/logView/view-pre";
|
||||||
import { updateCache } from "@/api/log-read";
|
import { updateCache } from "@/api/log-read";
|
||||||
|
@ -328,7 +328,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { parseTime, renderSize } from "@/utils/time";
|
import { parseTime, renderSize } from "@/utils/const";
|
||||||
import {
|
import {
|
||||||
dockerContainerList,
|
dockerContainerList,
|
||||||
dockerContainerRemove,
|
dockerContainerRemove,
|
||||||
|
@ -303,7 +303,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { parseTime, renderSize } from "@/utils/time";
|
import { parseTime, renderSize } from "@/utils/const";
|
||||||
import { dockerImageCreateContainer, dockerImageInspect, dockerImagePullImage, dockerImageRemove, dockerImagesList } from "@/api/docker-api";
|
import { dockerImageCreateContainer, dockerImageInspect, dockerImagePullImage, dockerImageRemove, dockerImagesList } from "@/api/docker-api";
|
||||||
import PullImageLog from "@/pages/docker/pull-image-log";
|
import PullImageLog from "@/pages/docker/pull-image-log";
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { dockerInfo, dockerPrune } from "@/api/docker-api";
|
import { dockerInfo, dockerPrune } from "@/api/docker-api";
|
||||||
import { renderSize } from "@/utils/time";
|
import { renderSize } from "@/utils/const";
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
|
@ -244,9 +244,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { apiVersions, dcokerSwarmLeaveForce, deleteDcoker, dockerList, editDocker, editDockerByFile, tryLocalDocker } from "@/api/docker-api";
|
import { apiVersions, dcokerSwarmLeaveForce, deleteDcoker, dockerList, editDocker, editDockerByFile, tryLocalDocker } from "@/api/docker-api";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { dockerSwarmListAll, initDockerSwarm, joinDockerSwarm } from "@/api/docker-swarm";
|
import { dockerSwarmListAll, initDockerSwarm, joinDockerSwarm } from "@/api/docker-swarm";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import Console from "./console";
|
import Console from "./console";
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
</a-table>
|
</a-table>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { renderSize, parseTime } from "@/utils/time";
|
import { renderSize, parseTime } from "@/utils/const";
|
||||||
import { dockerNetworksList, dockerVolumesRemove } from "@/api/docker-api";
|
import { dockerNetworksList, dockerVolumesRemove } from "@/api/docker-api";
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -68,9 +68,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { dockerSwarmList, editDockerSwarm, unbindSwarm } from "@/api/docker-swarm";
|
import { dockerSwarmList, editDockerSwarm, unbindSwarm } from "@/api/docker-swarm";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
import Console from "./console";
|
import Console from "./console";
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@
|
|||||||
import { dockerSwarmServicesDel, dockerSwarmServicesEdit, dockerSwarmServicesList } from "@/api/docker-swarm";
|
import { dockerSwarmServicesDel, dockerSwarmServicesEdit, dockerSwarmServicesList } from "@/api/docker-swarm";
|
||||||
import SwarmTask from "./task";
|
import SwarmTask from "./task";
|
||||||
import PullLog from "./pull-log";
|
import PullLog from "./pull-log";
|
||||||
import { renderSize } from "@/utils/time";
|
import { renderSize } from "@/utils/const";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { SwarmTask, PullLog },
|
components: { SwarmTask, PullLog },
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { dockerSwarmNodeLeave, dockerSwarmNodeUpdate, dockerSwarmServicesTaskList, TASK_STATE } from "@/api/docker-swarm";
|
import { dockerSwarmNodeLeave, dockerSwarmNodeUpdate, dockerSwarmServicesTaskList, TASK_STATE } from "@/api/docker-swarm";
|
||||||
import { parseTime } from "@/utils/time";
|
import { parseTime } from "@/utils/const";
|
||||||
import PullLog from "./pull-log";
|
import PullLog from "./pull-log";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
</a-table>
|
</a-table>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { renderSize, parseTime } from "@/utils/time";
|
import { renderSize, parseTime } from "@/utils/const";
|
||||||
import { dockerVolumesList, dockerVolumesRemove } from "@/api/docker-api";
|
import { dockerVolumesList, dockerVolumesRemove } from "@/api/docker-api";
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -137,8 +137,7 @@ import { deleteMonitor, editMonitor, getMonitorList } from "@/api/monitor";
|
|||||||
import { noFileModes } from "@/api/node-project";
|
import { noFileModes } from "@/api/node-project";
|
||||||
import { getUserListAll } from "@/api/user/user";
|
import { getUserListAll } from "@/api/user/user";
|
||||||
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
import { getNodeListAll, getProjectListAll } from "@/api/node";
|
||||||
import { itemGroupBy, parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY, itemGroupBy, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getMonitorLogList, notifyStyle } from "@/api/monitor";
|
import { getMonitorLogList, notifyStyle } from "@/api/monitor";
|
||||||
import { getNodeListAll } from "@/api/node";
|
import { getNodeListAll } from "@/api/node";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -90,8 +90,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { deleteMonitorOperate, editMonitorOperate, getMonitorOperateLogList, getMonitorOperateTypeList } from "@/api/monitor";
|
import { deleteMonitorOperate, editMonitorOperate, getMonitorOperateLogList, getMonitorOperateTypeList } from "@/api/monitor";
|
||||||
import { getUserListAll } from "@/api/user/user";
|
import { getUserListAll } from "@/api/user/user";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -345,8 +345,7 @@ import { getSshListAll } from "@/api/ssh";
|
|||||||
import { syncScript } from "@/api/node-other";
|
import { syncScript } from "@/api/node-other";
|
||||||
import NodeLayout from "./node-layout";
|
import NodeLayout from "./node-layout";
|
||||||
import Terminal from "@/pages/ssh/terminal";
|
import Terminal from "@/pages/ssh/terminal";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
import { getWorkSpaceListAll } from "@/api/workspace";
|
import { getWorkSpaceListAll } from "@/api/workspace";
|
||||||
import CustomSelect from "@/components/customSelect";
|
import CustomSelect from "@/components/customSelect";
|
||||||
import fastInstall from "./fast-install.vue";
|
import fastInstall from "./fast-install.vue";
|
||||||
|
@ -65,8 +65,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { deleteCert, downloadCert, editCert, getCertList, getCertWhiteList } from "../../../../api/node-nginx";
|
import { deleteCert, downloadCert, editCert, getCertList, getCertWhiteList } from "@/api/node-nginx";
|
||||||
import { parseTime } from "../../../../utils/time";
|
import { parseTime } from "@/utils/const";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -83,8 +83,7 @@
|
|||||||
import { getScriptList, editScript, deleteScript, itemScript, syncScript } from "@/api/node-other";
|
import { getScriptList, editScript, deleteScript, itemScript, syncScript } from "@/api/node-other";
|
||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import ScriptConsole from "./script-console";
|
import ScriptConsole from "./script-console";
|
||||||
import { CRON_DATA_SOURCE, COMPUTED_PAGINATION, CHANGE_PAGE, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CRON_DATA_SOURCE, COMPUTED_PAGINATION, CHANGE_PAGE, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ScriptConsole,
|
ScriptConsole,
|
||||||
|
@ -64,8 +64,7 @@
|
|||||||
import { getScriptLogList, scriptDel, triggerExecTypeMap } from "@/api/node-other";
|
import { getScriptLogList, scriptDel, triggerExecTypeMap } from "@/api/node-other";
|
||||||
// import {triggerExecTypeMap} from "@/api/node-script";
|
// import {triggerExecTypeMap} from "@/api/node-script";
|
||||||
import ScriptLogView from "@/pages/node/node-layout/other/script-log-view";
|
import ScriptLogView from "@/pages/node/node-layout/other/script-log-view";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -278,9 +278,7 @@ import {
|
|||||||
uploadProjectFile,
|
uploadProjectFile,
|
||||||
shardingMerge,
|
shardingMerge,
|
||||||
} from "@/api/node-project";
|
} from "@/api/node-project";
|
||||||
import { ZIP_ACCEPT } from "@/utils/const";
|
import { ZIP_ACCEPT, renderSize, formatDuration } from "@/utils/const";
|
||||||
import { renderSize, formatDuration } from "@/utils/time";
|
|
||||||
|
|
||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import projectFileBackup from "./project-file-backup.vue";
|
import projectFileBackup from "./project-file-backup.vue";
|
||||||
import { uploadPieces } from "@/utils/upload-pieces";
|
import { uploadPieces } from "@/utils/upload-pieces";
|
||||||
|
@ -425,9 +425,8 @@ import Console from "./project-console";
|
|||||||
import FileRead from "./project-file-read";
|
import FileRead from "./project-file-read";
|
||||||
import CustomSelect from "@/components/customSelect";
|
import CustomSelect from "@/components/customSelect";
|
||||||
// import Replica from "./project-replica";
|
// import Replica from "./project-replica";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, PROJECT_DSL_DEFATUL, randomStr } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, PROJECT_DSL_DEFATUL, randomStr, parseTime } from "@/utils/const";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
deleteProject,
|
deleteProject,
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getNodeCache, clearCache } from "@/api/system";
|
import { getNodeCache, clearCache } from "@/api/system";
|
||||||
import TaskStat from "@/pages/system/taskStat";
|
import TaskStat from "@/pages/system/taskStat";
|
||||||
import { parseTime } from "@/utils/time";
|
import { parseTime } from "@/utils/const";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
TaskStat,
|
TaskStat,
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { nodeMonitorData, getProcessList, killPid } from "@/api/node";
|
import { nodeMonitorData, getProcessList, killPid } from "@/api/node";
|
||||||
import { renderSize, formatPercent, parseTime, formatDuration } from "@/utils/time";
|
import { renderSize, formatPercent, parseTime, formatDuration } from "@/utils/const";
|
||||||
import CustomSelect from "@/components/customSelect";
|
import CustomSelect from "@/components/customSelect";
|
||||||
import NodeTop from "@/pages/node/node-layout/node-top";
|
import NodeTop from "@/pages/node/node-layout/node-top";
|
||||||
import { generateNodeTopChart, drawChart } from "@/api/node-stat";
|
import { generateNodeTopChart, drawChart } from "@/api/node-stat";
|
||||||
|
@ -193,8 +193,7 @@ import { delAllCache, deleteScript, editScript, getScriptListAll, itemScript, ge
|
|||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import { getNodeListAll } from "@/api/node";
|
import { getNodeListAll } from "@/api/node";
|
||||||
import ScriptConsole from "@/pages/node/node-layout/other/script-console";
|
import ScriptConsole from "@/pages/node/node-layout/other/script-console";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import ScriptLog from "@/pages/node/node-layout/other/script-log";
|
import ScriptLog from "@/pages/node/node-layout/other/script-log";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
|
|
||||||
|
@ -216,8 +216,7 @@ import { delAllProjectCache, getNodeListAll, getProjectList, sortItemProject } f
|
|||||||
import { getRuningProjectInfo, noFileModes, restartProject, runModeList, startProject, stopProject, getProjectTriggerUrl, getProjectGroupAll } from "@/api/node-project";
|
import { getRuningProjectInfo, noFileModes, restartProject, runModeList, startProject, stopProject, getProjectTriggerUrl, getProjectGroupAll } from "@/api/node-project";
|
||||||
import File from "@/pages/node/node-layout/project/project-file";
|
import File from "@/pages/node/node-layout/project/project-file";
|
||||||
import Console from "../node/node-layout/project/project-console";
|
import Console from "../node/node-layout/project/project-console";
|
||||||
import { itemGroupBy, parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, concurrentExecution, itemGroupBy, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, concurrentExecution } from "@/utils/const";
|
|
||||||
import FileRead from "@/pages/node/node-layout/project/project-file-read";
|
import FileRead from "@/pages/node/node-layout/project/project-file-read";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
|
|
||||||
|
@ -222,8 +222,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getStatist, status, statusStat } from "@/api/node-stat";
|
import { getStatist, status, statusStat } from "@/api/node-stat";
|
||||||
import { formatDuration, parseTime } from "@/utils/time";
|
import { PAGE_DEFAULT_LIST_QUERY, PAGE_DEFAULT_SHOW_TOTAL, formatDuration, parseTime } from "@/utils/const";
|
||||||
import { PAGE_DEFAULT_LIST_QUERY, PAGE_DEFAULT_SHOW_TOTAL } from "@/utils/const";
|
|
||||||
import NodeTop from "@/pages/node/node-layout/node-top";
|
import NodeTop from "@/pages/node/node-layout/node-top";
|
||||||
import { getNodeGroupAll } from "@/api/node";
|
import { getNodeGroupAll } from "@/api/node";
|
||||||
|
|
||||||
|
@ -232,8 +232,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { authorizeRepos, deleteRepository, editRepository, getRepositoryList, restHideField, sortItem } from "@/api/repository";
|
import { authorizeRepos, deleteRepository, editRepository, getRepositoryList, restHideField, sortItem } from "@/api/repository";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
components: {},
|
||||||
|
@ -220,8 +220,7 @@ import { deleteScript, editScript, getScriptList, syncToWorkspace, unbindScript,
|
|||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import { getNodeListAll } from "@/api/node";
|
import { getNodeListAll } from "@/api/node";
|
||||||
import ScriptConsole from "@/pages/script/script-console";
|
import ScriptConsole from "@/pages/script/script-console";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
import { getWorkSpaceListAll } from "@/api/workspace";
|
import { getWorkSpaceListAll } from "@/api/workspace";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
|
@ -51,10 +51,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getScriptLogList, scriptDel, triggerExecTypeMap } from "@/api/server-script";
|
import { getScriptLogList, scriptDel, triggerExecTypeMap } from "@/api/server-script";
|
||||||
|
|
||||||
import ScriptLogView from "@/pages/script/script-log-view";
|
import ScriptLogView from "@/pages/script/script-log-view";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -46,8 +46,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { deleteCommandLog, downloadLog, getCommandLogList, statusMap, triggerExecTypeMap } from "@/api/command";
|
import { deleteCommandLog, downloadLog, getCommandLogList, statusMap, triggerExecTypeMap } from "@/api/command";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import CommandLog from "./command-view-log";
|
import CommandLog from "./command-view-log";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -236,8 +236,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { deleteCommand, editCommand, executeBatch, getCommandList, syncToWorkspace, getTriggerUrl } from "@/api/command";
|
import { deleteCommand, editCommand, executeBatch, getCommandList, syncToWorkspace, getTriggerUrl } from "@/api/command";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, CRON_DATA_SOURCE, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import { getSshListAll } from "@/api/ssh";
|
import { getSshListAll } from "@/api/ssh";
|
||||||
import codeEditor from "@/components/codeEditor";
|
import codeEditor from "@/components/codeEditor";
|
||||||
import CommandLog from "./command-view-log";
|
import CommandLog from "./command-view-log";
|
||||||
|
@ -329,8 +329,7 @@
|
|||||||
import { deleteSsh, editSsh, getSshCheckAgent, getSshList, getSshOperationLogList, syncToWorkspace } from "@/api/ssh";
|
import { deleteSsh, editSsh, getSshCheckAgent, getSshList, getSshOperationLogList, syncToWorkspace } from "@/api/ssh";
|
||||||
import SshFile from "@/pages/ssh/ssh-file";
|
import SshFile from "@/pages/ssh/ssh-file";
|
||||||
import Terminal from "@/pages/ssh/terminal";
|
import Terminal from "@/pages/ssh/terminal";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
import { getWorkSpaceListAll } from "@/api/workspace";
|
import { getWorkSpaceListAll } from "@/api/workspace";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
|
@ -101,8 +101,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { backupStatusMap, backupTypeArray, backupTypeMap, createBackup, deleteBackup, downloadBackupFile, getBackupList, getTableNameList, restoreBackup, uploadBackupFile } from "@/api/backup-info";
|
import { backupStatusMap, backupTypeArray, backupTypeMap, createBackup, deleteBackup, downloadBackupFile, getBackupList, getTableNameList, restoreBackup, uploadBackupFile } from "@/api/backup-info";
|
||||||
import { parseTime, renderSize } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime, renderSize } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { parseTime } from "@/utils/time";
|
import { parseTime } from "@/utils/const";
|
||||||
export default {
|
export default {
|
||||||
name: "TaskStat",
|
name: "TaskStat",
|
||||||
props: {
|
props: {
|
||||||
|
@ -91,8 +91,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { deleteWorkspaceEnv, editWorkspaceEnv, getWorkspaceEnvList } from "@/api/workspace";
|
import { deleteWorkspaceEnv, editWorkspaceEnv, getWorkspaceEnvList } from "@/api/workspace";
|
||||||
import { getNodeListByWorkspace } from "@/api/node";
|
import { getNodeListByWorkspace } from "@/api/node";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -55,8 +55,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { deleteWorkspace, editWorkSpace, getWorkSpaceList } from "@/api/workspace";
|
import { deleteWorkspace, editWorkSpace, getWorkSpaceList } from "@/api/workspace";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
import workspaceEnv from "./workspace-env.vue";
|
import workspaceEnv from "./workspace-env.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -155,8 +155,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { closeUserMfa, deleteUser, editUser, getUserList, unlockUser, restUserPwd } from "@/api/user/user";
|
import { closeUserMfa, deleteUser, editUser, getUserList, unlockUser, restUserPwd } from "@/api/user/user";
|
||||||
import { getUserPermissionListAll } from "@/api/user/user-permission";
|
import { getUserPermissionListAll } from "@/api/user/user-permission";
|
||||||
import { parseTime } from "@/utils/time";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -63,9 +63,8 @@ import { getOperationLogList } from "@/api/operation-log";
|
|||||||
import { getMonitorOperateTypeList } from "@/api/monitor";
|
import { getMonitorOperateTypeList } from "@/api/monitor";
|
||||||
import { getNodeListAll } from "@/api/node";
|
import { getNodeListAll } from "@/api/node";
|
||||||
import { getUserListAll } from "@/api/user/user";
|
import { getUserListAll } from "@/api/user/user";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import JsonViewer from "vue-json-viewer";
|
import JsonViewer from "vue-json-viewer";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { JsonViewer },
|
components: { JsonViewer },
|
||||||
|
@ -168,9 +168,8 @@ import { workspaceList } from "@/api/user/user";
|
|||||||
import { getList, editPermissionGroup, deletePermissionGroup } from "@/api/user/user-permission";
|
import { getList, editPermissionGroup, deletePermissionGroup } from "@/api/user/user-permission";
|
||||||
import { getWorkSpaceListAll } from "@/api/workspace";
|
import { getWorkSpaceListAll } from "@/api/workspace";
|
||||||
import { getMonitorOperateTypeList } from "@/api/monitor";
|
import { getMonitorOperateTypeList } from "@/api/monitor";
|
||||||
import { parseTime } from "@/utils/time";
|
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY } from "@/utils/const";
|
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime } from "@/utils/const";
|
||||||
import Transfer from "@/components/compositionTransfer/composition-transfer.vue";
|
import Transfer from "@/components/compositionTransfer/composition-transfer.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -309,3 +309,150 @@ export function randomStr(len = 2) {
|
|||||||
}
|
}
|
||||||
return repliccaId;
|
return repliccaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换时间函数
|
||||||
|
* @param {*} time
|
||||||
|
* @param {*} cFormat
|
||||||
|
*/
|
||||||
|
export function parseTime(time, cFormat) {
|
||||||
|
if (arguments.length === 0) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
if (!time) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
// 处理 time 参数
|
||||||
|
if (isNaN(Number(time)) === false) {
|
||||||
|
time = Number(time);
|
||||||
|
}
|
||||||
|
const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
|
||||||
|
let date;
|
||||||
|
if (typeof time === "object") {
|
||||||
|
date = time;
|
||||||
|
} else {
|
||||||
|
if (("" + time).length === 10) time = parseInt(time) * 1000;
|
||||||
|
date = new Date(time);
|
||||||
|
}
|
||||||
|
const formatObj = {
|
||||||
|
y: date.getFullYear(),
|
||||||
|
m: date.getMonth() + 1,
|
||||||
|
d: date.getDate(),
|
||||||
|
h: date.getHours(),
|
||||||
|
i: date.getMinutes(),
|
||||||
|
s: date.getSeconds(),
|
||||||
|
a: date.getDay(),
|
||||||
|
};
|
||||||
|
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||||
|
let value = formatObj[key];
|
||||||
|
// Note: getDay() returns 0 on Sunday
|
||||||
|
if (key === "a") {
|
||||||
|
return ["日", "一", "二", "三", "四", "五", "六"][value];
|
||||||
|
}
|
||||||
|
if (result.length > 0 && value < 10) {
|
||||||
|
value = "0" + value;
|
||||||
|
}
|
||||||
|
return value || 0;
|
||||||
|
});
|
||||||
|
return time_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化文件大小
|
||||||
|
* @param {*} value
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function renderSize(value, defaultValue = "-") {
|
||||||
|
if (null == value || value == "") {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
var unitArr = new Array("Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
|
||||||
|
var index = 0;
|
||||||
|
var srcsize = parseFloat(value);
|
||||||
|
if (srcsize <= 0) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
// console.log(value, srcsize);
|
||||||
|
index = Math.floor(Math.log(srcsize) / Math.log(1024));
|
||||||
|
var size = srcsize / Math.pow(1024, index);
|
||||||
|
size = size.toFixed(2); //保留的小数位数
|
||||||
|
return size + unitArr[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数组分组 [{id:1,value:1},{id:2,value:3}] => {1:{id:1,value:1},2:{id:2,value:3}}
|
||||||
|
* @param {function} group
|
||||||
|
* @returns Object
|
||||||
|
*/
|
||||||
|
Array.prototype.groupBy = function (group) {
|
||||||
|
return group && typeof group === "function"
|
||||||
|
? Array.prototype.reduce.call(
|
||||||
|
this,
|
||||||
|
function (c, v) {
|
||||||
|
var k = group(v);
|
||||||
|
c[k] = v;
|
||||||
|
return c;
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
: this;
|
||||||
|
};
|
||||||
|
//
|
||||||
|
export function itemGroupBy(arr, groupKey, key, dataKey) {
|
||||||
|
key = key || "type";
|
||||||
|
dataKey = dataKey || "data";
|
||||||
|
|
||||||
|
let newArr = [],
|
||||||
|
types = {},
|
||||||
|
// newItem,
|
||||||
|
i,
|
||||||
|
j,
|
||||||
|
cur;
|
||||||
|
for (i = 0, j = arr.length; i < j; i++) {
|
||||||
|
cur = arr[i];
|
||||||
|
if (!(cur[groupKey] in types)) {
|
||||||
|
types[cur[groupKey]] = { [key]: cur[groupKey], [dataKey]: [] };
|
||||||
|
newArr.push(types[cur[groupKey]]);
|
||||||
|
}
|
||||||
|
types[cur[groupKey]][dataKey].push(cur);
|
||||||
|
}
|
||||||
|
return newArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化时长
|
||||||
|
* @param {String} ms
|
||||||
|
* @param {String} seg 分割符
|
||||||
|
* @param {String} levelCount 格式化个数
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function formatDuration(ms, seg, levelCount) {
|
||||||
|
if (isNaN(new Number(ms))) {
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
seg = seg || "";
|
||||||
|
levelCount = levelCount || 5;
|
||||||
|
if (ms < 0) ms = -ms;
|
||||||
|
const time = {
|
||||||
|
天: Math.floor(ms / 86400000),
|
||||||
|
小时: Math.floor(ms / 3600000) % 24,
|
||||||
|
分钟: Math.floor(ms / 60000) % 60,
|
||||||
|
秒: Math.floor(ms / 1000) % 60,
|
||||||
|
毫秒: Math.floor(ms) % 1000,
|
||||||
|
};
|
||||||
|
return Object.entries(time)
|
||||||
|
.filter((val) => val[1] !== 0)
|
||||||
|
.map(([key, val]) => `${val}${key}`)
|
||||||
|
.splice(0, levelCount)
|
||||||
|
.join(seg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//小数转换为分数(小数先转换成number类型,再乘以100,并且保留2位小数)
|
||||||
|
export function formatPercent(point, keep = 2) {
|
||||||
|
if (null == point) {
|
||||||
|
return "--";
|
||||||
|
}
|
||||||
|
var percent = (Number(point) * 100).toFixed(keep);
|
||||||
|
percent += "%";
|
||||||
|
return percent;
|
||||||
|
}
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
/**
|
|
||||||
* 转换时间函数
|
|
||||||
* @param {*} time
|
|
||||||
* @param {*} cFormat
|
|
||||||
*/
|
|
||||||
export function parseTime(time, cFormat) {
|
|
||||||
if (arguments.length === 0) {
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
if (!time) {
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
// 处理 time 参数
|
|
||||||
if (isNaN(Number(time)) === false) {
|
|
||||||
time = Number(time);
|
|
||||||
}
|
|
||||||
const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
|
|
||||||
let date;
|
|
||||||
if (typeof time === "object") {
|
|
||||||
date = time;
|
|
||||||
} else {
|
|
||||||
if (("" + time).length === 10) time = parseInt(time) * 1000;
|
|
||||||
date = new Date(time);
|
|
||||||
}
|
|
||||||
const formatObj = {
|
|
||||||
y: date.getFullYear(),
|
|
||||||
m: date.getMonth() + 1,
|
|
||||||
d: date.getDate(),
|
|
||||||
h: date.getHours(),
|
|
||||||
i: date.getMinutes(),
|
|
||||||
s: date.getSeconds(),
|
|
||||||
a: date.getDay(),
|
|
||||||
};
|
|
||||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
|
||||||
let value = formatObj[key];
|
|
||||||
// Note: getDay() returns 0 on Sunday
|
|
||||||
if (key === "a") {
|
|
||||||
return ["日", "一", "二", "三", "四", "五", "六"][value];
|
|
||||||
}
|
|
||||||
if (result.length > 0 && value < 10) {
|
|
||||||
value = "0" + value;
|
|
||||||
}
|
|
||||||
return value || 0;
|
|
||||||
});
|
|
||||||
return time_str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化文件大小
|
|
||||||
* @param {*} value
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function renderSize(value, defaultValue = "-") {
|
|
||||||
if (null == value || value == "") {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
var unitArr = new Array("Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
|
|
||||||
var index = 0;
|
|
||||||
var srcsize = parseFloat(value);
|
|
||||||
if (srcsize <= 0) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
// console.log(value, srcsize);
|
|
||||||
index = Math.floor(Math.log(srcsize) / Math.log(1024));
|
|
||||||
var size = srcsize / Math.pow(1024, index);
|
|
||||||
size = size.toFixed(2); //保留的小数位数
|
|
||||||
return size + unitArr[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数组分组 [{id:1,value:1},{id:2,value:3}] => {1:{id:1,value:1},2:{id:2,value:3}}
|
|
||||||
* @param {function} group
|
|
||||||
* @returns Object
|
|
||||||
*/
|
|
||||||
Array.prototype.groupBy = function (group) {
|
|
||||||
return group && typeof group === "function"
|
|
||||||
? Array.prototype.reduce.call(
|
|
||||||
this,
|
|
||||||
function (c, v) {
|
|
||||||
var k = group(v);
|
|
||||||
c[k] = v;
|
|
||||||
return c;
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
)
|
|
||||||
: this;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
export function itemGroupBy(arr, groupKey, key, dataKey) {
|
|
||||||
key = key || "type";
|
|
||||||
dataKey = dataKey || "data";
|
|
||||||
|
|
||||||
let newArr = [],
|
|
||||||
types = {},
|
|
||||||
// newItem,
|
|
||||||
i,
|
|
||||||
j,
|
|
||||||
cur;
|
|
||||||
for (i = 0, j = arr.length; i < j; i++) {
|
|
||||||
cur = arr[i];
|
|
||||||
if (!(cur[groupKey] in types)) {
|
|
||||||
types[cur[groupKey]] = { [key]: cur[groupKey], [dataKey]: [] };
|
|
||||||
newArr.push(types[cur[groupKey]]);
|
|
||||||
}
|
|
||||||
types[cur[groupKey]][dataKey].push(cur);
|
|
||||||
}
|
|
||||||
return newArr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化时长
|
|
||||||
* @param {String} ms
|
|
||||||
* @param {String} seg 分割符
|
|
||||||
* @param {String} levelCount 格式化个数
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function formatDuration(ms, seg, levelCount) {
|
|
||||||
if (isNaN(new Number(ms))) {
|
|
||||||
return ms;
|
|
||||||
}
|
|
||||||
seg = seg || "";
|
|
||||||
levelCount = levelCount || 5;
|
|
||||||
if (ms < 0) ms = -ms;
|
|
||||||
const time = {
|
|
||||||
天: Math.floor(ms / 86400000),
|
|
||||||
小时: Math.floor(ms / 3600000) % 24,
|
|
||||||
分钟: Math.floor(ms / 60000) % 60,
|
|
||||||
秒: Math.floor(ms / 1000) % 60,
|
|
||||||
毫秒: Math.floor(ms) % 1000,
|
|
||||||
};
|
|
||||||
return Object.entries(time)
|
|
||||||
.filter((val) => val[1] !== 0)
|
|
||||||
.map(([key, val]) => `${val}${key}`)
|
|
||||||
.splice(0, levelCount)
|
|
||||||
.join(seg);
|
|
||||||
}
|
|
||||||
|
|
||||||
//小数转换为分数(小数先转换成number类型,再乘以100,并且保留2位小数)
|
|
||||||
export function formatPercent(point, keep = 2) {
|
|
||||||
if (null == point) {
|
|
||||||
return "--";
|
|
||||||
}
|
|
||||||
var percent = (Number(point) * 100).toFixed(keep);
|
|
||||||
percent += "%";
|
|
||||||
return percent;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user