The use of renewable energy and storage systems in energy sharing communities relieves the strain on the grid and reduces the cost of electricity, making the design of community energy management strategies particularly important. In this paper, a shared energy storage operation strategy considering the time-of-use tariff is proposed for the grid-connected PV-BESS system of hybrid building community including factories, offices and dormitories. Aiming at maximizing the photovoltaic self-consumption ratio, minimizing the payback period and power transportation loss, the system is optimized by non-dominated sequencing genetic algorithm II to obtain the optimal battery capacity of each building under the designed strategy. The results show that when the total battery capacity of the community is determined, the photovoltaic power generation of each building and the building load are the main factors that affect the allocation of battery capacity, and the proportion of battery allocation in each building changes little when the values of other influencing parameters are changed. The photovoltaic array area of the building, the difference between peak and valley electricity price and the power input and output limits of the grid are the main factors affecting the optimal battery capacity and system performance. When the photovoltaic array area increases from 65% to 80%, the difference between peak and valley price increases from 0.52RMB/kWh to 0.82RMB/kWh, and the grid power output limit increases from 7500 kW to 9000 kW, the total optimal battery capacity is increased by 9.8%, 20%, 2.2%, the corresponding payback period is increased by 4%, 3.1%, 2%, the photovoltaic self-consumption ratio is increased by 3.3%, 1.9%, 0.2%, and the electricity transportation loss is increased by 6%, 21%, 2.4%, respectively. On the contrary, when the grid power input limit increases from 5500 kW to 7000 kW, the optimal total battery capacity, the corresponding payback period, photovoltaic self-consumption ratio, and power transport loss are reduced by 2.8%, 2.5%, 0.3% and 3.3%, respectively. This study provides theoretical guidance for community battery capacity optimization and energy scheduling design under the peak-valley policy of power grid.