Based on first-principles calculations, the electronic structure, magnetic properties and optical characteristics of intrinsic monolayer MoS
2 and different concentrations of Ru-doped (replacing Mo/S atoms) systems were systematically studied. The results indicate that intrinsic monolayer MoS
2 is a direct bandgap semiconductor with a bandgap of 1.724 eV. When Ru replaces Mo atom, the system gradually transforms into an
n-type metal with increasing doping concentration, the bandgap decreases to 0.28eV and then closes, with negligible magnetism. When Ru replaces S atom, the bandgap decreases significantly, with values of 1.086 eV and 0.083 eV at concentrations of 5.55% and 12.5%, respectively. At a concentration of 25%, the system becomes metallic, accompanied by the generation of magnetism and the increase of magnetic moment with concentration, and spin polarization induces additional electron transition channels.The density of states(DOS) analysis shows that when Ru replaces Mo, it is due to the injection of donor electrons and orbital hybridization, which causes the Fermi level to enter the conduction band. When Ru replaces S, it introduces Ru-4d and Mo-4d hybridized localized impurity levels in the bandgap, reducing the electron transition energy barrier. Magnetic analysis further shows that the weak magnetism in the Ru-Mo system originates from lattice polarization induced by carrier filling. The strong magnetism in the Ru-S system arises from spin splitting caused by strong orbital coupling between Ru-4d and Mo-4d states. In terms of optical properties, visible and near-infrared absorption are enhanced by Ru doping, while ultraviolet absorption is suppressed. For the Ru-Mo system, the dielectric response in the low-energy region increases significantly with concentration, and the characteristic peak exhibits a blue shift, which is primarily attributed to the Drude effect of free carriers. For the Ru-S system, the dielectric response is weaker, and the characteristic peak shows a red shift, resulting from the influence of spin-polarized impurity levels on interband transitions.This study elucidates the distinct effects of Ru doping sites and concentrations on the optoelectronic properties of MoS
2, providing a theoretical foundation for the design of related optoelectronic devices.