vue3: baidusubway using typescript

news2025/6/3 12:18:06

项目结构:

<!--npm install -D tailwindcss-3d  BaiduSubwayMap.vue npm install -D tailwindcss postcss autoprefixer-->
<template>
    <div class="relative w-full h-screen">
      <!-- 地图容器 -->
      <div id="subway-container" class="w-full h-full"></div>
       
      <!-- 缩放控制 -->
      <div class="fixed bottom-4 right-4 flex flex-col space-y-2 z-10">
        <button @click="zoomIn" class="w-10 h-10 rounded-full bg-white shadow-md flex items-center justify-center hover:bg-gray-100 transition-colors">
          <i class="fa fa-plus text-gray-700"></i>
        </button>
        <button @click="zoomOut" class="w-10 h-10 rounded-full bg-white shadow-md flex items-center justify-center hover:bg-gray-100 transition-colors">
          <i class="fa fa-minus text-gray-700"></i>
        </button>
      </div>
       
      <!-- 地铁图例 -->
      <div id="legend" class="fixed top-4 right-4 max-w-xs bg-white rounded-lg shadow-lg p-4 hidden md:block z-10">
        <h3 class="font-medium text-gray-800 mb-3">地铁线路图例</h3>
        <div id="legendContent" class="space-y-1 text-sm">
          <div v-for="line in subwayLines" :key="line.id" class="flex items-center">
            <span class="subway-line" :style="{ backgroundColor: line.color || '#3b82f6' }"></span>
            <span>{{ line.name }}</span>
          </div>
        </div>
      </div>
    </div>
  </template>
   
  <script lang="ts">
  import { defineComponent, ref, onMounted, onUnmounted, watch} from 'vue';  //,PropType
   
  interface SubwayLine {
    id: string;
    name: string;
    color?: string;
  }
   
  interface RouteStep {
    instruction: string;
    distance?: number;
    duration?: number;
  }
   
  interface RouteResult {
    steps: RouteStep[];
    distance?: number;
    duration?: number;
  }
   
  export default defineComponent({
    name: 'BaiduSubwayMap',
     
    props: {
      currentCity: {
        type: String,
        required: true
      },
      startStation: {
        type: String,
        required: true
      },
      endStation: {
        type: String,
        required: true
      },
      cityData: Object as () => Record<string, { start: string; end: string }>  //vue 3.3
      //Vue 3
      //cityData: {
        //type: Object as PropType<Record<string, { start: string; end: string }>>,
        //required: true
      //}
    },
     
    emits: ['routeFound', 'error', 'mapLoaded'],
     
    setup(props, { emit }) {
      const subway = ref<any>(null);
      const direction = ref<any>(null);
      const subwayLines = ref<SubwayLine[]>([]);
      const isMapLoaded = ref(false);
       
      // 监听城市变化
        watch(() => props.currentCity, async (newCity, oldCity) => {
        if (newCity !== oldCity) {
            console.log(`城市切换: ${oldCity} → ${newCity}`);
            await loadCitySubway(newCity);
        }
        });
 
 
      // 生命周期钩子
      onMounted(() => {
        initMap();
      });
       
      onUnmounted(() => {
        cleanupSubwayInstance();
      });
       
      // 监听城市或站点变化
      watch([() => props.currentCity, () => props.startStation, () => props.endStation], () => {
        if (isMapLoaded.value && props.startStation && props.endStation) {
          searchRoute();
        }
      });
       
      // 初始化地图
      const initMap = () => {
        try {
          // 检查百度地图API是否加载成功
          if (typeof BMapSub === 'undefined') {
            emit('error', '百度地图API加载失败,请检查API密钥是否正确');
            return;
          }
           
          // 加载当前城市的地铁地图
          loadCitySubway(props.currentCity);
        } catch (error) {
          console.error('初始化地图时出错:', error);
          emit('error', '初始化地图时出错,请刷新页面');
        }
      };
       
      // 加载指定城市的地铁地图
      const loadCitySubway = (cityName: string) => {
        // 重置地图容器
        const container = document.getElementById('subway-container');
        if (container) container.innerHTML = '';
         
        // 清理旧的地铁实例
        cleanupSubwayInstance();
         
        try {
          // 查找城市信息
          const city = BMapSub.SubwayCitiesList.find(c => c.name === cityName);
           
          if (!city) {
            emit('error', `未找到${cityName}的地铁数据,请尝试其他城市`);
            return;
          }
          console.log(`加载${cityName}地铁地图,城市代码: ${city.citycode}`);
          // 创建新的地铁实例
          subway.value = new BMapSub.Subway('subway-container', city.citycode);
           
          // 绑定地铁加载完成事件
          subway.value.addEventListener('subwayloaded', () => {
            console.log(`${cityName}地铁地图加载完成`);
            onSubwayLoaded(cityName);
            emit('mapLoaded', true);
          });
           
          // 绑定错误处理
          subway.value.addEventListener('subwayloaderror', onSubwayLoadError);
           
        } catch (e) {
          console.error('创建地铁实例时出错:', e);
          emit('error', `加载${cityName}地铁数据失败,请稍后再试`);
        }
      };
       
      // 地铁加载完成回调
      const onSubwayLoaded = (cityName: string) => {
        try {
          // 初始化路线规划
          direction.value = new BMapSub.Direction(subway.value);
           
          // 设置路线规划完成后的回调
          direction.value.addEventListener('directioncomplete', handleRouteResults);
           
          isMapLoaded.value = true;
          emit('mapLoaded', true);
           
          // 生成线路图例
          generateLineLegend();
           
          // 如果有起点和终点,执行搜索
          if (props.startStation && props.endStation) {
            searchRoute();
          }
           
        } catch (e) {
          console.error('初始化地铁地图时出错:', e);
          emit('error', `初始化${cityName}地铁地图失败,请稍后再试`);
        }
      };
       
      // 地铁加载错误回调
      const onSubwayLoadError = () => {
        emit('error', `加载${props.currentCity}地铁数据失败,请稍后再试`);
        isMapLoaded.value = false;
      };
       
      // 清理旧的地铁实例
      const cleanupSubwayInstance = () => {
        if (subway.value) {
          try {
            subway.value.removeEventListener('subwayloaded', onSubwayLoaded);
            subway.value.removeEventListener('subwayloaderror', onSubwayLoadError);
             
            // 仅在地铁已初始化且有destroy方法时尝试销毁
            if (isMapLoaded.value && typeof subway.value.destroy === 'function') {
              // 移除路线规划器的事件监听器
              if (direction.value) {
                direction.value.removeEventListener('directioncomplete', handleRouteResults);
                direction.value = null;
              }
               
              // 尝试销毁地铁实例
              subway.value.destroy();
            }
          } catch (e) {
            console.error('销毁地铁实例时出错:', e);
          } finally {
            // 无论如何都重置地铁实例和状态
            subway.value = null;
            isMapLoaded.value = false;
          }
        }
      };
       
      // 生成线路图例
      const generateLineLegend = () => {
        try {
          // 获取线路信息
          if (!subway.value) return;
           
          const lines = subway.value.getLines();
           
          if (lines && lines.length > 0) {
            // 只显示前10条线路以避免图例过长
            const displayLines = lines.slice(0, 10);
            subwayLines.value = displayLines.map(line => ({
              id: line.id,
              name: line.name,
              color: line.color
            }));
          }
        } catch (e) {
          console.error('生成线路图例时出错:', e);
        }
      };
       
      // 搜索路线
      const searchRoute = () => {
        if (!isMapLoaded.value || !direction.value) {
          emit('error', '地图加载中,请稍候再试');
          return;
        }
         
        if (!props.startStation || !props.endStation) {
          emit('error', '请输入起点站和终点站');
          return;
        }
         
        // 验证站点是否属于当前城市
        const validStations = getValidStations(props.currentCity);
        if (validStations && !validStations.includes(props.startStation)) {
          emit('error', `起点站“${props.startStation}”不存在于${props.currentCity}地铁系统中`);
          return;
        }
         
        if (validStations && !validStations.includes(props.endStation)) {
          emit('error', `终点站“${props.endStation}”不存在于${props.currentCity}地铁系统中`);
          return;
        }
         
        // 执行路线搜索
        try {
          direction.value.search(props.startStation, props.endStation);
        } catch (e) {
          console.error('搜索路线时出错:', e);
          emit('error', '搜索路线时出错,请重试');
        }
      };
       
      // 处理路线规划结果
      const handleRouteResults = (results: any) => {
        try {
          if (!results || results.length === 0) {
            emit('error', `未找到从${props.startStation}到${props.endStation}的路线,请尝试其他站点`);
            return;
          }
           
          // 选择第一条路线(通常是最优路线)
          const route = results[0];
           
          // 格式化路线结果
          const formattedRoute: RouteResult = {
            steps: route.steps || [],
            distance: route.distance,
            duration: route.duration
          };
           
          // 发送路线结果给父组件
          emit('routeFound', formattedRoute);
           
        } catch (e) {
          console.error('处理路线结果时出错:', e);
          emit('error', '处理路线信息时出错,请重试');
        }
      };
       
      // 地图缩放控制
      const zoomIn = () => {
        if (subway.value) {
          try {
            subway.value.setZoom(subway.value.getZoom() + 1);
          } catch (e) {
            console.error('地图缩放时出错:', e);
          }
        }
      };
       
      const zoomOut = () => {
        if (subway.value) {
          try {
            subway.value.setZoom(subway.value.getZoom() - 1);
          } catch (e) {
            console.error('地图缩放时出错:', e);
          }
        }
      };
       
      // 获取当前城市的有效站点列表
      const getValidStations = (cityName: string): string[] | null => {
        try {
          if (!subway.value) {
            return null;
          }
           
          // 获取所有线路
          const lines = subway.value.getLines();
           
          if (!lines || lines.length === 0) {
            return null;
          }
           
          // 收集所有站点
          const stations = new Set<string>();
           
          lines.forEach(line => {
            if (line.stations && line.stations.length > 0) {
              line.stations.forEach(station => {
                stations.add(station.name);
              });
            }
          });
           
          return Array.from(stations);
        } catch (e) {
          console.error('获取站点列表时出错:', e);
          return null;
        }
      };
       
      return {
        subwayLines,
        zoomIn,
        zoomOut
      };
    }
  });
  </script>
   
  <style type="text/tailwindcss">
  @layer utilities {
    .subway-line {
      display: inline-block;
      width: 12px;
      height: 2px;
      margin: 0 4px;
      vertical-align: middle;
    }
  }
  </style>

