提交 06ee1108 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix code review issues

上级 0465bd86
import {Mutation, Action, ActionContext} from 'vuex'; import {Mutation, Action} from 'vuex';
import { StoreModuleType } from "@/utils/store"; import { StoreModuleType } from "@/utils/store";
import {WebSocket} from "@/services/websocket"; import {WebSocket} from "@/services/websocket";
......
...@@ -12,14 +12,14 @@ export const setExecBy = async (execBy) => { ...@@ -12,14 +12,14 @@ export const setExecBy = async (execBy) => {
} }
export const getInitStatus = async () => { export const getInitStatus = async () => {
return await getCache(settings.initStatus); return getCache(settings.initStatus);
} }
export const setInitStatus = async () => { export const setInitStatus = async () => {
await setCache(settings.initStatus, true); await setCache(settings.initStatus, true);
} }
export const getCurrSiteId = async () => { export const getCurrSiteId = async () => {
return await getCache(settings.currSiteId); return getCache(settings.currSiteId);
} }
export const setCurrSiteId = async (val) => { export const setCurrSiteId = async (val) => {
await setCache(settings.currSiteId, val); await setCache(settings.currSiteId, val);
......
import localforage from 'localforage'; import localforage from 'localforage';
import settings from '@/config/settings';
export const getCache = async (key: string): Promise<any | null> => { export const getCache = async (key: string): Promise<any | null> => {
return localforage.getItem(key); return localforage.getItem(key);
......
...@@ -18,7 +18,6 @@ import { RouteRecordRaw, RouteLocationNormalizedLoaded } from 'vue-router'; ...@@ -18,7 +18,6 @@ import { RouteRecordRaw, RouteLocationNormalizedLoaded } from 'vue-router';
*/ */
export type TabNavType = 'path' | 'querypath'; export type TabNavType = 'path' | 'querypath';
import 'vue-router'
declare module 'vue-router' { declare module 'vue-router' {
/** /**
* 自定义补充扩展 - 路由 - 类型字段 * 自定义补充扩展 - 路由 - 类型字段
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import {computed, defineComponent, PropType, ref, Ref} from "vue"; import {computed, defineComponent, PropType, ref} from "vue";
import {useI18n} from "vue-i18n"; import {useI18n} from "vue-i18n";
import {useStore} from "vuex"; import {useStore} from "vuex";
import {ScriptData} from "@/views/script/store"; import {ScriptData} from "@/views/script/store";
......
...@@ -161,7 +161,6 @@ ...@@ -161,7 +161,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { import {
computed, computed,
defineComponent,
onMounted, onUnmounted, onMounted, onUnmounted,
ref, ref,
watch watch
...@@ -170,7 +169,7 @@ import {useStore} from "vuex"; ...@@ -170,7 +169,7 @@ import {useStore} from "vuex";
import {useI18n} from "vue-i18n"; import {useI18n} from "vue-i18n";
import {ScriptData} from "../store"; import {ScriptData} from "../store";
import {Empty, Modal, notification} from "ant-design-vue"; import {Modal, notification} from "ant-design-vue";
import bus from "@/utils/eventBus"; import bus from "@/utils/eventBus";
import {ZentaoData} from "@/store/zentao"; import {ZentaoData} from "@/store/zentao";
...@@ -198,7 +197,6 @@ import {isWindows} from "@/utils/comm"; ...@@ -198,7 +197,6 @@ import {isWindows} from "@/utils/comm";
import {testToolMap} from "@/utils/testing"; import {testToolMap} from "@/utils/testing";
import {ExecStatus} from "@/store/exec"; import {ExecStatus} from "@/store/exec";
import debounce from "lodash.debounce"; import debounce from "lodash.debounce";
import throttle from "lodash.debounce";
import TreeContextMenu from "./treeContextMenu.vue" import TreeContextMenu from "./treeContextMenu.vue"
import {ZentaoCasePrefix} from "@/utils/const"; import {ZentaoCasePrefix} from "@/utils/const";
...@@ -495,7 +493,7 @@ import {isInArray} from "@/utils/array"; ...@@ -495,7 +493,7 @@ import {isInArray} from "@/utils/array";
const nameFormVisible = ref(false) const nameFormVisible = ref(false)
const treeDataMap = {} const treeDataMap = {}
const getNodeMapCall = throttle(async () => { const getNodeMapCall = debounce(async () => {
getNodeMap(treeData.value[0], treeDataMap) getNodeMap(treeData.value[0], treeDataMap)
}, 300) }, 300)
......
...@@ -20,15 +20,13 @@ import { ...@@ -20,15 +20,13 @@ import {
computed, computed,
defineComponent, defineComponent,
onMounted, onMounted,
ref,
watch
} from "vue"; } from "vue";
import {useStore} from "vuex"; import {useStore} from "vuex";
import {useI18n} from "vue-i18n"; import {useI18n} from "vue-i18n";
import {ScriptData} from "./store"; import {ScriptData} from "./store";
import {resizeWidth, resizeHeight} from "@/utils/dom"; import {resizeWidth} from "@/utils/dom";
import {Empty, notification} from "ant-design-vue"; import {Empty} from "ant-design-vue";
import {ZentaoData} from "@/store/zentao"; import {ZentaoData} from "@/store/zentao";
......
...@@ -218,27 +218,22 @@ export const getFileNodesUnderParent = (node): string[] => { ...@@ -218,27 +218,22 @@ export const getFileNodesUnderParent = (node): string[] => {
getNodeMap(node, nodeMap) getNodeMap(node, nodeMap)
const arr = [] as string[] const arr = [] as string[]
Object.keys(nodeMap).forEach((k, v) => { Object.keys(nodeMap).forEach((k, _v) => {
const node = nodeMap[k] const item = nodeMap[k]
if (node.type === 'file') { if (item.type === 'file') {
node.childrem = null item.childrem = null
arr.push(node) arr.push(item)
} }
}) })
return arr return arr
} }
export function getSyncToInfoFromMenu(key: string, node: any): any {
return
}
export function scriptTreeAddAttr(treeData) { export function scriptTreeAddAttr(treeData) {
if(treeData == undefined){ if(treeData == undefined){
return treeData; return treeData;
} }
treeData = treeData.map((item, index) => { treeData = treeData.map((item) => {
item.id = item.path; item.id = item.path;
item.checkable = item.workspaceType == 'ztf' ? true : false; item.checkable = item.workspaceType == 'ztf' ? true : false;
if (item.isLeaf) { if (item.isLeaf) {
......
...@@ -107,7 +107,7 @@ const StoreModel: ModuleType = { ...@@ -107,7 +107,7 @@ const StoreModel: ModuleType = {
commit('setQueryParams', playload); commit('setQueryParams', playload);
return true; return true;
}, },
async loadChildren({ commit }, treeNode: any ) { async loadChildren(_ctx, treeNode: any ) {
console.log('load node children', treeNode.dataRef.workspaceType) console.log('load node children', treeNode.dataRef.workspaceType)
if (treeNode.dataRef.workspaceType === 'ztf') if (treeNode.dataRef.workspaceType === 'ztf')
return true return true
...@@ -118,19 +118,16 @@ const StoreModel: ModuleType = { ...@@ -118,19 +118,16 @@ const StoreModel: ModuleType = {
}) })
}, },
async getScript({ commit, dispatch }, script: any ) { async getScript({ commit}, script: any ) {
if (!script || script.type !== 'file') { if (!script || script.type !== 'file') {
commit('setItem', null); commit('setItem', null);
return true; } else if (script.path.indexOf('zentao-') === 0) {
}
if (script.path.indexOf('zentao-') === 0) {
commit('setItem', {id: script.caseId, workspaceId: script.workspaceId, code: ScriptFileNotExist}); commit('setItem', {id: script.caseId, workspaceId: script.workspaceId, code: ScriptFileNotExist});
return true; } else {
const response: ResponseData = await get(script.path, script.workspaceId);
commit('setItem', response.data);
} }
const response: ResponseData = await get(script.path, script.workspaceId);
commit('setItem', response.data);
return true; return true;
}, },
...@@ -150,7 +147,7 @@ const StoreModel: ModuleType = { ...@@ -150,7 +147,7 @@ const StoreModel: ModuleType = {
return resp return resp
}, },
async syncToZentao({ commit, dispatch, state }, payload: any ) { async syncToZentao({ dispatch, state }, payload: any ) {
const resp = await syncToZentao(payload) const resp = await syncToZentao(payload)
if (resp.code === 0) { if (resp.code === 0) {
...@@ -170,7 +167,7 @@ const StoreModel: ModuleType = { ...@@ -170,7 +167,7 @@ const StoreModel: ModuleType = {
return data.done return data.done
}, },
async createScript({ commit , dispatch, state}, payload: any) { async createScript({ dispatch, state}, payload: any) {
try { try {
const jsn = await create(payload); const jsn = await create(payload);
const path = jsn.data const path = jsn.data
...@@ -182,7 +179,7 @@ const StoreModel: ModuleType = { ...@@ -182,7 +179,7 @@ const StoreModel: ModuleType = {
return '' return ''
} }
}, },
async updateScript({ commit }, payload: any ) { async updateScript(_ctx, payload: any ) {
try { try {
const { id, ...params } = payload; const { id, ...params } = payload;
await update(id, { ...params }); await update(id, { ...params });
...@@ -192,7 +189,7 @@ const StoreModel: ModuleType = { ...@@ -192,7 +189,7 @@ const StoreModel: ModuleType = {
} }
}, },
async updateCode({ commit, dispatch, state }, payload: any ) { async updateCode({ dispatch, state }, payload: any ) {
try { try {
await updateCode(payload); await updateCode(payload);
await dispatch('listScript', state.queryParams) await dispatch('listScript', state.queryParams)
...@@ -202,7 +199,7 @@ const StoreModel: ModuleType = { ...@@ -202,7 +199,7 @@ const StoreModel: ModuleType = {
} }
}, },
async pasteScript({ commit , dispatch, state}, data: any ) { async pasteScript({ dispatch, state}, data: any ) {
try { try {
await paste(data); await paste(data);
await dispatch('listScript', state.queryParams) await dispatch('listScript', state.queryParams)
...@@ -213,7 +210,7 @@ const StoreModel: ModuleType = { ...@@ -213,7 +210,7 @@ const StoreModel: ModuleType = {
} }
}, },
async moveScript({ commit , dispatch, state}, data: any ) { async moveScript({ dispatch, state}, data: any ) {
try { try {
await move(data); await move(data);
await dispatch('listScript', state.queryParams) await dispatch('listScript', state.queryParams)
...@@ -224,7 +221,7 @@ const StoreModel: ModuleType = { ...@@ -224,7 +221,7 @@ const StoreModel: ModuleType = {
} }
}, },
async deleteScript({ commit , dispatch, state}, path: string ) { async deleteScript({ dispatch, state}, path: string ) {
try { try {
await remove(path); await remove(path);
await dispatch('listScript', state.queryParams) await dispatch('listScript', state.queryParams)
......
...@@ -76,7 +76,7 @@ const StoreModel: ModuleType = { ...@@ -76,7 +76,7 @@ const StoreModel: ModuleType = {
commit('setDetailResult',data); commit('setDetailResult',data);
return true; return true;
}, },
async save({ commit }, payload) { async save(_ctx, payload) {
try { try {
await save(payload); await save(payload);
return true; return true;
...@@ -84,7 +84,7 @@ const StoreModel: ModuleType = { ...@@ -84,7 +84,7 @@ const StoreModel: ModuleType = {
return false; return false;
} }
}, },
async delete({ commit , dispatch, state}, id: number ) { async delete({ dispatch, state}, id: number ) {
try { try {
await remove(id); await remove(id);
dispatch('list', {}) dispatch('list', {})
......
...@@ -97,7 +97,7 @@ const StoreModel: ModuleType = { ...@@ -97,7 +97,7 @@ const StoreModel: ModuleType = {
commit('setDetailResult',data); commit('setDetailResult',data);
return true; return true;
}, },
async save({ commit }, payload) { async save(_ctx, payload) {
try { try {
await save(payload); await save(payload);
return true; return true;
...@@ -105,7 +105,7 @@ const StoreModel: ModuleType = { ...@@ -105,7 +105,7 @@ const StoreModel: ModuleType = {
return false; return false;
} }
}, },
async delete({ commit , dispatch, state}, id: number ) { async delete({ dispatch}, id: number ) {
try { try {
await remove(id); await remove(id);
dispatch('list', {}) dispatch('list', {})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册