A clever way is to insert page numbers.
When selecting the page number format, do not choose the format of-1-, -2- and -3-, but choose the format of "1, 2,3", and then manually add "-"at both ends of the page number, so that "-"will not be included in the generated directory. If you don't want to reinsert the page number, you can format the page number directly and then update the table of contents.