In what context was Du Fu's poem "The Prime Minister of Shu" written?

This poem was written by Du Fu in the spring of the first year of the Yuan Dynasty (760) when he first visited Chengdu to visit Wuhou Temple. This is a seven-rhyme poem. The first couplet is about asking and answering questions about the scenery of Wuhou Temple. The evergreen pines and cypresses symbolize the longevity of Wuhou's fame. The chin couplet describes the scenery in the ancestral hall, reflecting on things and people, contrasting the permanence of nature with the changeable world and the eternal darkness of life. The neck couplet describes Zhuge Liang's talents, loyalty and immortal deeds, expressing his deep admiration. Wei Lian lamented that Wu Hou's great achievements were not accomplished. This poem was written after the author was frustrated in his official career and abandoned his official position to enter Shu. At that time, the Anshi Rebellion was not over, and the national crisis was still severe. In his poem, Du Fu highly praised Zhuge Liang who "dedicated himself to death", which has a profound meaning. "Ying Kui Lu Sui Review" quoted Ji Yun as saying: "The first four sentences are sparse and unrestrained, and the last four sentences suddenly become melancholy and extremely powerful." Zhao Xi said: "depressed and broad". "Detailed Notes on Du Shi": "'The plan of the world' reflects Kuang Shi's heroic strategy; 'the heart of an old minister' reflects the hardships of serving the country. These two sentences are deep and solemn and tragic, and they form a heart-wrenching and sour tone, which is the spirit."