我想嵌套类别,但没有预定义级别数 可能有3-5个级别,具体取决于几个因素。
因此1级将是“categoryX / 1”,2级“categoryX / 1 / categoryY / 2”等......
现在我们有这样的路线,但它确实让事情变得更难了,所以我真的希望有一个解决方案。
{
path: ':name/:id', component: CategoryPageComponent,
children: [
{
path: ':name/:id/:name/:id',
component: CategorySubPageComponent,
},
{
path: ':name/:id',
component: CategorySubPageComponent,
},
{
path: '', component: CategorySubPageComponent,
},
]
}
答案 0 :(得分:0)
这有点晚了,但是...这可能起作用:
import math #import needed modules
import pyaudio #sudo apt-get install python-pyaudio
PyAudio = pyaudio.PyAudio #initialize pyaudio
sequence = 'AGCT' #if you make this longer (with 'A','G','T' or'C') it will play more, but never everything
LENGTH = 0.5
BITRATE = 44000
NUMBEROFFRAMES = int(BITRATE * LENGTH)
RESTFRAMES = (NUMBEROFFRAMES % BITRATE) % 2
WAVEDATA=""
for base in sequence:
if base == 'A':
FREQUENCY = 300
for x in range(NUMBEROFFRAMES):
WAVEDATA = WAVEDATA+chr(int(math.sin(x/((BITRATE/FREQUENCY)/math.pi))*127+128))
for x in range(RESTFRAMES):
WAVEDATA = WAVEDATA+chr(128)
elif base == 'G':
FREQUENCY = 600
for x in range(NUMBEROFFRAMES):
WAVEDATA = WAVEDATA+chr(int(math.sin(x/((BITRATE/FREQUENCY)/math.pi))*127+128))
for x in range(RESTFRAMES):
WAVEDATA = WAVEDATA+chr(128)
elif base == 'C':
FREQUENCY = 900
for x in range(NUMBEROFFRAMES):
WAVEDATA = WAVEDATA+chr(int(math.sin(x/((BITRATE/FREQUENCY)/math.pi))*127+128))
for x in range(RESTFRAMES):
WAVEDATA = WAVEDATA+chr(128)
elif base == 'T':
FREQUENCY = 1200
for x in range(NUMBEROFFRAMES):
WAVEDATA = WAVEDATA+chr(int(math.sin(x/((BITRATE/FREQUENCY)/math.pi))*127+128))
for x in range(RESTFRAMES):
WAVEDATA = WAVEDATA+chr(128)
p = PyAudio()
stream = p.open(format = p.get_format_from_width(1),
channels = 2,
rate = BITRATE,
output = True)
stream.write(WAVEDATA)
stream.stop_stream()
stream.close()
p.terminate()
或类似的东西。但是,如果您不需要使用id来构造它,这绝对可以解决问题:
{
path: ':name/:id', component: CategoriesComponent,
children: [
{
path: '**/:name/:id',
component: CategoriesComponent
}
]
}