The capacity optimization configuration of offshore wind power and hydrogen production systems has traditionally focused on initial investment and cost-benefit analysis during the project construction lifecycle, neglecting considerations of scheduling economy in the system's actual operation. This article presents a novel approach to optimize the allocation mechanism of grid power and hydrogen production power in offshore wind farms with the aim of maximizing net income. The study employs simulations to assess the hydrogen production scenario for a 1000 MW Sheyang offshore wind power facility under various offshore distance scenarios across different seasons. Results indicate that peak shaving through electrolysis is most effective during autumn, yielding substantial benefits. Electrolysis cells can achieve peak shaving operation ranging from 6 MW to 300 MW, constituting 26.5% of the total electricity generated for hydrogen production.