Skip to content

Commit

Permalink
chore: 修复 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dlzmoe committed Sep 5, 2024
1 parent cfc7c95 commit 854cbb8
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 125 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
- 修复:黑夜模式 UI
- 修复:用户标签删除失败 bug
- 修复:同步配置 bug
103 changes: 59 additions & 44 deletions dist/linuxdo-scripts.user.js

Large diffs are not rendered by default.

103 changes: 59 additions & 44 deletions linuxdo-scripts.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linuxdo-scripts",
"version": "0.3.23",
"version": "0.3.24",
"author": "dlzmoe",
"description": "An enhanced script for the linux.do forum",
"type": "module",
Expand Down
3 changes: 2 additions & 1 deletion src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<GPTconfig v-model:value="settingData.gptdata" />
</div>
<div class="menu-body-item">
<SyncBackup />
<SyncBackup v-model:value="settingData.syncbackup" />
</div>
</div>
</div>
Expand Down Expand Up @@ -481,6 +481,7 @@ export default {
// 从 localStorage 获取现有的设置数据
let existingData = JSON.parse(localStorage.getItem("linxudoscriptssetting"));
this.settingData = { ...this.settingData, ...existingData };
localStorage.setItem("linxudoscriptssetting", JSON.stringify(this.settingData));
Expand Down
69 changes: 45 additions & 24 deletions src/components/Sync/SyncBackup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<div class="tit">WebDav 地址:</div>
<input
type="text"
v-model="webdavUrl"
@input="handleChange"
v-model="tableData.webdavUrl"
@blur="handleChange"
placeholder="https://dav.xxxx.com/dav/"
/>
</div>
<div class="item">
<div class="tit">WebDav 用户名:</div>
<input type="text" v-model="webdavUsername" @input="handleChange" />
<input type="text" v-model="tableData.webdavUsername" @blur="handleChange" />
</div>
<div class="item">
<div class="tit">WebDav 密码:</div>
<input type="text" v-model="webdavPassword" @input="handleChange" />
<input type="text" v-model="tableData.webdavPassword" @blur="handleChange" />
</div>

<div class="btnwrapper">
Expand All @@ -24,21 +24,37 @@
</div>
<hr />
<!-- 手动导入导出 -->
<div style="margin:10px 0">手动导入导出数据:</div>
<div style="margin: 10px 0">手动导入导出数据:</div>
<ManualBackup />
</template>

<script>
import ManualBackup from "./ManualBackup.vue";
export default {
props: {
value: {
type: Object,
default: {
webdavUrl: "",
webdavUsername: "",
webdavPassword: "",
},
},
},
components: {
ManualBackup,
},
watch: {
value(newValue) {
this.tableData = newValue;
},
},
data() {
return {
webdavUrl: "",
webdavUsername: "",
webdavPassword: "",
tableData: this.value,
// webdavUrl: "",
// webdavUsername: "",
// webdavPassword: "",
};
},
methods: {
Expand All @@ -50,13 +66,15 @@ export default {
}, 3000);
},
handleChange() {
let linxudoscriptssetting =
JSON.parse(localStorage.getItem("linxudoscriptssetting")) || [];
this.$emit("update:value", this.tableData);
let linxudoscriptssetting = JSON.parse(localStorage.getItem("linxudoscriptssetting"));
let data = {
webdavUrl: this.webdavUrl,
webdavUsername: this.webdavUsername,
webdavPassword: this.webdavPassword,
webdavUrl: this.tableData.webdavUrl,
webdavUsername: this.tableData.webdavUsername,
webdavPassword: this.tableData.webdavPassword,
};
linxudoscriptssetting.syncbackup = data;
localStorage.setItem(
"linxudoscriptssetting",
Expand All @@ -71,7 +89,8 @@ export default {
url: folderUrl,
headers: {
Authorization:
"Basic " + btoa(`${this.webdavUsername}:${this.webdavPassword}`),
"Basic " +
btoa(`${this.tableData.webdavUsername}:${this.tableData.webdavPassword}`),
Depth: "1", // 只检查一层
},
onload: function (response) {
Expand Down Expand Up @@ -99,7 +118,8 @@ export default {
url: folderUrl,
headers: {
Authorization:
"Basic " + btoa(`${this.webdavUsername}:${this.webdavPassword}`),
"Basic " +
btoa(`${this.tableData.webdavUsername}:${this.tableData.webdavPassword}`),
},
onload: function (response) {
if (response.status === 201) {
Expand All @@ -118,7 +138,7 @@ export default {
// 检查并创建文件夹
async checkAndCreateFolder() {
const folderUrl = `${this.webdavUrl}linuxdo-scripts-backup/`;
const folderUrl = `${this.tableData.webdavUrl}linuxdo-scripts-backup/`;
try {
const exists = await this.checkFolderExists(folderUrl);
Expand All @@ -138,7 +158,7 @@ export default {
return;
}
const uploadUrl = `${this.webdavUrl}linuxdo-scripts-backup/data.json`;
const uploadUrl = `${this.tableData.webdavUrl}linuxdo-scripts-backup/data.json`;
try {
const uploadResponse = await this.uploadFile(uploadUrl, fileData);
Expand All @@ -161,7 +181,8 @@ export default {
headers: {
"Content-Type": "text/plain",
Authorization:
"Basic " + btoa(`${this.webdavUsername}:${this.webdavPassword}`),
"Basic " +
btoa(`${this.tableData.webdavUsername}:${this.tableData.webdavPassword}`),
},
onload: function (response) {
if (response.status >= 200 && response.status < 300) {
Expand All @@ -184,7 +205,8 @@ export default {
url: url,
headers: {
Authorization:
"Basic " + btoa(`${this.webdavUsername}:${this.webdavPassword}`),
"Basic " +
btoa(`${this.tableData.webdavUsername}:${this.tableData.webdavPassword}`),
},
onload: function (response) {
if (response.status >= 200 && response.status < 300) {
Expand All @@ -205,11 +227,10 @@ export default {
},
// 下载
async downloadSampleFile() {
const downloadUrl = `${this.webdavUrl}linuxdo-scripts-backup/data.json`;
const downloadUrl = `${this.tableData.webdavUrl}linuxdo-scripts-backup/data.json`;
try {
const downloadResponse = await this.downloadFile(downloadUrl);
console.log(JSON.parse(downloadResponse));
localStorage.setItem("linxudoscriptssetting", downloadResponse);
this.messageToast("下载成功,即将刷新页面!");
Expand All @@ -226,9 +247,9 @@ export default {
const linxudoscriptssetting =
JSON.parse(localStorage.getItem("linxudoscriptssetting")) || [];
if (linxudoscriptssetting) {
this.webdavUrl = linxudoscriptssetting.syncbackup.webdavUrl;
this.webdavUsername = linxudoscriptssetting.syncbackup.webdavUsername;
this.webdavPassword = linxudoscriptssetting.syncbackup.webdavPassword;
this.tableData.webdavUrl = linxudoscriptssetting.syncbackup.webdavUrl;
this.tableData.webdavUsername = linxudoscriptssetting.syncbackup.webdavUsername;
this.tableData.webdavPassword = linxudoscriptssetting.syncbackup.webdavPassword;
}
},
};
Expand Down
4 changes: 0 additions & 4 deletions src/components/UserTags/UserTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ export default {
type: String,
default: "",
},
sort: {
type: Number,
required: true,
},
},
data() {
return {
Expand Down
4 changes: 4 additions & 0 deletions version-log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.24

- 修复:同步配置 bug

## 0.3.23

- 修复:黑夜模式 UI
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,6 @@ vite@^5.2.12:
optionalDependencies:
fsevents "~2.3.3"

vue-toast-notification@^3:
version "3.1.2"
resolved "https://registry.npmmirror.com/vue-toast-notification/-/vue-toast-notification-3.1.2.tgz#55106acc4f2c17ecf84468ee9435b97fc7106748"
integrity sha512-oNRL/W9aaHoeScp+iTIW7k09vM16/+8aptp2maa+7qTB43JuxmAgKdXKFYtf+uvSNOYYq2BIWgLCeJ61pwom/A==

vue@^3.4.27:
version "3.4.38"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.4.38.tgz#0ccbb64ed03ef3c4ab73e540793290b18e7c4236"
Expand Down

0 comments on commit 854cbb8

Please sign in to comment.