<!-- SubWayView.vue -->
<template>
    <div class="font-sans">
      <!-- 搜索面板 -->
      <div
        v-show="panelVisible"
        class="fixed top-4 left-1/2 transform -translate-x-1/2 bg-white rounded-xl shadow-lg p-6 max-w-md w-full z-50 transition-all duration-300"
      >
        <div class="flex justify-between items-center mb-4">
          <h2 class="text-xl font-bold text-gray-900">{{ panelTitle }}</h2>
          <button
            @click="closePanel"
            class="text-gray-500 hover:text-gray-700 focus:outline-none"
          >
            <i class="fa fa-times text-lg"></i>
          </button>
        </div>
   
        <div class="space-y-4">
          <!-- 城市选择 -->
          <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">城市</label>
            <div class="relative">
              <input
                v-model="currentCity"
                @input="handleCityInput"
                @keypress.enter="changeCity"
                class="w-full px-4 py-2 border rounded-lg focus:ring-blue-500 focus:border-blue-500"
                placeholder="请输入城市名称"
              />
              <div
                v-show="citySuggestions.length > 0"
                class="absolute left-0 right-0 top-full mt-1 bg-white rounded-lg shadow-lg z-50"
              >
                <div
                  v-for="suggestion in citySuggestions"
                  :key="suggestion"
                  @click="selectCity(suggestion)"
                  class="px-4 py-2 hover:bg-gray-100 cursor-pointer"
                >
                  {{ suggestion }}
                </div>
              </div>
            </div>
            <div class="flex space-x-2 mt-2">
              <button
                @click="changeCity"
                class="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg shadow-md"
              >
                切换城市
              </button>
              <button
                @click="resetToDefault"
                class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium py-2 px-4 rounded-lg"
              >
                <i class="fa fa-refresh mr-1"></i> 重置默认
              </button>
            </div>
          </div>
   
          <!-- 站点输入 -->
          <div>
            <div class="relative">
              <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
                <i class="fa fa-map-marker text-blue-500"></i>
              </div>
              <input
                v-model="startStation"
                @keypress.enter="searchRoute"
                class="w-full pl-10 pr-4 py-2 border rounded-lg focus:ring-blue-500 focus:border-blue-500"
                placeholder="请输入起点站"
              />
              <div
                v-show="isDefaultStartStation"
                class="absolute right-3 top-1/2 transform -translate-y-1/2 text-xs text-gray-400"
              >
                默认
              </div>
            </div>
            <div class="relative mt-4">
              <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
                <i class="fa fa-flag text-red-500"></i>
              </div>
              <input
                v-model="endStation"
                @keypress.enter="searchRoute"
                class="w-full pl-10 pr-4 py-2 border rounded-lg focus:ring-blue-500 focus:border-blue-500"
                placeholder="请输入终点站"
              />
              <div
                v-show="isDefaultEndStation"
                class="absolute right-3 top-1/2 transform -translate-y-1/2 text-xs text-gray-400"
              >
                默认
              </div>
            </div>
          </div>
   
          <!-- 查询按钮 -->
          <button
            @click="searchRoute"
            class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg shadow-lg mt-4"
          >
            查询路线
          </button>
   
          <!-- 路线结果 -->
          <div class="mt-4 bg-gray-100 rounded-lg p-4 text-sm">
            <div v-if="loading" class="text-gray-500 animate-pulse">
              <i class="fa fa-spinner fa-spin mr-1"></i> {{ loadingMessage }}
            </div>
            <div v-else-if="errorMessage" class="text-red-500">
              <i class="fa fa-exclamation-circle mr-1"></i> {{ errorMessage }}
            </div>
            <div v-else-if="routeResults">
              <!-- 路线展示逻辑保持不变 -->
              <div class="bg-white rounded-lg shadow-sm p-4 mb-4">
                <div class="flex justify-between items-center mb-3">
                  <h3 class="font-medium">{{ startStation }} → {{ endStation }}</h3>
                  <span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full">
                    <i class="fa fa-clock-o mr-1"></i> 约{{ routeResults.duration || '未知' }}分钟
                  </span>
                </div>
                <!-- 路线步骤展示 -->
              </div>
            </div>
            <div v-else class="text-gray-500">
              请输入起点和终点,点击查询路线
            </div>
          </div>
        </div>
      </div>
   
      <!-- 显示面板按钮 -->
      <button
        v-show="!panelVisible"
        @click="showPanel"
        class="fixed top-4 left-4 bg-white hover:bg-gray-100 text-gray-800 font-medium py-2 px-4 rounded-lg shadow-md z-50"
      >
        <i class="fa fa-search mr-2"></i> 显示搜索面板
      </button>
       
      <!-- 百度地铁地图组件 -->
      <BaiduSubwayMap
        :currentCity="currentCity"
        :startStation="startStation"
        :endStation="endStation"
        :cityData="cityData"
        @routeFound="handleRouteFound"
        @error="handleError"
        @mapLoaded="handleMapLoaded"
      />
    </div>
  </template>
   
  <script lang="ts">
  import { defineComponent, ref, computed, onMounted, watch } from 'vue';
  import BaiduSubwayMap from '../components/BaiduSubwayMap.vue';
   
  interface CityData {
    [city: string]: {
      start: string;
      end: string;
    };
  }
   
  export default defineComponent({
    name: 'SubWayView',
     
    components: {
      BaiduSubwayMap
    },
     
    setup() {
      // 状态管理
      const currentCity = ref('深圳');
      const startStation = ref('');
      const endStation = ref('');
      const panelVisible = ref(true);
      const loading = ref(false);
      const loadingMessage = ref('');
      const errorMessage = ref('');
      const routeResults = ref(null);
      const cityData = ref<CityData>({});
      const citySuggestions = ref<string[]>([]);
      const cityHistory = ref<string[]>([]); // 新增:历史记录数组
      const panelTitle = ref('深圳地铁线路规划');  //
       
      // 计算属性
      const isDefaultStartStation = computed(() => {
        return cityData.value[currentCity.value]?.start === startStation.value;
      });
       
      const isDefaultEndStation = computed(() => {
        return cityData.value[currentCity.value]?.end === endStation.value;
      });
       
      // 生命周期钩子
      onMounted(() => {
        loadCityData();
        loadSavedState();
      });
       
      // 从city.json加载城市数据
      const loadCityData = async () => {
        try {
          console.log('开始加载城市数据...');
          loading.value = true;
          loadingMessage.value = '正在加载城市数据...';
           
          const response = await fetch('city.json');
          cityData.value = await response.json();
          console.log('城市数据加载成功:', cityData.value);
          // 设置当前城市的默认站点
          setDefaultStations();
           
          loading.value = false;
        } catch (error) {
          console.error('加载城市数据失败:', error);
          errorMessage.value = '加载城市数据失败,请稍后再试';
          loading.value = false;
        }
      };
       
      // 加载保存的状态
      const loadSavedState = () => {
        try {
          const savedState = localStorage.getItem('subwayMapState');
           
          if (savedState) {
            const parsedState = JSON.parse(savedState);
             
            // 恢复当前城市
            if (parsedState.currentCity && cityData.value[parsedState.currentCity]) {
              currentCity.value = parsedState.currentCity;
              panelTitle.value = `${currentCity.value}地铁线路规划`;
            }
             
            // 恢复站点
            if (parsedState.startStation) {
              startStation.value = parsedState.startStation;
            }
             
            if (parsedState.endStation) {
              endStation.value = parsedState.endStation;
            }
             
            // 恢复面板可见性
            if (typeof parsedState.panelVisible === 'boolean') {
              panelVisible.value = parsedState.panelVisible;
            }
             
            console.log('从本地存储恢复状态:', parsedState);
          }
        } catch (e) {
          console.error('恢复应用状态失败:', e);
        }
      };
       
      // 保存当前状态到本地存储
      const saveState = () => {
        try {
          const stateToSave = {
            currentCity: currentCity.value,
            startStation: startStation.value,
            endStation: endStation.value,
            panelVisible: panelVisible.value
          };
           
          localStorage.setItem('subwayMapState', JSON.stringify(stateToSave));
        } catch (e) {
          console.error('保存应用状态失败:', e);
        }
      };
       
      // 设置当前城市的默认站点
      const setDefaultStations = () => {
        const defaultStations = cityData.value[currentCity.value];
         
        if (defaultStations) {
          // 只有在站点为空时设置默认值,保留用户修改
          if (!startStation.value) {
            startStation.value = defaultStations.start;
          }
           
          if (!endStation.value) {
            endStation.value = defaultStations.end;
          }
        }   
      };
       
      // 切换城市
      const changeCity = () => {
        console.log(`点击:选择城市...`);

        const cityName1 = currentCity.value.trim();
        console.log(`点击:选择城市${cityName1}`);    

        const defaultStations = cityData.value[currentCity.value];
         
         if (defaultStations) {
           startStation.value = defaultStations.start;
           endStation.value = defaultStations.end;
           panelTitle.value = `${currentCity.value}地铁线路规划`;
           // 保存状态
           saveState();
         }        
        // 清除错误消息
        errorMessage.value = null;
      };
       
      // 处理城市输入
      const handleCityInput = () => {
        const query = currentCity.value.trim().toLowerCase();
         
        if (query.length < 2) {
          citySuggestions.value = [];
          return;
        }
         // 检查输入的城市是否有效(存在于cityData中)
        const isValidCity = cityData.value[query];
        if (isValidCity && !cityHistory.value.includes(query)) {
            // 添加到历史记录(去重)
            cityHistory.value.push(query);
        }
        //
        const allCities = [...new Set([...Object.keys(cityData.value), ...cityHistory.value])];
        const matchedCities = allCities.filter(city => 
            city.toLowerCase().includes(query)
        );

        // 过滤匹配的城市
        //const matchedCities = Object.keys(cityData.value).filter(city =>
          //city.toLowerCase().includes(query)
        //);
         
        // 更新建议列表
        citySuggestions.value = matchedCities;
      };
       
      // 选择城市
      const selectCity = (cityName: string) => {
        currentCity.value = cityName;
        console.log(`换了地图:选择城市${cityName}`);      
        //setDefaultStations(); // 强制设置默认站点

           // itySuggestions.value = [];
            if (!cityHistory.value.includes(cityName)) {
                cityHistory.value.push(cityName);
            }


        //citySuggestions.value = [];
        const defaultStations = cityData.value[currentCity.value];
         
         if (defaultStations) {
           startStation.value = defaultStations.start;
           endStation.value = defaultStations.end;
           panelTitle.value = `${currentCity.value}地铁线路规划`;
           // 保存状态
           saveState();
         }



      };
       
      // 搜索路线
      const searchRoute = () => {
        if (!startStation.value || !endStation.value) {
          errorMessage.value = '请输入起点站和终点站';
          return;
        }
         
        // 保存当前状态
        saveState();
         
        // 清空错误消息
        //errorMessage.value = null;
      };
       
      // 处理路线结果
      const handleRouteFound = (results: any) => {
        routeResults.value = results;
        loading.value = false;
         
        // 保存当前状态
        saveState();
      };
       
      // 处理错误
      const handleError = (message: string) => {
        errorMessage.value = message;
        loading.value = false;
      };
       
      // 处理地图加载完成
      const handleMapLoaded = () => {
        loading.value = false;
      };
       
      // 关闭面板
      const closePanel = () => {
        panelVisible.value = false;
        saveState();
      };
       
      // 显示面板
      const showPanel = () => {
        panelVisible.value = true;
        saveState();
      };
       
      // 重置为默认值
      const resetToDefault = () => {
        const defaultStations = cityData.value[currentCity.value];
         
        if (defaultStations) {
          startStation.value = defaultStations.start;
          endStation.value = defaultStations.end;
          panelTitle.value = `${currentCity.value}地铁线路规划`;
          // 保存状态
          saveState();
        }
      };
       
      // 监听面板可见性变化
      watch(panelVisible, () => {
        saveState();
      });
       
      // 监听站点变化
      watch([startStation, endStation], () => {
        saveState();
      });
       
      return {
        currentCity,
        startStation,
        endStation,
        panelVisible,
        loading,
        loadingMessage,
        errorMessage,
        routeResults,
        cityData,
        citySuggestions,
        panelTitle,
        isDefaultStartStation,
        isDefaultEndStation,
        changeCity,
        handleCityInput,
        selectCity,
        searchRoute,
        closePanel,
        showPanel,
        resetToDefault,
        handleRouteFound, // 确保将方法添加到返回对象中
        handleError,
        handleMapLoaded
      };
    }
  });
  </script>
   
   <style scoped>
  /* 优化字体和间距 */
  @tailwind base;
  @tailwind components;
  @tailwind utilities;
   
  /* 修复搜索面板层级问题 */
  .z-50 {
    z-index: 50;
  }
  </style>

