Commit e1214a14 authored by Sparkf's avatar Sparkf 🏙️
Browse files

Merge origin/master and retain dependency updates

parents 96dc13e5 1ae1dd92
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -13,6 +13,10 @@ import Canteen from './components/Canteen.vue'
import AdSenseInline from './components/adsense-inline.vue'
import AdSenseDisplayAD from './components/adsense-displayad.vue'
import TalksTodayNav from './components/TalksTodayNav.vue'
import { BusHomeV2 } from './components/bus-v2/index.mjs'
import BusRouteV2 from './components/bus-v2/BusRouteV2.vue'
import BusStopV2 from './components/bus-v2/BusStopV2.vue'
import BusSchedulesV2 from './components/bus-v2/BusSchedulesV2.vue'

export default defineClientConfig({
  enhance({ app }) {
@@ -28,10 +32,13 @@ export default defineClientConfig({
    app.component("AdSenseInline", AdSenseInline)
    app.component("AdSenseDisplayAD", AdSenseDisplayAD)
    app.component("TalksTodayNav", TalksTodayNav)
    app.component("BusHomeV2", BusHomeV2)
    app.component("BusRouteV2", BusRouteV2)
    app.component("BusStopV2", BusStopV2)
    app.component("BusSchedulesV2", BusSchedulesV2)

    // 含有echart的组件,注意需要用non-ssr模式
    app.component("BusChartVue", BusChartVue)
    app.component("Canteen", Canteen)
  },
})
+2 −7
Original line number Diff line number Diff line
@@ -302,15 +302,10 @@ export default {
          .then((response) => {
            const res = response.data;
            const busData = res
              .filter((f) => (f.is_operating == 1))
              .filter((f) => f.is_operating == 1 && (f.route_code === "RC61" || f.route_code === "RC62"))
              .map((f) => {
                //哪条线路
                let thisRoute = 0;
                if (f.route_code == "XYBS2") {
                  thisRoute = 1;
                } else if (f.route_code == "XYBS1") {
                  thisRoute = 0;
                }
                const thisRoute = f.route_code === "RC62" ? 1 : 0;

                //线上最近点
                const mcp = point([f.lng, f.lat]);
+11 −8
Original line number Diff line number Diff line
@@ -138,11 +138,13 @@ export default {
  methods: {
    async fetch_bus() {
      const realtime_location_api_data = await axios.get(`https://bus.sustcra.com/api/v2/monitor_osm/`)
      this.bus_location_data_api = realtime_location_api_data.data;
      this.bus_location_data_api = realtime_location_api_data.data.filter(
          (bus) => bus.route_code === 'RC61' || bus.route_code === 'RC62'
      );
      const d = new Date();
      console.log("bus location data fetched at " + parseInt(d.getTime() / 1000,));
      //console log the diff of report time and display time
      if (typeof this.bus_location_data_api[0].time_mt != "undefined") {
      if (this.bus_location_data_api.length > 0 && typeof this.bus_location_data_api[0].time_mt != "undefined") {
        this.time_difference = parseInt(d.getTime() / 1000 - this.bus_location_data_api[0].time_mt);
        // log current time and report time
        console.log("The clock drift is " + this.time_difference + " seconds");
@@ -223,7 +225,7 @@ export default {
        if ((new Date().getTime() / 1000) - busData.time_mt < 150) {
          const busLocation = [busData.lng, busData.lat];
          let busHeadingAngle = 0;
          const isRoute1 = busData.route_code.slice(-1) === '1';
          const isRoute1 = busData.route_code === 'RC61';
          busData.route_geojson = isRoute1 ? this.geojson_line_1 : this.geojson_line_2;
          const closestSegment = this.findNearestSegment(busLocation, busData.route_geojson);
          busHeadingAngle = this.calculateBusAngle(
@@ -256,17 +258,18 @@ export default {

    createPopup(busData) {
      let routeDirText;
      const routeCodeLastDigit = busData.route_code.slice(-1); // 检查是XYBS1还是XYBS2
      if (routeCodeLastDigit === '1') {
      const isRoute1 = busData.route_code === 'RC61';
      if (isRoute1) {
        //log car plate and route dir
        // console.log("Car plate: " + busData.id.slice(2,) + " Route dir: " + busData.route_dir);
        routeDirText = parseInt(busData.route_dir) === 0 ? '欣园 Joy Highland' : '工学院 COE';
      } else if (routeCodeLastDigit === '2') {
      } else if (busData.route_code === 'RC62') {
        routeDirText = parseInt(busData.route_dir) === 0 ? '欣园 Joy Highland' : '科研楼 Research BLDG.';
      } else {
        routeDirText = '未知'; // Fallback text in case neither condition is true
      }
      const LineColour = busData.route_code.slice(-1) === '1' ? '#f7911d': '#29abe2';
      const lineNumber = isRoute1 ? '1' : '2';
      const LineColour = isRoute1 ? '#f7911d': '#29abe2';
      const htmlContent = `
      <div style="margin-top: 0; font-size: 14px; margin: 0; color: #333; font-weight: bold;">
        粤B${busData.id.slice(2,)}
@@ -275,7 +278,7 @@ export default {
        ${busData.speed} km/h
      </p>
      <p style="margin: 0px 0; line-height: 1.4;">
        <span style="display: inline-block; background-color: ${LineColour}; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold;">Line ${busData.route_code.slice(-1)} 号线</span>
        <span style="display: inline-block; background-color: ${LineColour}; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold;">Line ${lineNumber} 号线</span>
      </p>
      <p style="font-size: 12px; margin: 0px 0; color: #666;">
        To往: <b>${routeDirText}</b>
+13 −11
Original line number Diff line number Diff line
@@ -48,13 +48,13 @@ export default {

      // 配置表,每条线路单独定义方向映射 & 颜色
      routeConfig: {
        NKDH1: {
        RC61: {
          name: 'L1',
          directions: { '0': '顺时针🔁CW', '1': '' },
          icon: 'https://bus.sustcra.com/static/icon/bus-icon-NKDH1.png',
          color: '#4ca963'
        },
        NKDH2: {
        RC62: {
          name: 'L2',
          directions: { '0': '逆时针🔄CCW', '1': '' },
          icon: 'https://bus.sustcra.com/static/icon/bus-icon-NKDH2.png',
@@ -69,7 +69,7 @@ export default {
      },

      // --- Data Placeholders ---
      geojson_NKDH1: [],
      geojson_RC61: [],
      predictionRoutes: {},
      sevPredictionHistory: {},

@@ -215,11 +215,11 @@ export default {

    async loadGeoJSONLines() {
      try {
        const [NKDH1Res] = await Promise.all([
        const [RC61Res] = await Promise.all([
          axios.get('https://bus.sustcra.com/static/lines/NKDH1_clockwise.json')
        ]);
        // console.log('NKDH1:', NKDH1Res.data);
        this.geojson_NKDH1 = NKDH1Res.data;
        // console.log('RC61:', RC61Res.data);
        this.geojson_RC61 = RC61Res.data;
      } catch (error) {
        console.error("Failed to fetch GeoJSON lines:", error);
      }
@@ -244,7 +244,7 @@ export default {
            key: 'sev-cw',
            routeName: 'CW',
            directionLabel: '顺时针 CW',
            color: this.routeConfig.NKDH1.color,
            color: this.routeConfig.RC61.color,
            lineGeoJSON: cwLineRes.data,
            stopGeoJSON: latestStationGeoJSON,
          },
@@ -252,7 +252,7 @@ export default {
            key: 'sev-ccw',
            routeName: 'CCW',
            directionLabel: '逆时针 CCW',
            color: this.routeConfig.NKDH2.color,
            color: this.routeConfig.RC62.color,
            lineGeoJSON: ccwLineRes.data,
            stopGeoJSON: latestStationGeoJSON,
          },
@@ -357,8 +357,8 @@ export default {

    setupMapLayers() {
      // 添加线路图层
      this.addRouteLayer('line1', this.geojson_NKDH1, '#747474');
      console.log("NKDH1 route layer added.");
      this.addRouteLayer('line1', this.geojson_RC61, '#747474');
      console.log("RC61 route layer added.");

      // 添加站点、建筑和校门图层
      // station 语义缩放
@@ -651,7 +651,9 @@ export default {
        //also fetch sev locations https://bus.sustcra.com/api/v2/monitor_sev_osm/
        const response_sev = await axios.get(`https://bus.sustcra.com/api/v2/monitor_sev_osm/`);

        this.busLocations = response.data;
        this.busLocations = response.data.filter(
            (bus) => bus.route_code === 'RC61' || bus.route_code === 'RC62'
        );
        this.sevLocations = response_sev.data;

        // merge busLocations and sevLocations
+326 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading