Skip to content

Commit

Permalink
fix: config upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyHeeead committed Sep 12, 2023
1 parent f297573 commit 899d05a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ VUE_APP_SUBCONVERTER_REMOTE_CONFIG = "https://raw.githubusercontent.com/tindy201
VUE_APP_SUBCONVERTER_DEFAULT_BACKEND = "https://api.wcc.best"

# 短链接后端
VUE_APP_MYURLS_DEFAULT_BACKEND = "https://suo.yt"
VUE_APP_MYURLS_API = "https://suo.yt/short"

# 文本托管后端
VUE_APP_CONFIG_UPLOAD_BACKEND = "https://api.wcc.best"
VUE_APP_CONFIG_UPLOAD_API = "https://oss.wcc.best/upload"

# 页面配置
VUE_APP_USE_STORAGE = true
Expand Down
55 changes: 24 additions & 31 deletions src/views/Subconverter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ const project = process.env.VUE_APP_PROJECT
const remoteConfigSample = process.env.VUE_APP_SUBCONVERTER_REMOTE_CONFIG
const gayhubRelease = process.env.VUE_APP_BACKEND_RELEASE
const defaultBackend = process.env.VUE_APP_SUBCONVERTER_DEFAULT_BACKEND + '/sub?'
const shortUrlBackend = process.env.VUE_APP_MYURLS_DEFAULT_BACKEND + '/short'
const configUploadBackend = process.env.VUE_APP_CONFIG_UPLOAD_BACKEND + '/config/upload'
const shortUrlBackend = process.env.VUE_APP_MYURLS_API
const configUploadBackend = process.env.VUE_APP_CONFIG_UPLOAD_API
const tgBotLink = process.env.VUE_APP_BOT_LINK
export default {
Expand Down Expand Up @@ -601,37 +601,30 @@ export default {
this.loading = true;
let data = new FormData();
data.append("password", this.uploadPassword);
data.append("config", this.uploadConfig);
this.$axios
.post(configUploadBackend, data, {
header: {
"Content-Type": "application/form-data; charset=utf-8"
}
})
.then(res => {
if (res.data.code === 0 && res.data.data.url !== "") {
this.$message.success(
"远程配置上传成功,配置链接已复制到剪贴板,有效期三个月望知悉"
);
let body = {
content: this.uploadConfig,
}
this.$axios.post(configUploadBackend, body).then(res => {
if (res.data.code === 0 && res.data.data.url !== "") {
this.$message.success(
"远程配置上传成功,配置链接已复制到剪贴板,有效期三个月望知悉"
);
// 自动填充至『表单-远程配置』
this.form.remoteConfig = res.data.data.url;
this.$copyText(this.form.remoteConfig);
// 自动填充至『表单-远程配置』
this.form.remoteConfig = res.data.data.url;
this.$copyText(this.form.remoteConfig);
this.dialogUploadConfigVisible = false;
} else {
this.$message.error("远程配置上传失败: " + res.data.msg);
}
})
.catch(() => {
this.$message.error("远程配置上传失败");
})
.finally(() => {
this.loading = false;
});
this.dialogUploadConfigVisible = false;
} else {
this.$message.error("远程配置上传失败: " + res.data.msg);
}
})
.catch(() => {
this.$message.error("远程配置上传失败");
})
.finally(() => {
this.loading = false;
});
},
confirmLoadConfig(){
// 怎么解析短链接的302和301...
Expand Down

1 comment on commit 899d05a

@vercel
Copy link

@vercel vercel bot commented on 899d05a Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.