输出:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2395555.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Redis最佳实践——性能优化技巧之集群与分片

Redis集群与分片在电商应用中的性能优化技巧 一、Redis集群架构模式解析 1. 主流集群方案对比 方案核心原理适用场景电商应用案例主从复制读写分离数据冗余中小规模读多写少商品详情缓存Redis Sentinel自动故障转移监控高可用需求场景订单状态缓存Redis Cluster原生分布式分片…

常见相机的ISP算法

常见的ISP算法 3A算法 去雾算法 图像增强算法 图像宽动态算法 图像的电子缩放算法&#xff0c;无极电子缩放 图像降噪算法 相机常见问题 1.相机启动速度问题&#xff0c;启动速度较慢 2.相机扛不住高低温问题 3.相机散热问题问题 4.相机高低温芯片保护掉电 5.相机的成像效果或者…

2024 CKA模拟系统制作 | Step-By-Step | 8、题目搭建-创建 Ingress

目录 ​​​​​​免费获取题库配套 CKA_v1.31_模拟系统 一、题目 二、核心考点 Ingress 资源定义 Ingress Controller 依赖 服务暴露验证 网络层次关系 三、搭建模拟环境 1.创建命名空间 2.安装ingress ingress-nginx-controller 3.创建hello.yaml并部署 四、总结 …

