Skip to content

Commit

Permalink
feat: api error notice
Browse files Browse the repository at this point in the history
build: update script
  • Loading branch information
HuanLinOTO authored Apr 20, 2024
1 parent 6d55558 commit c891458
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
50 changes: 17 additions & 33 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
name: dist # 构建产物的名称
path: dist # 上传的文件路径
branch: gh-pages
folder: dist

40 changes: 24 additions & 16 deletions src/page/infer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
28 changes: 18 additions & 10 deletions src/page/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit c891458

Please sign in to comment.