Skip to content

Commit

Permalink
Standardize and normalize code, standardize variable function naming
Browse files Browse the repository at this point in the history
Standardize and normalize code by renaming variables and functions for consistency and clarity.

* **src/axios/axios.js**
  - Rename `instance` to `axiosInstance`, `config` to `requestConfig`, and `data` to `responseData`.

* **src/components/AddTolist.vue**
  - Rename `lists` to `projectLists`, `NewProjectListDialog` to `newProjectListDialog`, `ProjectlistAdd` to `addProjectToList`, and `ProjectlistDelete` to `deleteProjectFromList`.

* **src/components/AppHeader.vue**
  - Rename `userinfo` to `userInfo`, `islogin` to `isLogin`, `clicklogout` to `clickLogout`, and `logoutbutton` to `logoutButton`.

* **src/components/Comment.vue**
  - Rename `comments` to `commentList`, `userinfo` to `userInfo`, `morecommnets` to `moreComments`, and `replyid` to `replyId`.

* **src/components/EditProjectListConfig.vue**
  - Rename `listinfo` to `listInfo`, `newlistinfo` to `newListInfo`, and `liststates` to `listStates`.

* **src/components/NewProjectList.vue**
  - Rename `projectinfo` to `projectInfo`, `newid` to `newId`, and `isVisible` to `isVisibleDialog`.

* **src/pages/account/index.vue**
  - Rename `UserInfo` to `userInfo`, `userinfo` to `userInfo`, `UserCardLoading` to `userCardLoading`, `oldpassword` to `oldPassword`, and `newpassword` to `newPassword`.

* **src/pages/projects/my.vue**
  - Rename `userinfo` to `userInfo`, `nowProject` to `currentProject`, `oldProject` to `previousProject`, and `abouttags` to `aboutTags`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ZeroCatDev/ZeroCatNext?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
SunWuyuan committed Nov 9, 2024
1 parent 5fe4c3b commit 77610c6
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 171 deletions.
18 changes: 9 additions & 9 deletions src/axios/axios.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import axios from "axios";
// 基本配置
const instance = axios.create({
const axiosInstance = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API, // 根据实际情况修改API地址
// timeout: 5000 // 设置超时时间,单位为ms
});