OldRoll复古胶片相机:穿越时光,定格经典

在数字摄影盛行的今天&#xff0c;复古胶片相机的独特魅力依然吸引着无数摄影爱好者。OldRoll复古胶片相机这款软件&#xff0c;以其独特的复古风格和丰富的胶片滤镜效果&#xff0c;让用户仿佛穿越回了那个胶片摄影的黄金时代。它不仅模拟了胶片相机的操作界面&#xff0c;还提…

通俗易懂的 JS DOM 操作指南:从创建到挂载

目录 &#x1f9e9; 1. 创建元素&#xff1a;document.createElement / createElementNS &#x1f4dd; 2. 创建文本&#xff1a;document.createTextNode ✏️ 3. 修改文本&#xff1a;node.nodeValue &#x1f5d1;️ 4. 移除元素&#xff1a;el.removeChild() &#x1…

CSS Day07

1.搭建项目目录 2.网页头部SEO三大标签 3.Favicon图标与版心 &#xff08;1&#xff09;Favicon图标 &#xff08;2&#xff09;版心 4.快捷导航 5.头部-布局 6.头部-logo 7.头部-导航 8.头部-搜索 9头部-购物车 10.底部-布局 11.底部-服务区域 12.底部-帮助中心 13.底部-版权…

RV1126-OPENCV 交叉编译

