diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 57df786a..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: BuildStatic - -on: - push: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14' - - - name: build front and back - run: | - yarn install - yarn build - yarn build-back - - - name: copy to static repo - env: - # GITHUB_REPO: gitee.com/whyour/qinglong-static - GITHUB_REPO: github.com/whyour/qinglong-static - run: | - mkdir -p static - cd ./static - cp -rf ../dist ./ && cp -rf ../build ./ - git init && git add . - git config user.name "whyour" - git config user.email "imwhyour@gmail.com" - git commit --allow-empty -m "copy static at $(date +'%Y-%m-%d %H:%M:%S')" - git push --force --quiet "https://whyour:${{ secrets.API_TOKEN }}@${GITHUB_REPO}.git" master:master \ No newline at end of file diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index e9407441..9066795b 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -67,8 +67,8 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Login to GHCR uses: docker/login-action@v1 diff --git a/back/api/script.ts b/back/api/script.ts index 0e04e545..83391e28 100644 --- a/back/api/script.ts +++ b/back/api/script.ts @@ -18,33 +18,47 @@ export default (app: Router) => { const fileList = fs.readdirSync(config.scriptPath, 'utf-8'); res.send({ code: 200, - data: fileList.map((x) => { - if (fs.lstatSync(config.scriptPath + x).isDirectory()) { - const childFileList = fs.readdirSync( - config.scriptPath + x, - 'utf-8', - ); - return { - title: x, - value: x, - key: x, - disabled: true, - children: childFileList.map((y) => { - const statObj = fs.statSync(`${config.scriptPath}${x}/${y}`); - return { - title: y, - value: y, - key: y, - mtime: statObj.mtimeMs, - parent: x, - }; - }), - }; - } else { - const statObj = fs.statSync(config.scriptPath + x); - return { title: x, value: x, key: x, mtime: statObj.mtimeMs }; - } - }), + data: fileList + .map((x) => { + if (fs.lstatSync(config.scriptPath + x).isDirectory()) { + const childFileList = fs.readdirSync( + config.scriptPath + x, + 'utf-8', + ); + const dirStat = fs.statSync(`${config.scriptPath}${x}`); + return { + title: x, + value: x, + key: x, + mtime: dirStat.mtimeMs, + disabled: true, + children: childFileList + .filter( + (y) => + !fs + .lstatSync(`${config.scriptPath}${x}/${y}`) + .isDirectory(), + ) + .map((y) => { + const statObj = fs.statSync( + `${config.scriptPath}${x}/${y}`, + ); + return { + title: y, + value: y, + key: y, + mtime: statObj.mtimeMs, + parent: x, + }; + }) + .sort((a, b) => b.mtime - a.mtime), + }; + } else { + const statObj = fs.statSync(config.scriptPath + x); + return { title: x, value: x, key: x, mtime: statObj.mtimeMs }; + } + }) + .sort((a, b) => b.mtime - a.mtime), }); } catch (e) { logger.error('🔥 error: %o', e); diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx index c028c081..7813f2ca 100644 --- a/src/pages/script/index.tsx +++ b/src/pages/script/index.tsx @@ -76,10 +76,8 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { request .get(`${config.apiPrefix}scripts/files`) .then((data) => { - const sortData = data.data.sort((a: any, b: any) => b.mtime - a.mtime); - setData(sortData); - setFilterData(sortData); - onSelect(sortData[0].value, sortData[0]); + setData(data.data); + setFilterData(data.data); }) .finally(() => setLoading(false)); };