Skip to content

Commit

Permalink
fix:不能改头像、未登录不能访问我的地盘、静态资源目录
Browse files Browse the repository at this point in the history
  • Loading branch information
eee555 committed May 14, 2024
1 parent c5a6799 commit 6970af5
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 34 deletions.
5 changes: 4 additions & 1 deletion back_end/saolei/article/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
def update_list(request):
if (request.user.is_staff or request.user.is_superuser) and request.method == 'GET':
# if 1:
article_dir = settings.BASE_DIR / "assets" / 'article'
if settings.DEBUG:
article_dir = settings.BASE_DIR / "assets" / 'article'
else:
article_dir = os.path.join(settings.MEDIA_ROOT, 'assets/article')
articles: List[str] = os.listdir(article_dir)
# 先清空已有
while cache.llen("articles") > 0:
Expand Down
2 changes: 1 addition & 1 deletion back_end/saolei/monitor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_capacity(request):
if settings.DEBUG:
video_size = get_dir_size(os.path.join(settings.BASE_DIR, 'assets/videos'))
else:
video_size = get_dir_size(os.path.join(settings.MEDIA_ROOT, 'videos'))
video_size = get_dir_size(os.path.join(settings.MEDIA_ROOT, 'assets/videos'))
# 内存占用情况
virtual = psutil.virtual_memory()
return JsonResponse({"d_t": disk.total, "d_u": disk.used, "v": video_size,
Expand Down
2 changes: 1 addition & 1 deletion back_end/saolei/msuser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def update_realname(request):
@login_required(login_url='/')
def update_avatar(request):
if request.method == 'POST':
if request.user.userms.e_timems_std >= 200:
if request.user.userms.e_timems_std >= 200000:
return JsonResponse({"status": 177, "msg": "只允许标准高级sub200的玩家修改头像和个性签名!"})
user_update_form = UserUpdateAvatarForm(
data=request.POST, files=request.FILES, request=request)
Expand Down
2 changes: 1 addition & 1 deletion back_end/saolei/refresh_font_end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://gitee.com/ee55/saolei_website_article.git
cp -r saolei_website_article/* ./
rm -r .git
rm LICENSE
rm -r /saolei_website_article
rm -r saolei_website_article
cd ..
cd ..

Expand Down
94 changes: 94 additions & 0 deletions front_end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 25 additions & 15 deletions front_end/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<template>
<!-- message的z索引为2015 -->
<el-menu style=" position: fixed; width: 100%; height: 60px; top: 0; z-index: 2010;user-select: none;"
mode="horizontal">
<el-menu-item index="1">
<div @click="goback_home()" class="logo"
mode="horizontal" :router="true" :default-active="menu_index">
<el-menu-item index="/">
<div @click="goback_home();" class="logo"
style="display: inline-flex;justify-content: center;align-items: center;">
<el-image style="width: 52px; height: 52px;display: inline-flex;" :src="logo_1" :fit="'cover'" />
<el-image style="width: 131px; height: 60px;display: inline-flex;" :src="logo_2" :fit="'cover'" />
</div>
</el-menu-item>
<el-menu-item index="2" @click="router.push('/ranking')">
<el-menu-item index="/ranking">
<div class="header">排行榜</div>
</el-menu-item>
<el-menu-item index="3" @click="router.push('/video')">
<el-menu-item index="/video">
<div class="header">录像</div>
</el-menu-item>
<el-menu-item index="4" @click="router.push('/world')">
<el-menu-item index="/world">
<div class="header">统计</div>
</el-menu-item>
<el-menu-item index="5" @click="router.push('/guide')">
<el-menu-item index="/guide">
<div class="header">教程</div>
</el-menu-item>
<el-menu-item index="6" @click="router.push('/score')">
<el-menu-item index="/score">
<div class="header">积分</div>
</el-menu-item>
<el-menu-item index="7" @click="router.push('/player/' + proxy.$store.state.user.id)">
<el-menu-item :index="player_url" :disabled="proxy.$store.state.user.id == 0">
<div class="header">我的地盘</div>
</el-menu-item>
<div
Expand Down Expand Up @@ -68,9 +68,9 @@
</template>

<script setup lang='ts'>
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, onMounted, computed } from 'vue'
import Menu from "./components/Menu.vue";
import { LoginStatus } from "@/utils/common/structInterface"
// import { LoginStatus } from "@/utils/common/structInterface"
import useCurrentInstance from "@/utils/common/useCurrentInstance";
const { proxy } = useCurrentInstance();
const logo_1 = ref(require('@/assets/logo.png'))
Expand All @@ -82,9 +82,9 @@ const router = useRouter()
// const player_visibile = ref(false)
const notice_visible = ref(false)
const never_show_notice = ref(false)
const tab_width = ref("16%")
// let refLogin = ref<any>(null)
// 主要是切换后的高亮
const menu_index = ref()
const notice = ref(`
1、即日起开始删档公测,公测与开发同步进行。公测结束后,在正式上线之前会删除所有数据。
Expand All @@ -98,22 +98,32 @@ onMounted(() => {
notice_visible.value = true;
}
console.log(`
元扫雷网(fff666.top)开发团队,期待您的加入: [email protected]
`);
router.isReady().then(() => { menu_index.value = router.currentRoute.value.fullPath; })
})
const player_url = computed(() => {
return '/player/' + proxy.$store.state.user.id;
})
const user_login = () => {
// player_visibile.value = true;
// tab_width.value = "14vw";
}
const user_logout = () => {
// player_visibile.value = false;
// tab_width.value = "16vw";
proxy.$store.commit('updateUser', {
id: 0,
username: '',
realname: '',
is_banned: false
});
menu_index.value = "/";
proxy.$router.push("/");
}
Expand Down
9 changes: 5 additions & 4 deletions front_end/src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ const login = () => {
user_name_show.value = response.data.msg.username;
proxy.$store.commit('updateUser', response.data.msg);// 当前登录用户
if (localStorage.getItem("player") === null) {
// 解决刷新后改成用户自己
localStorage.setItem("player", JSON.stringify(response.data.msg));
}
// if (localStorage.getItem("player") === null) {
// // 解决刷新后改成用户自己
// localStorage.setItem("player", JSON.stringify(response.data.msg));
// }
// proxy.$store.commit('updatePlayer', response.data.msg);// 看我的地盘看谁的
if (response.data.msg.is_banned) {
user_name_show.value += "(您已被封禁,详情请询问管理员!)"
Expand Down Expand Up @@ -318,6 +318,7 @@ const retrieve = () => {
hint_message.value = "";
user_name_show.value = response.data.msg;
login_status.value = LoginStatus.IsLogin;
proxy.$store.commit('updateUser', response.data.msg);// 当前登录用户
emit('login'); // 向父组件发送消息
retrieve_visibile.value = false;
ElMessage.success({ message: '修改密码成功!', offset: 68 });
Expand Down
4 changes: 3 additions & 1 deletion front_end/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { createStore } from 'vuex'
export default createStore({
state: {
user: {
// 此id为用户的id从1开始,而不是数据库的自增id
id: 0,
username: "",
realname: "",
is_banned: false
}, // 真正的用户
// player: [], // 访问我的地盘(放弃。放到localstorage)
// 访问谁的地盘不再具有记忆性。即点“我的地盘”,将永远是“我”的地盘
// 想要访问特定用户,可以用url
},
getters: {

Expand Down
11 changes: 1 addition & 10 deletions front_end/src/views/PlayerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,9 @@ const upload_info = () => {
// 把头像、姓名、个性签名传上去。至少头像改过了。
const handleAvatarUpload = async (options: UploadRequestOptions) => {
// console.log("****" + realname_edit.value);
// console.log("----" + realname.value);
if (realname_edit.value != realname.value) {
post_update_realname(realname_edit.value);
}
// console.log("34554" + signature_edit.value);
// console.log("5654" + signature.value);
if (signature_edit.value != signature.value) {
post_update_signature(signature_edit.value);
Expand Down Expand Up @@ -318,18 +313,14 @@ const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
return false
}
return new Promise((resolve, reject) => {
// 此处会报错net::ERR_FILE_NOT_FOUND,但头像依然能更新成功
compressAccurately(rawFile, 256).then(res => {
res = new File([res], rawFile.name, { type: res.type, lastModified: Date.now() })
resolve(res)
})
})
}
</script>


Expand Down

0 comments on commit 6970af5

Please sign in to comment.