一.下载opencv-3.4.16.zip到自己想装的目录下 二.解压并且打开 opencv 目录 先用 unzip opencv-3.4.16.zip 来解压 opencv 的压缩包&#xff0c;并且进入 opencv 目录(cd opencv-3.4.16) 三. 修改 opencv 的 cmake 脚本的内容 先 cd platforms/linux 然后修改 arm-gnueabi.to…

【深度学习】 19. 生成模型:Diffusion Models

Diffusion Models Diffusion Models 简介 Diffusion 模型是一类通过逐步添加噪声并再逆向还原的方式进行图像生成的深度生成模型。其基本流程包括&#xff1a; 前向过程&#xff08;Forward Process&#xff09;&#xff1a;将真实图像逐步加噪&#xff0c;最终变为高斯噪声…

JMeter 直连数据库

1.直连数据库的使用场景 1.1 参数化&#xff0c;例如登录使用的账户名密码都可以从数据库中取得 1.2 断言&#xff0c;查看实际结果和数据库中的预期结果是否一致 1.3 清理垃圾数据&#xff0c;例如插入一个用户&#xff0c;它的ID不能相同&#xff0c;在测试插入功能后将数据删…

易路 iBuilder:解构企业 AI 落地困境,重构智能体时代生产力范式

一、从大模型到智能体的产业跃迁 2024 年堪称中国人工智能产业的 "战略拐点" 之年。当 DeepSeek R1 模型以 "技术 价格" 双重普惠模式掀起行业震荡时&#xff0c;各企业纷纷意识到&#xff0c;大模型的真正价值不在于技术炫技&#xff0c;而在于成为企业…

