fix: 添加产品物模型规则TS,添加 tcp粘拆包TS
* fix: bug#17584 * fix: bug#17605、规则属性脚本提示语 * fix: 系统管理菜单管理 * fix: tcp粘拆包TS * fix: 产品物模型规则TS
This commit is contained in:
parent
1a905ddc90
commit
6274b1f01d
|
@ -617,3 +617,17 @@ export const queryByParent = (deviceId: string) => server.get(`/device/gateway/$
|
|||
|
||||
export const queryCodeTips = (productId: string, deviceId: string) => server.get(`/device/transparent-codec/${productId}/${deviceId}.d.ts`)
|
||||
export const queryProductCodeTips = (productId: string) => server.get(`/device/transparent-codec/${productId}.d.ts`)
|
||||
|
||||
/**
|
||||
* 获取设备物模型规则TS
|
||||
* @param deviceId 设备ID
|
||||
* @returns
|
||||
*/
|
||||
export const queryTypescript = (deviceId:string) => server.get(`/device/${deviceId}/virtual-property.d.ts`)
|
||||
|
||||
/**
|
||||
* 获取产品物模型规则TS
|
||||
* @param productId 产品ID
|
||||
* @returns
|
||||
*/
|
||||
export const queryProductTs = (productId:string) => server.get(`/product/${productId}/virtual-property.d.ts`)
|
|
@ -36,3 +36,8 @@ export const save = (data: Object) => server.post(`/network/config`, data);
|
|||
export const update = (data: Object) => server.patch(`/network/config`, data);
|
||||
|
||||
export const detail = (id: string) => server.get(`/network/config/${id}`);
|
||||
|
||||
/**
|
||||
* 获取TCP粘拆包TS资源
|
||||
*/
|
||||
export const getTs = () => server.get('/system/resources/ScriptPayloadParser.d.ts')
|
||||
|
|
|
@ -29,19 +29,28 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="editor">
|
||||
<j-monaco-editor v-if="loading" v-model:model-value="_value" theme="vs" ref="editor" language="javascript"/>
|
||||
<j-monaco-editor v-if="loading" v-model:model-value="_value" theme="vs" ref="editor" language="javascript" :registrationTypescript="typescriptTip"
|
||||
:init="editorInit"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts" name="Editor">
|
||||
|
||||
import {
|
||||
queryTypescript,
|
||||
queryProductTs
|
||||
} from '@/api/device/instance';
|
||||
import { useInstanceStore } from '@/store/instance';
|
||||
import { useProductStore } from '@/store/product';
|
||||
import { inject } from 'vue'
|
||||
interface Props {
|
||||
mode?: 'advance' | 'simple';
|
||||
id?: string;
|
||||
value?: string;
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const target = inject('target')
|
||||
const instanceStore = useInstanceStore()
|
||||
const productStore = useProductStore()
|
||||
interface Emits {
|
||||
(e: 'change', data: string): void;
|
||||
(e: 'update:value', data: string): void;
|
||||
|
@ -58,6 +67,56 @@ type SymbolType = {
|
|||
key: string,
|
||||
value: string
|
||||
}
|
||||
|
||||
const typescriptTip = reactive({
|
||||
typescript: ''
|
||||
})
|
||||
|
||||
const queryCode = () => {
|
||||
let id = ''
|
||||
if(target==='device'){
|
||||
id = instanceStore.current.id
|
||||
queryTypescript(id).then(res => {
|
||||
if (res.status===200) {
|
||||
typescriptTip.typescript = res.result
|
||||
}
|
||||
})
|
||||
}else if(target ==='product'){
|
||||
id = productStore.current.id
|
||||
queryProductTs(id).then(res => {
|
||||
if (res.status===200) {
|
||||
typescriptTip.typescript = res.result
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
queryCode()
|
||||
|
||||
const editorInit = (editor: any, monaco: any) => {
|
||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||
noSemanticValidation: true,
|
||||
noSyntaxValidation: false,
|
||||
});
|
||||
|
||||
// compiler options
|
||||
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||
allowJs: true,
|
||||
checkJs: true,
|
||||
allowNonTsExtensions: true,
|
||||
target: monaco.languages.typescript.ScriptTarget.ESNext,
|
||||
strictNullChecks: false,
|
||||
strictPropertyInitialization: true,
|
||||
strictFunctionTypes: true,
|
||||
strictBindCallApply: true,
|
||||
useDefineForClassFields: true,//permit class static fields with private name to have initializer
|
||||
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
||||
module: monaco.languages.typescript.ModuleKind.CommonJS,
|
||||
typeRoots: ["types"],
|
||||
lib: ["esnext"]
|
||||
});
|
||||
}
|
||||
|
||||
const symbolList = [
|
||||
{
|
||||
key: 'add',
|
||||
|
|
|
@ -50,6 +50,7 @@ export const SystemConst = {
|
|||
|
||||
export const USER_CENTER_MENU_CODE = 'account-center'
|
||||
export const USER_CENTER_MENU_BUTTON_CODE = 'user-center-passwd-update'
|
||||
export const messageSubscribe = 'message-subscribe'
|
||||
|
||||
/**协议列表 */
|
||||
export const protocolList = [
|
||||
|
|
|
@ -177,7 +177,7 @@ const checkChange = (e: any) => { // 全选
|
|||
const keys = deviceList.value.filter(item => {
|
||||
// 过滤已选中和已绑定
|
||||
const type = !checkKeys.value.includes(item.id) && !disabledKeys.value.includes(item.id)
|
||||
if (type && checkCache.value.has(item.id)) {
|
||||
if (type && !checkCache.value.has(item.id)) {
|
||||
checkCache.value.set(item.id, item)
|
||||
}
|
||||
return type
|
||||
|
|
|
@ -99,6 +99,7 @@ import { useInstanceStore } from '@/store/instance';
|
|||
import { resetRule } from '@/api/device/instance';
|
||||
import { updata } from '@/api/rule-engine/configuration';
|
||||
import { onlyMessage } from '@/utils/comm';
|
||||
import { provide } from 'vue';
|
||||
const instanceStore = useInstanceStore();
|
||||
const PropertySource: { label: string; value: string }[] = isNoCommunity
|
||||
? [
|
||||
|
@ -156,7 +157,7 @@ const props = defineProps({
|
|||
default: []
|
||||
}
|
||||
});
|
||||
|
||||
provide('target',props.target)
|
||||
const emit = defineEmits<Emit>();
|
||||
const formItemContext = Form.useInjectFormItemContext();
|
||||
|
||||
|
|
|
@ -903,6 +903,8 @@
|
|||
.script
|
||||
"
|
||||
language="javascript"
|
||||
:init="editorInit"
|
||||
:registrationTypescript="typescriptTip"
|
||||
/>
|
||||
</div>
|
||||
</j-form-item>
|
||||
|
@ -1127,6 +1129,7 @@ import {
|
|||
start,
|
||||
resourceClusters,
|
||||
resourceClustersById,
|
||||
getTs
|
||||
} from '@/api/link/type';
|
||||
import {
|
||||
ParserConfiguration,
|
||||
|
@ -1172,6 +1175,34 @@ const portOptionsIndex: any = ref([]);
|
|||
const certIdOptions = ref([]);
|
||||
const configClustersList = ref<any[]>([]);
|
||||
|
||||
const typescriptTip = reactive({
|
||||
typescript: ''
|
||||
})
|
||||
|
||||
const editorInit = (editor: any, monaco: any) => {
|
||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||
noSemanticValidation: true,
|
||||
noSyntaxValidation: false,
|
||||
});
|
||||
|
||||
// compiler options
|
||||
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||
allowJs: true,
|
||||
checkJs: true,
|
||||
allowNonTsExtensions: true,
|
||||
target: monaco.languages.typescript.ScriptTarget.ESNext,
|
||||
strictNullChecks: false,
|
||||
strictPropertyInitialization: true,
|
||||
strictFunctionTypes: true,
|
||||
strictBindCallApply: true,
|
||||
useDefineForClassFields: true,//permit class static fields with private name to have initializer
|
||||
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
||||
module: monaco.languages.typescript.ModuleKind.CommonJS,
|
||||
typeRoots: ["types"],
|
||||
lib: ["esnext"]
|
||||
});
|
||||
}
|
||||
|
||||
const dynamicValidateForm = reactive<{ cluster: FormData2Type[] }>({
|
||||
cluster: [{ ...cloneDeep(FormStates2), id: '1' }],
|
||||
});
|
||||
|
@ -1250,6 +1281,13 @@ const changeType = (value: string) => {
|
|||
const { configuration } = dynamicValidateForm.cluster[0];
|
||||
value && (configuration.host = '0.0.0.0');
|
||||
}
|
||||
if(value ==='TCP_SERVER'){
|
||||
getTs().then((res:any)=>{
|
||||
if (res.status===200) {
|
||||
typescriptTip.typescript = res.result
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const updateClustersListIndex = () => {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
:columns="searchColumns"
|
||||
target="category-bind-modal"
|
||||
@search="search"
|
||||
style="width: 75%;"
|
||||
style="width: 75%; margin-bottom: 0;"
|
||||
/>
|
||||
</template>
|
||||
<template #card="slotProps">
|
||||
|
|
|
@ -79,6 +79,7 @@ import { cloneDeep } from 'lodash';
|
|||
import { onlyMessage } from '@/utils/comm';
|
||||
import {
|
||||
USER_CENTER_MENU_CODE,
|
||||
messageSubscribe
|
||||
} from '@/utils/consts';
|
||||
import { protocolList } from '@/utils/consts';
|
||||
import { getProviders } from '@/api/data-collect/channel';
|
||||
|
@ -199,7 +200,7 @@ const onDragend = (info: AntTreeNodeDropEvent) => {
|
|||
onMounted(() => {
|
||||
getSystemPermission_api().then((resp: any) => {
|
||||
const filterBaseMenu = BaseMenu.filter(item => ![
|
||||
USER_CENTER_MENU_CODE,
|
||||
USER_CENTER_MENU_CODE,messageSubscribe
|
||||
].includes(item.code))
|
||||
baseMenu.value = filterMenu(
|
||||
resp.result.map((item: any) => JSON.parse(item).id),
|
||||
|
@ -210,7 +211,7 @@ onMounted(() => {
|
|||
systemMenu.value = resp.result?.filter(
|
||||
(item: { code: string }) =>
|
||||
![
|
||||
USER_CENTER_MENU_CODE
|
||||
USER_CENTER_MENU_CODE,messageSubscribe
|
||||
].includes(item.code),
|
||||
);
|
||||
//初始化菜单
|
||||
|
@ -219,12 +220,12 @@ onMounted(() => {
|
|||
selectedKeys.value = systemMenuData.checkedKeys;
|
||||
|
||||
const AllMenu = filterMenus(mergeArr(
|
||||
cloneDeep(filterBaseMenu),
|
||||
cloneDeep(baseMenu.value),
|
||||
cloneDeep(systemMenu.value),
|
||||
))
|
||||
console.log(AllMenu);
|
||||
// 处理排序
|
||||
treeData.value = handleSortsArr(AllMenu);
|
||||
treeData.value = handleSortsArr(systemMenu.value);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -83,7 +83,7 @@ import PermissionButton from '@/components/PermissionButton/index.vue';
|
|||
import { getMenuTree_api, delMenuInfo_api } from '@/api/system/menu';
|
||||
import dayjs from 'dayjs';
|
||||
import { useUserInfo } from '@/store/userInfo';
|
||||
import { USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||
import { USER_CENTER_MENU_CODE,messageSubscribe } from '@/utils/consts'
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onlyMessage } from '@/utils/comm';
|
||||
|
||||
|
@ -212,7 +212,7 @@ const table = reactive({
|
|||
return {
|
||||
code: resp.message,
|
||||
result: {
|
||||
data: resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE].includes(item.code)),
|
||||
data: resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE,messageSubscribe].includes(item.code)),
|
||||
pageIndex: resp.pageIndex,
|
||||
pageSize: resp.pageSize,
|
||||
total: resp.total,
|
||||
|
|
Loading…
Reference in New Issue