// 请求拦截器
instance.interceptors.request.use(
(config) => {
config.headers["Authorization"] = localStorage.getItem("token"); // 设置请求头部分,这里举例使用了localStorage存储的token作为身份标识
return config;
axiosInstance.interceptors.request.use(
(requestConfig) => {
requestConfig.headers["Authorization"] = localStorage.getItem("token"); // 设置请求头部分,这里举例使用了localStorage存储的token作为身份标识
return requestConfig;
},
(error) => {
console.log(error);
Expand All @@ -18,14 +18,14 @@ instance.interceptors.request.use(
);

// 响应拦截器
instance.interceptors.response.use(
axiosInstance.interceptors.response.use(
(response) => {
const data = response.data;
const responseData = response.data;
//if (data && data.code !== 200) { // 根据接口返回的状态码判断是否有错误
// alert(`Error code ${data.code}: ${data.message}`); // 自定义错误提示
// return Promise.reject(new Error(data.message));
//} else {
return data;
return responseData;
//}
},
(error) => {
Expand All @@ -35,4 +35,4 @@ instance.interceptors.response.use(
}
);

export default instance;
export default axiosInstance;
22 changes: 11 additions & 11 deletions src/components/AddTolist.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-list>
<div v-for="item in lists" :key="item.id">
<div v-for="item in projectLists" :key="item.id">
<v-list-item

:append-icon="
Expand All @@ -10,21 +10,21 @@
color="primary"
@click="
item.include == true
? ProjectlistDelete(item.id)
: ProjectlistAdd(item.id)
? deleteProjectFromList(item.id)
: addProjectToList(item.id)
"
>
<v-list-item-title> {{ item.title }}</v-list-item-title>
<v-list-item-subtitle>{{ item.description }}</v-list-item-subtitle>
</v-list-item>
</div>
<v-list-item @click="NewProjectListDialog = true">新建列表</v-list-item>
<v-list-item @click="newProjectListDialog = true">新建列表</v-list-item>
</v-list>

<v-dialog v-model="NewProjectListDialog">
<v-dialog v-model="newProjectListDialog">
<NewProjectList
:listid="editlistid"
:close="() => (NewProjectListDialog = false)"
:close="() => (newProjectListDialog = false)"
:callback="getProjectList"
>
</NewProjectList>
Expand All @@ -42,13 +42,13 @@ export default {
return {
localuser: localuser,
userinfo: localuser.user,
NewProjectListDialog: false,
lists: [],
newProjectListDialog: false,
projectLists: [],
};
},
methods: {
async getProjectList() {
this.lists = (
this.projectLists = (
await request({
url: "/projectlist/check?projectid=" + this.$route.params.id,
data: {
Expand All @@ -59,7 +59,7 @@ export default {
})
).data;
},
async ProjectlistAdd(id) {
async addProjectToList(id) {
await request({
url: "/projectlist/add",
data: {
Expand All @@ -78,7 +78,7 @@ export default {
this.getProjectList();
});
},
async ProjectlistDelete(id) {
async deleteProjectFromList(id) {
await request({
url: "/projectlist/delete",
data: {
Expand Down
32 changes: 16 additions & 16 deletions src/components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
>
<v-list>
<v-list-item
v-if="islogin == true"
:prepend-avatar="'https://s4-1.wuyuan.1r.ink/user/' + userinfo.avatar"
v-if="isLogin == true"
:prepend-avatar="'https://s4-1.wuyuan.1r.ink/user/' + userInfo.avatar"
rounded="xl"
:subtitle="userinfo.username"
:to="'/user/' + userinfo.userid"
:title="userinfo.display_name"
:subtitle="userInfo.username"
:to="'/user/' + userInfo.userid"
:title="userInfo.display_name"
></v-list-item>
<v-list-item
v-else
Expand Down Expand Up @@ -71,11 +71,11 @@ export default {
components: { NewProjectDialog },
data: () => ({
localuser: localuser,
userinfo: localuser.user,
userInfo: localuser.user,
drawer: true,
islogin: localuser.islogin,
clicklogout: 0,
logoutbutton: "退出",
isLogin: localuser.islogin,
clickLogout: 0,
logoutButton: "退出",
urltoken: "",
algolia_AppId: import.meta.env.VITE_APP_ALGOLIA_APP_ID,
items: {
Expand Down Expand Up @@ -121,7 +121,7 @@ export default {
this.drawer = drawerStatus === "true"; // 根据存储的值设置drawer
},
watch: {
userinfo(newName, oldName) {
userInfo(newName, oldName) {
this.$forceUpdate();
},
drawer(newVal) {
Expand All @@ -130,16 +130,16 @@ export default {
},
},
methods: {
trylogout() {
tryLogout() {
console.log(111);
if (this.clicklogout == 1) {
if (this.clickLogout == 1) {
this.$router.push("/account/logout");
this.clicklogout = 0;
this.logoutbutton = "退出";
this.clickLogout = 0;
this.logoutButton = "退出";
} else {
this.clicklogout = this.clicklogout + 1;
this.clickLogout = this.clickLogout + 1;
this.logoutbutton = "再点一次退出";
this.logoutButton = "再点一次退出";
}
},
},
Expand Down
54 changes: 27 additions & 27 deletions src/components/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
border
class="mb-2"
elevation
v-for="comment in comments"
v-for="comment in commentList"
:key="comment.id"
@click="showMore(comment)"
>
Expand Down Expand Up @@ -112,7 +112,7 @@
<v-img
:src="
'https://s4-1.wuyuan.1r.ink/user/' +
users[morecommnets.user_id].images
users[moreComments.user_id].images
"
></v-img>
</v-avatar>
Expand All @@ -124,42 +124,42 @@
</template>
<v-list border>
<v-list-item
v-if="morecommnets.user_id == localuser.user.userid"
v-if="moreComments.user_id == localuser.user.userid"
prepend-icon="mdi-delete"
@click="deleteCommnet({ id: morecommnets.id })"
@click="deleteCommnet({ id: moreComments.id })"
>
<v-list-item-title>删除</v-list-item-title>
</v-list-item>
<v-list-item
prepend-icon="mdi-reply"
@click="replyid = morecommnets.id"
@click="replyId = moreComments.id"
>
<v-list-item-title>回复</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>

</template>
<v-card-title :to="'/user/' + morecommnets.user_id">{{
users[morecommnets.user_id].display_name
<v-card-title :to="'/user/' + moreComments.user_id">{{
users[moreComments.user_id].display_name
}}</v-card-title>

<v-card-subtitle>
<TimeAgo :date="morecommnets.insertedAt" /> - ({{
UAParser(morecommnets.user_ua).browser.name
<TimeAgo :date="moreComments.insertedAt" /> - ({{
UAParser(moreComments.user_ua).browser.name
}}
-
{{
UAParser(morecommnets.user_ua).os.name +
UAParser(morecommnets.user_ua).os.version
}}) - {{ morecommnets.insertedAt }}
UAParser(moreComments.user_ua).os.name +
UAParser(moreComments.user_ua).os.version
}}) - {{ moreComments.insertedAt }}
</v-card-subtitle>
</v-card-item>
<v-card-text><Markdown>{{ morecommnets.text }}</Markdown></v-card-text>
<v-card-text><Markdown>{{ moreComments.text }}</Markdown></v-card-text>
</v-card>
<v-card
class="mb-2"
v-for="comment in morecommnets.children"
v-for="comment in moreComments.children"
:key="comment.id"
elevation
hover
Expand All @@ -180,7 +180,7 @@
<template v-slot:append>
<v-btn
icon="mdi-reply"
@click="replyid = comment.id"
@click="replyId = comment.id"
border
v-if="comment.user_id != localuser.user.userid"
>
Expand All @@ -199,7 +199,7 @@
</v-list-item>
<v-list-item
prepend-icon="mdi-reply"
@click="replyid = comment.id"
@click="replyId = comment.id"
>
<v-list-item-title>回复</v-list-item-title>
</v-list-item>
Expand All @@ -226,8 +226,8 @@

<v-card class="mt-4" elevation hover border>
<v-card-title class="headline"
>回复评论{{ replyid
}}<v-btn @click="replyid = null" v-if="replyid != null"
>回复评论{{ replyId
}}<v-btn @click="replyId = null" v-if="replyId != null"
>取消</v-btn
></v-card-title
>
Expand All @@ -245,8 +245,8 @@
color="primary"
@click="
addComment({
pid: replyid,
rid: morecommnets.id,
pid: replyId,
rid: moreComments.id,
commnet: comment,
})
"
Expand Down Expand Up @@ -295,15 +295,15 @@ export default {
url: this.url,
sort: "时间倒序",
sorttext: "insertedAt_desc",
comments: [],
commentList: [],
users: {},
page: 0,
totalPages: 0,
pageSize: 10,
count: 0,
loadbuttondisabled: false,
moredialog: false,
morecommnets: [],
moreComments: [],
localuser: localuser,
commentrules: [
(value) => {
Expand All @@ -312,7 +312,7 @@ export default {
},
],
comment: "",
replyid: "",
replyId: "",
UAParser,
};
},
Expand All @@ -323,7 +323,7 @@ export default {
getComments(info = {}) {
if (info.retry == true) {
this.page = 0;
this.comments = [];
this.commentList = [];
}
// 获取评论列表
request({
Expand All @@ -337,7 +337,7 @@ export default {
if (res.data.data.length == 0) {
this.loadbuttondisabled = true;
}
this.comments = this.comments.concat(res.data.data);
this.commentList = this.commentList.concat(res.data.data);
console.log(res.users);
res.users.forEach((user) => {
this.users[user.id] = user;
Expand Down Expand Up @@ -375,7 +375,7 @@ export default {
if (res.errno == 0) {
this.info = "评论成功";
this.comment = "";
this.replyid = null;
this.replyId = null;
this.getComments({ retry: true });
} else {
this.info = "评论失败";
Expand All @@ -399,7 +399,7 @@ export default {
});
},
showMore(info) {
this.morecommnets = info;
this.moreComments = info;
this.moredialog = true;
},
createDateFromMysql(mysql_string) {
Expand Down
Loading

0 comments on commit 77610c6

Please sign in to comment.