计算机网络之路由表更新

1.解题思路 对新接收到的路由表进行更新&#xff0c;全部"距离"1&#xff0c;且"下一跳路由器"都写成发送方路由器的名称。 开始对比新表和原来的路由表 1.看目的网络 如果是新的目的网络&#xff0c;则直接把对应的各项信息填入表中&#xff1b;如果是相同…

万兴PDF手机版

万兴PDF手机版(万兴PDF编辑器)是一款国产PDF编辑工具.万兴PDF安卓版提供PDF文档编辑,AI撰写摘要,文档签名,设置密码保护等功能,万兴PDF专家APP以简约风格及文档编辑功能为核心,支持多设备终端同步保存.全免 万兴 PDF 编辑器是一款功能强大的 PDF 编辑软件&#xff0c;它支持多种…

Qt -使用OpenCV得到SDF

博客主页&#xff1a;【夜泉_ly】 本文专栏&#xff1a;【暂无】 欢迎点赞&#x1f44d;收藏⭐关注❤️ 目录 cv::MatdistanceTransform获得SDF 本文的目标&#xff0c; 是简单学习并使用OpenCV的相关函数&#xff0c; 并获得QImage的SDF(Signed Distance Field 有向距离场) 至…

DDR5 ECC详细原理介绍与基于协议讲解

