diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3b6a315..d4e83c4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,39 +1,23 @@ -name: Build and Package - +name: Deploy To Github pages +permissions: + contents: write on: - push: - branches: - - main # 触发条件:当代码推送到主分支时触发 - + push jobs: - build: - runs-on: ubuntu-latest # 在 Ubuntu 环境下运行 - + build-and-deploy: + runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v2 # 检出存储库代码 - - - name: Delete yarn.lock - run: rm yarn.lock # 删除 yarn.lock 文件 - - - name: Set up Node.js - uses: actions/setup-node@v2 + - name: Checkout + uses: actions/checkout@v2 with: - node-version: 18 # 设置 Node.js 版本为 18.x - - - name: Install Dependencies - run: yarn install # 使用 yarn 安装依赖 - - - name: Build - run: yarn build # 运行构建命令 - - - name: Package Dist Folder + persist-credentials: false + - name: Install and Build run: | - zip -r dist.zip dist # 将 dist 文件夹打包成 zip 文件 - # mv dist.zip $GITHUB_WORKSPACE/dist.zip # 将 zip 文件移动到工作目录 - - - name: Upload Artifact - uses: actions/upload-artifact@v2 + yarn + yarn build + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4.2.2 with: - name: dist # 构建产物的名称 - path: dist # 上传的文件路径 + branch: gh-pages + folder: dist + \ No newline at end of file diff --git a/src/page/infer.vue b/src/page/infer.vue index daec178..2acb353 100644 --- a/src/page/infer.vue +++ b/src/page/infer.vue @@ -46,23 +46,31 @@ const autocomplete_options = computed(() => }; }) ); -const infer_fn = async () => { - isloading.value = true; - const data = await infer({ - lang: "zh", - appid: "9tuof1o8y7ni8h3e", - text: text.value, - speaker: spk.value as unknown as string, - sdp_ratio: sdp_dp.value, - noise: noise.value, - noisew: noisew.value, - length: (100 - length.value)/100, - token: store.token.value as string, - }); - audio_url.value = data.audio; - isloading.value = false; - notification.info({ content: data.message.replace(/(?:\\r\\n|\\r|\\n)/g, '\n'), duration: 10000 }); +const infer_fn = async () => { + try { + isloading.value = true; + const data = await infer({ + lang: "zh", + appid: "9tuof1o8y7ni8h3e", + text: text.value, + speaker: spk.value as unknown as string, + sdp_ratio: sdp_dp.value, + noise: noise.value, + noisew: noisew.value, + length: (100 - length.value)/100, + token: store.token.value as string, + }); + audio_url.value = data.audio; + isloading.value = false; + notification.info({ content: data.message.replace(/(?:\\r\\n|\\r|\\n)/g, '\n'), duration: 10000 }); + } catch(e) { + notification.error({ + content: "API 调用失败,请联系网站维护者", + duration: 3000 + }) + console.error(e) + } }; const onAudioCanplay = (payload: Event) => { diff --git a/src/page/login.vue b/src/page/login.vue index 1ca1e24..26e6d43 100644 --- a/src/page/login.vue +++ b/src/page/login.vue @@ -24,19 +24,27 @@ const email = ref("") const router = useRouter() const store = useUserStore() const login = async () => { - const data = await user.login({lang: "zh",email: email.value,password: pwd.value,mac: ""}) - if(data.token) { - store.token.value = data.token - notification.success({ - content: data.message.replace(/(?:\\r\\n|\\r|\\n)/g, '\n'), - duration: 5000 - }) - router.push("/infer") - } else { + try { + const data = await user.login({lang: "zh",email: email.value,password: pwd.value,mac: ""}) + if(data.token) { + store.token.value = data.token + notification.success({ + content: data.message.replace(/(?:\\r\\n|\\r|\\n)/g, '\n'), + duration: 5000 + }) + router.push("/infer") + } else { + notification.error({ + content: data.message, + duration: 3000 + }) + } + } catch(e) { notification.error({ - content: data.message, + content: "API 调用失败,请联系网站维护者", duration: 3000 }) + console.error(e) } }