The aptamers functionalized orange-emission carbon dots (OCDs) and green-emission carbon dots (GCDs) had dual-emission peaks with single excitation. Tungsten disulfide nanosheets (WS2 NSs)-triggered fluorescence quenching achieved the ratiometric fluorescence determination of Escherichia coli O157:H7 (E. coli O157:H7) and Staphylococcus aureus (S. aureus) with wide ranges of 18–1.8 × 106 and 37–3.7 × 107 CFU/mL and low detection limits of 8 and 20 CFU/mL, respectively. The results in real sample with recoveries of 90–101 % and RSD < 4.12 % were no significant difference from standard plate counting method. Meanwhile, the dual-color CDs were further adopted in the smartphone-assisted hydrogel platform and achieved speedy, sensitive, portable and real-time determination of E. coli O157:H7 and S. aureus in real samples. This work has not only developed ratiometric fluorescence detection and constructed a portable hydrogel platform, but also provided a unique strategy in developing a time-efficient and easy-to-use portable device in food safety monitoring.