本文篇幅较长,涉及背景原理介绍方便大家理解其运作方式 以及 基于DDR5协议具体展开介绍。 背景原理介绍 上图参考:DDR 内存中的 ECC 写入操作时,On-die ECC的工作过程如下: SoC将需要写入到Memory中的数据发送给控制器控制器将需要写入的数据直接发送给DRAM芯片在DDR5 DR…

EC800X QuecDuino开发板介绍

支持的模组列表 EG800KEC800MEC800GEC800E 功能列表 基本概述 EC800X QuecDuino EVB 搭载移远 EC800 系列模组。支持模组型号为&#xff1a; EC800M 系列、EC800K 系列、EG800K 系列、EC800E 系列等。 渲染图 开发板的主要组件、接口布局见下图 资料下载 EC800X-QuecDui…

PHP轻量级聊天室源码(源码下载)

最新版本&#xff1a;v2.1.2 (2024.08更新) 运行环境&#xff1a;PHP5.6&#xff08;无需MySQL&#xff09; 核心特性&#xff1a;手机电脑自适应、TXT数据存储、50条历史消息 适用场景&#xff1a;小型社区/企业内网/教育培训即时通讯 一、核心功能亮点&#xff08;SEO关键词布…

leetcode hot100刷题日记——33.二叉树的层序遍历

