Browse Source

优化配置,增加单独配置 端口服务的功能

yanglzh 2 months ago
parent
commit
c3d4b305a3

+ 2 - 2
.env.development

@@ -5,7 +5,7 @@ VITE_NGINX_PROXY = ''
 VITE_SERVER_ORIGIN = 'http://127.0.0.1:8199'
 
 # 规则引擎服务地址
-VITE_RULE_SERVER_URL = 'http://127.0.0.1:9090'
+VITE_RULE_SERVER_URL = ':9090'
 
 # 流媒体服务地址
-VITE_MEDIA_SERVER_URL = 'http://127.0.0.1:8080'
+VITE_MEDIA_SERVER_URL = ':8080'

+ 2 - 2
.env.golocal

@@ -6,5 +6,5 @@ VITE_ROUTER_MODE = 'hash'
 
 VITE_SERVER_ORIGIN = ''
 
-VITE_RULE_SERVER_URL = 'http://127.0.0.1:9090'
-VITE_MEDIA_SERVER_URL = 'http://127.0.0.1:8080'
+VITE_RULE_SERVER_URL = ':9090'
+VITE_MEDIA_SERVER_URL = ':8080'

+ 12 - 3
src/utils/origin.ts

@@ -1,5 +1,5 @@
 export default function getOrigin(urlStr: string = '', type: string = 'http') {
-  const origin = import.meta.env.VITE_SERVER_ORIGIN
+  const origin = import.meta.env.VITE_SERVER_ORIGIN 
   const nginxProxy = import.meta.env.VITE_NGINX_PROXY
   const suffixUrl = import.meta.env.VITE_API_SUFFIX_URL
   const url = nginxProxy + suffixUrl + urlStr
@@ -35,8 +35,7 @@ export function getOtherServersOrigin(urlStr: string = '') {
 
 // 规则引擎
 export function getRuleServerOrigin(urlStr: string = '') {
-  const origin = import.meta.env.VITE_SERVER_ORIGIN || window.location.origin
-  return origin + urlStr
+  return getOnlyPartOrigin(import.meta.env.VITE_RULE_SERVER_URL) + urlStr
 }
 
 // 流媒体服务
@@ -45,6 +44,8 @@ export function getMediaOrigin(urlStr: string = '') {
   const VITE_MEDIA_SERVER_URL = import.meta.env.VITE_MEDIA_SERVER_URL
   if (VITE_MEDIA_SERVER_URL.startsWith('http')) {
     return VITE_MEDIA_SERVER_URL + urlStr
+  } else if (VITE_MEDIA_SERVER_URL.startsWith(':')) {
+    return getOnlyPartOrigin(VITE_MEDIA_SERVER_URL) + urlStr
   } else {
     return origin + VITE_MEDIA_SERVER_URL + urlStr
   }
@@ -54,4 +55,12 @@ export function getSSEOrigin(urlStr: string = '') {
   const origin = import.meta.env.VITE_SERVER_ORIGIN || window.location.origin
   const nginxProxy = import.meta.env.VITE_NGINX_PROXY
   return origin + nginxProxy + urlStr
+}
+
+export function getOnlyPartOrigin(baseUrl: string = '') {
+  // 兼容只有端口号不一样的情况
+  if (baseUrl?.startsWith(':')) {
+    return window.location.protocol + '//' + window.location.hostname + baseUrl
+  }
+  return baseUrl || window.location.origin
 }

+ 4 - 3
src/views/iot/rule-engine/edit.vue

@@ -32,6 +32,7 @@ import { ruleRequired } from "/@/utils/validator";
 import { ElMessage } from "element-plus";
 import { getToken } from "/@/utils/auth";
 import { v4 as uuid } from "uuid";
+import { getRuleServerOrigin } from "/@/utils/origin";
 
 const emit = defineEmits(["getList"]);
 
@@ -76,7 +77,7 @@ const onSubmit = async () => {
     if (!formData.id) {
       const id = uuid();
       await axios.post(
-        import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + id,
+        getRuleServerOrigin("/api/v1/rules/" + id),
         {
           ruleChain: {
             id: id,
@@ -100,7 +101,7 @@ const onSubmit = async () => {
       formData.flowId = id;
     } else {
       // 找到规则
-      const { data } = (await axios.get(import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + formData.flowId, { headers }).catch(() => {
+      const { data } = (await axios.get(getRuleServerOrigin("/api/v1/rules/" + formData.flowId), { headers }).catch(() => {
         ElMessage.error("规则不存在");
       })) as any;
 
@@ -109,7 +110,7 @@ const onSubmit = async () => {
       data.ruleChain.additionalInfo.description = formData.expound;
 
       // 保存
-      await axios.post(import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + formData.flowId, data, { headers });
+      await axios.post(getRuleServerOrigin("/api/v1/rules/" + formData.flowId), data, { headers });
     }
   } else if (props.model === "node-red") {
     if (!formData.id) {

+ 24 - 20
src/views/iot/rule-engine/index.vue

@@ -6,18 +6,17 @@
           <el-input v-model="searchParams.keyWord" placeholder="请输入关键字" clearable @keyup.enter="handleSearch" />
         </el-form-item>
         <el-form-item label="类型">
-          <el-select v-model="searchParams.types" placeholder="请选择类型" clearable @clear="() => searchParams.types = -1" @change="handleSearch">
+          <el-select v-model="searchParams.types" placeholder="请选择类型" clearable @clear="() => (searchParams.types = -1)" @change="handleSearch">
             <el-option label="主链" :value="1" />
             <el-option label="子链" :value="2" />
             <el-option label="全部" :value="-1" />
           </el-select>
         </el-form-item>
         <el-form-item label="状态">
-          <el-select v-model="searchParams.status" placeholder="请选择状态" clearable @clear="() => searchParams.status = -1" @change="handleSearch">
+          <el-select v-model="searchParams.status" placeholder="请选择状态" clearable @clear="() => (searchParams.status = -1)" @change="handleSearch">
             <el-option label="已启动" :value="1" />
             <el-option label="已停止" :value="0" />
             <el-option label="全部" :value="-1" />
-
           </el-select>
         </el-form-item>
         <el-form-item>
@@ -80,6 +79,7 @@ import { useSearch } from "/@/hooks/useCommon";
 import EditForm from "./edit.vue";
 import axios from "axios";
 import { getToken } from "/@/utils/auth";
+import { getRuleServerOrigin } from "/@/utils/origin";
 
 const editFormRef = ref();
 
@@ -87,28 +87,32 @@ const editFormRef = ref();
 const model: "node-red" | "sagoo-rule" = import.meta.env.VITE_RULE_MODEL;
 
 const searchParams = reactive({
-  keyWord: '',
+  keyWord: "",
   types: -1,
-  status: -1
+  status: -1,
 });
 
 // 监听搜索参数变化,确保在API请求中正确传递搜索条件
-watch(searchParams, (newVal: any) => {
-  // 处理搜索参数的值
-  for (const key in newVal) {
-    if (newVal[key] === '' || newVal[key] === null) {
-      // 如果是类型或状态字段,在清除时设置为-1(全部)
-      if (key === 'types' || key === 'status') {
-        params[key] = -1;
-        searchParams[key] = -1; // 同步更新searchParams
+watch(
+  searchParams,
+  (newVal: any) => {
+    // 处理搜索参数的值
+    for (const key in newVal) {
+      if (newVal[key] === "" || newVal[key] === null) {
+        // 如果是类型或状态字段,在清除时设置为-1(全部)
+        if (key === "types" || key === "status") {
+          params[key] = -1;
+          searchParams[key] = -1; // 同步更新searchParams
+        } else {
+          delete params[key];
+        }
       } else {
-        delete params[key];
+        params[key] = newVal[key];
       }
-    } else {
-      params[key] = newVal[key];
     }
-  }
-}, { deep: true });
+  },
+  { deep: true }
+);
 
 const { params, tableData, getList, loading } = useSearch<any[]>(api.getList, "Data", searchParams);
 
@@ -148,7 +152,7 @@ const addOrEdit = async (row?: any) => {
 const setStatus = async (row: any, status: number) => {
   if (model === "sagoo-rule") {
     axios
-      .get(`${import.meta.env.VITE_RULE_SERVER_URL}/api/v1/rule/${row.flowId}/${status ? "enable" : "stop"}`, { headers })
+      .get(getRuleServerOrigin(`/api/v1/rule/${row.flowId}/${status ? "enable" : "stop"}`), { headers })
       .then(() => {
         api
           .setStatus(row.id, status)
@@ -209,7 +213,7 @@ const onDel = (row: any) => {
     type: "warning",
   }).then(async () => {
     if (model == "sagoo-rule") {
-      await axios.delete(import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + row.flowId, { headers }).catch(() => {
+      await axios.delete(getRuleServerOrigin("/api/v1/rules/" + row.flowId), { headers }).catch(() => {
         ElMessage.error("规则不存在");
       });
     } else if (model == "node-red") {

+ 161 - 168
src/views/modules/policy/index/components/addItem.vue

@@ -1,13 +1,7 @@
 <template>
   <el-dialog :title="ruleForm.id ? '修改控制策略' : '添加控制策略'" v-model="isShowDialog" width="650px">
-    <el-form
-      ref="ruleFormRef"
-      :model="ruleForm"
-      :rules="rules"
-      label-width="auto"
-      status-icon
-    >
-      <el-form-item label="标题" prop="title" style="width: 388px;">
+    <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto" status-icon>
+      <el-form-item label="标题" prop="title" style="width: 388px">
         <el-input clearable v-model="ruleForm.title" />
       </el-form-item>
       <el-form-item label="类型" prop="types">
@@ -22,20 +16,20 @@
           <el-radio :label="2">禁用</el-radio>
         </el-radio-group>
       </el-form-item>
-      <el-form-item label="说明" style="width: 388px;">
-        <el-input  v-model="ruleForm.description" type="textarea" />
+      <el-form-item label="说明" style="width: 388px">
+        <el-input v-model="ruleForm.description" type="textarea" />
       </el-form-item>
       <el-form-item label="参数配置" prop="param">
-        <div style="width: 100%;">
+        <div style="width: 100%">
           <div class="param-wrap" v-for="(item, index) in ruleForm.param" :key="index">
-            <el-input  clearable placeholder="key" v-model="item.key" />
+            <el-input clearable placeholder="key" v-model="item.key" />
             <el-input clearable placeholder="标题" v-model="item.title" />
             <el-select v-model="item.types" placeholder="请选择数据类型">
-							<el-option-group v-for="group in typeData" :key="group.label" :label="group.label">
-								<el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type" />
-							</el-option-group>
-						</el-select>
-            <el-button v-if="index === ruleForm.param.length -1" @click="plusParam()">
+              <el-option-group v-for="group in typeData" :key="group.label" :label="group.label">
+                <el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type" />
+              </el-option-group>
+            </el-select>
+            <el-button v-if="index === ruleForm.param.length - 1" @click="plusParam()">
               <el-icon>
                 <ele-Plus />
               </el-icon>
@@ -56,145 +50,146 @@
 </template>
 
 <script lang="ts" setup>
-import { ref } from 'vue'
-import api from '/@/api/device';
-import policyApi from '/@/api/modules/policy';
-import axios from 'axios';
-import { ElMessage } from 'element-plus';
-import type { FormInstance } from 'element-plus'
+import { ref } from "vue";
+import api from "/@/api/device";
+import policyApi from "/@/api/modules/policy";
+import axios from "axios";
+import { ElMessage } from "element-plus";
+import type { FormInstance } from "element-plus";
 import { getToken } from "/@/utils/auth";
 import { v4 as uuid } from "uuid";
+import { getRuleServerOrigin } from "/@/utils/origin";
 
 interface RuleForm {
-  id: any
-  title: string
-  types: number
-  status: number
-  description: string,
-  param: any[],
-  flowId: string,
+  id: any;
+  title: string;
+  types: number;
+  status: number;
+  description: string;
+  param: any[];
+  flowId: string;
 }
 
-const emit = defineEmits(['getList']);
+const emit = defineEmits(["getList"]);
 
 const headers = {
-	Authorization: 'Bearer ' + getToken(),
+  Authorization: "Bearer " + getToken(),
 };
 const isShowDialog = ref(false);
-const ruleFormRef = ref<FormInstance>()
+const ruleFormRef = ref<FormInstance>();
 const ruleForm = ref<RuleForm>({
   id: null,
-  title: '',
+  title: "",
   types: 2,
   status: 1,
-  description: '',
-  param: [ {
-    key: "",
-    title: "",
-    types: ""
-  }],
-  flowId: ''
-})
+  description: "",
+  param: [
+    {
+      key: "",
+      title: "",
+      types: "",
+    },
+  ],
+  flowId: "",
+});
 
 // 数据类型下拉数据
 const typeData = ref([]);
 const validateParam = (rule: any, value: any, callback: any) => {
-  if (value === '') {
-    callback(new Error('请输入参数配置'))
+  if (value === "") {
+    callback(new Error("请输入参数配置"));
   } else if (value) {
-    verification(value).then(() => {
-      callback()
-    })
-    .catch((e:string) => {
-      callback(new Error(e))
-    })
+    verification(value)
+      .then(() => {
+        callback();
+      })
+      .catch((e: string) => {
+        callback(new Error(e));
+      });
   } else {
-    callback()
+    callback();
   }
-}
+};
 
-const verification = (data:any) => {
-  return new Promise(function(resolve, reject) {
+const verification = (data: any) => {
+  return new Promise(function (resolve, reject) {
     try {
-      data.forEach((item:any, indexs:number) => {
+      data.forEach((item: any, indexs: number) => {
         if (!item.key && !item.title && !item.types) {
-          throw '参数配置未完善,请进行完善'
+          throw "参数配置未完善,请进行完善";
         }
         if (!item.key) {
-          throw '第' + (indexs + 1) + '个参数配置的key未完善,请进行完善'
+          throw "第" + (indexs + 1) + "个参数配置的key未完善,请进行完善";
         } else if (!item.title) {
-          throw '第' + (indexs + 1) + '个参数配置的标题未完善,请进行完善'
+          throw "第" + (indexs + 1) + "个参数配置的标题未完善,请进行完善";
         } else if (!item.types) {
-          throw '第' + (indexs + 1) + '个参数配置的数据类型未完善,请进行完善'
+          throw "第" + (indexs + 1) + "个参数配置的数据类型未完善,请进行完善";
         }
-
-      })
+      });
     } catch (e) {
-      return reject(e)
+      return reject(e);
     }
-    resolve('成功')
-  })
-}
+    resolve("成功");
+  });
+};
 
 const rules = ref({
-  title: [
-    { required: true, message: '请输入标题', trigger: 'blur' },
-  ],
+  title: [{ required: true, message: "请输入标题", trigger: "blur" }],
   types: [
     {
       required: true,
-      message: '请输入说明',
-      trigger: 'change',
+      message: "请输入说明",
+      trigger: "change",
     },
   ],
-  status: [
-    { required: true, message: '请选择状态', trigger: 'blur' },
-  ],
-  param: [{ required: true, validator: validateParam, trigger: 'change' }],
-})
+  status: [{ required: true, message: "请选择状态", trigger: "blur" }],
+  param: [{ required: true, validator: validateParam, trigger: "change" }],
+});
 
 const onSubmit = async (formEl: FormInstance | undefined) => {
-  if (!formEl) return
+  if (!formEl) return;
   await formEl.validate();
   if (!ruleForm.value.id) {
-      const id = uuid();
-      await axios.post(
-        import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + id,
-        {
-          ruleChain: {
-            id: id,
-            name: ruleForm.value.title,
-            root: true,
-            additionalInfo: {
-              description: ruleForm.value.description,
-              layoutX: "130",
-              layoutY: "220",
-            },
+    const id = uuid();
+    await axios.post(
+      getRuleServerOrigin("/api/v1/rules/" + id),
+      {
+        ruleChain: {
+          id: id,
+          name: ruleForm.value.title,
+          root: true,
+          additionalInfo: {
+            description: ruleForm.value.description,
+            layoutX: "130",
+            layoutY: "220",
           },
-          metadata: {
-            nodes: [{
-              "id": "node_2",
-              "additionalInfo": {
-                "layoutX": 606,
-                "layoutY": 424
+        },
+        metadata: {
+          nodes: [
+            {
+              id: "node_2",
+              additionalInfo: {
+                layoutX: 606,
+                layoutY: 424,
               },
-              "type": "log",
-              "name": "日志",
-              "debugMode": true,
-              "configuration": {
-                "jsScript": "return 'Incoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
-              }
-            }],
-            endpoints: [],
-            connections: [],
-          },
+              type: "log",
+              name: "日志",
+              debugMode: true,
+              configuration: {
+                jsScript: "return 'Incoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);",
+              },
+            },
+          ],
+          endpoints: [],
+          connections: [],
         },
-        { headers }
-      );
-      ruleForm.value.flowId = id;
-	} else {
+      },
+      { headers }
+    );
+    ruleForm.value.flowId = id;
+  } else {
     // 找到规则
-    const { data } = (await axios.get(import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + ruleForm.value.flowId, { headers }).catch(() => {
+    const { data } = (await axios.get(getRuleServerOrigin("/api/v1/rules/" + ruleForm.value.flowId), { headers }).catch(() => {
       ElMessage.error("规则不存在");
     })) as any;
 
@@ -203,39 +198,41 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
     data.ruleChain.additionalInfo.description = ruleForm.value.description;
 
     // 保存
-    await axios.post(import.meta.env.VITE_RULE_SERVER_URL + "/api/v1/rules/" + ruleForm.value.flowId, data, { headers });
+    await axios.post(getRuleServerOrigin("/api/v1/rules/" + ruleForm.value.flowId), data, { headers });
   }
   const theApi = ruleForm.value.id ? policyApi.edit : policyApi.add;
 
-	await theApi(ruleForm.value);
+  await theApi(ruleForm.value);
 
-	ElMessage.success('操作成功');
-	resetForm();
-	isShowDialog.value = false;
-	emit('getList');
-}
+  ElMessage.success("操作成功");
+  resetForm();
+  isShowDialog.value = false;
+  emit("getList");
+};
 
 const resetForm = () => {
   ruleFormRef.value && ruleFormRef.value.resetFields();
 
-  ruleForm.value.param = [{
-    key: "",
-    title: "",
-    types: ""
-  }]
-}
+  ruleForm.value.param = [
+    {
+      key: "",
+      title: "",
+      types: "",
+    },
+  ];
+};
 
 const plusParam = () => {
   ruleForm.value.param.push({
-    key: '',
-    title: '',
-    types: ''
-  })
-}
+    key: "",
+    title: "",
+    types: "",
+  });
+};
 
-const minusParam = (index:number) => {
+const minusParam = (index: number) => {
   ruleForm.value.param.splice(index, 1);
-}
+};
 
 // 打开弹窗
 const openDialog = (row?: any) => {
@@ -250,57 +247,53 @@ const openDialog = (row?: any) => {
         status: status,
         description: description,
         param: paramData,
-        flowId: flowId
-      }
+        flowId: flowId,
+      };
     });
-
-
   }
   api.product.getDataType({ status: -1 }).then((res: any) => {
-    const data:any = Object.values(res.dataType)
-    data.forEach((item:any, index:number) => {
+    const data: any = Object.values(res.dataType);
+    data.forEach((item: any, index: number) => {
       if (index == 0) {
-        data[index]['label'] = '基础类型';
-        data[index]['options'] = item;
+        data[index]["label"] = "基础类型";
+        data[index]["options"] = item;
       } else {
-        data[index]['label'] = '扩展类型';
-        data[index]['options'] = item.filter((i:any) => ['enum', 'array', 'object'].indexOf(i.type) === -1);
-        
+        data[index]["label"] = "扩展类型";
+        data[index]["options"] = item.filter((i: any) => ["enum", "array", "object"].indexOf(i.type) === -1);
       }
     });
     typeData.value = data || [];
   });
   isShowDialog.value = true;
-
 };
 
-defineExpose({ openDialog })
+defineExpose({ openDialog });
 </script>
 
 <style lang="scss" scoped>
-  .param-wrap {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    margin-bottom: 10px;
-    .el-input,
-    .el-select {
-      width: 150px;
-    }
-  }
-  .el-icon {
-    margin-right: 0!important;
+.param-wrap {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 10px;
+  .el-input,
+  .el-select {
+    width: 150px;
   }
-  ::v-deep .el-dialog__body {
-    position: relative;
-  }
-  .form-btn-wrap {
-    position: absolute;
-    bottom: 20px;
-    right: 20px;
-    display: flex;
-    justify-content: flex-end;
-    align-items: center;
-    width: 100%;
-  }
-</style>
+}
+.el-icon {
+  margin-right: 0 !important;
+}
+::v-deep .el-dialog__body {
+  position: relative;
+}
+.form-btn-wrap {
+  position: absolute;
+  bottom: 20px;
+  right: 20px;
+  display: flex;
+  justify-content: flex-end;
+  align-items: center;
+  width: 100%;
+}
+</style>

+ 58 - 71
src/views/modules/policy/index/components/execute.vue

@@ -2,38 +2,24 @@
   <el-dialog title="执行" v-model="isShowDialog" width="600px">
     <el-form>
       <el-form-item>
-        <p>标题:{{currentPolicy.title}}</p>
-        <p class="ml30">执行类型:{{typesText[currentPolicy.types]}}</p>
+        <p>标题:{{ currentPolicy.title }}</p>
+        <p class="ml30">执行类型:{{ typesText[currentPolicy.types] }}</p>
       </el-form-item>
-      <el-form-item >
-        <div style="width: 100%;">
+      <el-form-item>
+        <div style="width: 100%">
           <p>参数配置</p>
           <div class="param-wrap" v-for="(item, index) in currentPolicy.paramData" :key="index">
-            <p class="mr6 label">{{item.title}}:</p>
+            <p class="mr6 label">{{ item.title }}:</p>
             <!-- int、long、float、double、string、boolean、date、timestamp -->
             <el-input v-if="item.types === 'string'" clearable :placeholder="`请输入${item.title}`" v-model="item.value" />
-            <el-input-number v-if="['int',  'long'].indexOf(item.types) > -1" :placeholder="`请输入${item.title}`" v-model="item.value" :step="1" step-strictly />
-            <el-input-number v-if="['float',  'double'].indexOf(item.types) > -1" :placeholder="`请输入${item.title}`" v-model="item.value" :precision="2" />
+            <el-input-number v-if="['int', 'long'].indexOf(item.types) > -1" :placeholder="`请输入${item.title}`" v-model="item.value" :step="1" step-strictly />
+            <el-input-number v-if="['float', 'double'].indexOf(item.types) > -1" :placeholder="`请输入${item.title}`" v-model="item.value" :precision="2" />
             <el-radio-group v-if="item.types === 'boolean'" v-model="item.value">
               <el-radio :label="0">否</el-radio>
               <el-radio :label="1">是</el-radio>
             </el-radio-group>
-            <el-date-picker
-              v-if="item.types === 'date'"
-              v-model="item.value"
-              type="datetime"
-              :placeholder="`请选择${item.title}`"
-              format="YYYY/MM/DD hh:mm:ss"
-              value-format="YYYY-MM-DD h:m:s"
-            />
-            <el-date-picker
-              v-if="item.types === 'timestamp'"
-              v-model="item.value"
-              type="datetime"
-              :placeholder="`请选择${item.title}`"
-              format="YYYY/MM/DD hh:mm:ss"
-              value-format="x"
-            />
+            <el-date-picker v-if="item.types === 'date'" v-model="item.value" type="datetime" :placeholder="`请选择${item.title}`" format="YYYY/MM/DD hh:mm:ss" value-format="YYYY-MM-DD h:m:s" />
+            <el-date-picker v-if="item.types === 'timestamp'" v-model="item.value" type="datetime" :placeholder="`请选择${item.title}`" format="YYYY/MM/DD hh:mm:ss" value-format="x" />
           </div>
         </div>
       </el-form-item>
@@ -46,44 +32,45 @@
 </template>
 
 <script lang="ts" setup>
-import { ref } from 'vue'
+import { ref } from "vue";
 import { ElMessage } from "element-plus";
-import api from '/@/api/modules/policy';
-import axios from 'axios';
+import api from "/@/api/modules/policy";
+import axios from "axios";
 import { getToken } from "/@/utils/auth";
+import { getRuleServerOrigin } from "/@/utils/origin";
 
 const isShowDialog = ref(false);
 const typesText = {
-  1: '手动',
-  2: '自动'
+  1: "手动",
+  2: "自动",
 };
 const headers = {
   Authorization: "Bearer " + getToken(),
 };
 const currentPolicy = ref<any>({});
 
-const emit = defineEmits(['getList']);
+const emit = defineEmits(["getList"]);
 
 // 手动执行/开始执行
 const onSubmit = async () => {
-  const params:any = {};
-  currentPolicy.value.paramData.forEach((item:any) => {
-    params[item.key] = item.value
-  })
+  const params: any = {};
+  currentPolicy.value.paramData.forEach((item: any) => {
+    params[item.key] = item.value;
+  });
   await api.saveParam({
     id: currentPolicy.value.id,
     param: {
-      ...params
-    }
-  })
-  await axios.post(`${import.meta.env.VITE_RULE_SERVER_URL}/api/v1/rules/${currentPolicy.value.flowId}/execute/${currentPolicy.value.types}`, params, { headers }).catch(() => {
+      ...params,
+    },
+  });
+  (await axios.post(getRuleServerOrigin(`/api/v1/rules/${currentPolicy.value.flowId}/execute/${currentPolicy.value.types}`), params, { headers }).catch(() => {
     ElMessage.error("规则不存在");
-  }) as any;
+  })) as any;
 
-	ElMessage.success('操作成功');
-	isShowDialog.value = false;
-	emit('getList');
-}
+  ElMessage.success("操作成功");
+  isShowDialog.value = false;
+  emit("getList");
+};
 
 // 打开弹窗
 const openDialog = (row?: any) => {
@@ -99,34 +86,34 @@ defineExpose({ openDialog });
 </script>
 
 <style lang="scss" scoped>
-  .param-wrap {
-    display: flex;
-    justify-content: flex-start;
-    align-items: center;
-    margin-bottom: 10px;
-    .label {
-      width: 120px;
-      text-align: right;
-    }
-  }
-  .el-input-number,
-  .el-input {
-    width: 260px!important;
-  }
-  ::v-deep   .el-date-editor.el-input {
-    width: 260px!important;
+.param-wrap {
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+  margin-bottom: 10px;
+  .label {
+    width: 120px;
+    text-align: right;
   }
+}
+.el-input-number,
+.el-input {
+  width: 260px !important;
+}
+::v-deep .el-date-editor.el-input {
+  width: 260px !important;
+}
 
-  ::v-deep .el-dialog__body {
-    position: relative;
-  }
-  .form-btn-wrap {
-    position: absolute;
-    bottom: 20px;
-    right: 20px;
-    display: flex;
-    justify-content: flex-end;
-    align-items: center;
-    width: 100%;
-  }
-</style>
+::v-deep .el-dialog__body {
+  position: relative;
+}
+.form-btn-wrap {
+  position: absolute;
+  bottom: 20px;
+  right: 20px;
+  display: flex;
+  justify-content: flex-end;
+  align-items: center;
+  width: 100%;
+}
+</style>

+ 2 - 0
writeEnv.mjs

@@ -7,7 +7,9 @@ dotenv.config({ path: NODE_ENV ? [`.env.${NODE_ENV}.local`, '.env.' + NODE_ENV,
 
 const { VITE_SERVER_ORIGIN, VITE_NGINX_PROXY, VITE_API_SUFFIX_URL, VITE_RULE_SERVER_URL, VITE_MEDIA_SERVER_URL } = process.env
 
+console.log(VITE_SERVER_ORIGIN, VITE_NGINX_PROXY, VITE_API_SUFFIX_URL, VITE_RULE_SERVER_URL, VITE_MEDIA_SERVER_URL)
 const baseUrl = VITE_SERVER_ORIGIN + VITE_NGINX_PROXY + VITE_API_SUFFIX_URL
+console.log(baseUrl)
 
 const configFile = './public/config.js'
 const configJson = {