解题总结二维vector的初始化方法 题目描述情况1&#xff1a;不确定行数和列数情况2&#xff1a;已知行数和列数情况3&#xff1a;已知行数但不知道列数情况4&#xff1a;已知列数但不知道行数 题目描述 解答&#xff1a;用队列 思路都差不多&#xff0c;我觉得对于我自己来说&a…

《数据结构初阶》【番外篇:快速排序的前世今生】

【番外篇&#xff1a;快速排序的前世今生】目录 前言&#xff1a;---------------起源---------------一、诞生&#xff1a;二、突破&#xff1a;三、核心&#xff1a; ---------------发展---------------1. 早期版本&#xff1a;简单但不稳定1960 年&#xff1a;初始版本 2. …

【笔记】基于 MSYS2(MINGW64)的 Poetry 虚拟环境创建指南

#工作记录 基于 MSYS2&#xff08;MINGW64&#xff09;的 Poetry 虚拟环境创建指南 一、背景说明 在基于 MSYS2&#xff08;MINGW64&#xff09;的环境中&#xff0c;使用 Poetry 创建虚拟环境是一种高效且灵活的方式来管理 Python 项目依赖。本指南将详细介绍如何在 PyChar…

PINNs案例——二维磁场计算

基于物理信息的神经网络是一种解决偏微分方程计算问题的全新方法… 有关PINN基础详见&#xff1a;PINNs案例——中心热源温度场预测问题的torch代码 今日分享代码案例&#xff1a;二维带电流源磁场计算 该案例参考学习论文&#xff1a;[1]张宇娇&#xff0c;孙宏达&#xff0…