Browse Source

修复上传/下载存档BUG

v1.0
许孟阳 6 days ago
parent
commit
8c7196190f
  1. 2
      java/src/main/java/vip/xumy/idle/server/ctrl/ArchiveController.java
  2. 17
      java/src/main/java/vip/xumy/idle/server/mapper/IArchiveMapper.java
  3. 1
      java/src/main/java/vip/xumy/idle/server/pojo/Archive.java
  4. 5
      java/src/main/java/vip/xumy/idle/server/service/ArchiveService.java
  5. 4
      src/api/index.ts
  6. 18
      src/views/archive.vue
  7. 10
      src/views/login.vue

2
java/src/main/java/vip/xumy/idle/server/ctrl/ArchiveController.java

@ -43,7 +43,7 @@ public class ArchiveController {
if (archive == null) { if (archive == null) {
return new BaseResponse(false, "未查询到你的存档"); return new BaseResponse(false, "未查询到你的存档");
} }
return new BaseResponse(true, archive.getArchive()); return new BaseResponse(archive.getArchive());
} }
} }

17
java/src/main/java/vip/xumy/idle/server/mapper/IArchiveMapper.java

@ -1,12 +1,14 @@
package vip.xumy.idle.server.mapper; package vip.xumy.idle.server.mapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vip.xumy.idle.server.pojo.Archive; import vip.xumy.idle.server.pojo.Archive;
/** Ownership belongs to the company /**
* Ownership belongs to the company
* *
* @author:mengyxu * @author:mengyxu
* @date:2025年5月19日 * @date:2025年5月19日
@ -15,4 +17,17 @@ import vip.xumy.idle.server.pojo.Archive;
@Mapper @Mapper
public interface IArchiveMapper extends BaseMapper<Archive> { public interface IArchiveMapper extends BaseMapper<Archive> {
@Update("""
UPDATE archive
SET
lv = #{lv},
coins = #{coins},
strengthen_lv= #{strengthenLv} ,
archive = #{archive}
WHERE
username = #{username}
and version = #{version}
""")
void update(Archive archive);
} }

1
java/src/main/java/vip/xumy/idle/server/pojo/Archive.java

@ -21,6 +21,7 @@ public class Archive {
private String version; private String version;
private int lv; private int lv;
private long coins; private long coins;
private int strengthenLv;
private String archive; private String archive;
} }

5
java/src/main/java/vip/xumy/idle/server/service/ArchiveService.java

@ -8,7 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import vip.xumy.idle.server.mapper.IArchiveMapper; import vip.xumy.idle.server.mapper.IArchiveMapper;
import vip.xumy.idle.server.pojo.Archive; import vip.xumy.idle.server.pojo.Archive;
/** Ownership belongs to the company /**
* Ownership belongs to the company
* *
* @author:mengyxu * @author:mengyxu
* @date:2025年5月19日 * @date:2025年5月19日
@ -24,7 +25,7 @@ public class ArchiveService {
if (exit == null) { if (exit == null) {
archiveMapper.insert(archive); archiveMapper.insert(archive);
} else { } else {
archiveMapper.updateById(archive); archiveMapper.update(archive);
} }
} }

4
src/api/index.ts

@ -16,6 +16,6 @@ export const getUser = () => {
export const uploadArchive = (archive) => { export const uploadArchive = (archive) => {
return post(urls.archive, archive); return post(urls.archive, archive);
}; };
export const downArchive = () => { export const downArchive = (param) => {
return get(urls.archive); return get(urls.archive, param);
}; };

18
src/views/archive.vue

@ -38,6 +38,15 @@ const showArchive = computed(() => {
const archive = ref(''); const archive = ref('');
const key = 'KUf4hM5rThssysJhcRFCfxLR8Imihjl0eMsyhh1M7Wk'; const key = 'KUf4hM5rThssysJhcRFCfxLR8Imihjl0eMsyhh1M7Wk';
let timeOut = 0; let timeOut = 0;
const strengthenLv = computed(() => {
const player = state.playerAttribute;
const equips = [player.weapon, player.armor, player.neck, player.ring, player.jewelry, player.pants, player.shoes, player.bracers];
let lv = 0;
equips.forEach(equip => {
equip && (lv += equip.strengthenLv)
})
return lv;
});
const showMenu = () => { const showMenu = () => {
if (showArchive.value) { if (showArchive.value) {
@ -74,7 +83,7 @@ const uploadArchive = () => {
API.getUser().then(user => { API.getUser().then(user => {
if (user) { if (user) {
const palyer = state.playerAttribute.attribute; const palyer = state.playerAttribute.attribute;
const data = { version: archive_version, lv: palyer.lv, coins: palyer.coins, archive: archive.value } const data = { version: archive_version, lv: palyer.lv, coins: palyer.coins, strengthenLv: strengthenLv.value, archive: archive.value }
API.uploadArchive(data).then(rsp => rsp && showMenu()); API.uploadArchive(data).then(rsp => rsp && showMenu());
} else { } else {
state.showLogin = true; state.showLogin = true;
@ -85,7 +94,12 @@ const uploadArchive = () => {
const downArchive = () => { const downArchive = () => {
API.getUser().then(user => { API.getUser().then(user => {
if (user) { if (user) {
API.downArchive().then(rsp => rsp && showMenu()); API.downArchive({ version: archive_version }).then((rsp: any) => {
if (rsp) {
archive.value = rsp;
importArchive();
}
});
} else { } else {
state.showLogin = true; state.showLogin = true;
} }

10
src/views/login.vue

@ -8,7 +8,7 @@
</div> </div>
<div class="item"> <div class="item">
<div class="label">{{ t('login.2') }}: </div> <div class="label">{{ t('login.2') }}: </div>
<input type="password" v-model="user.passowrd"><br> <input type="password" v-model="user.password"><br>
</div> </div>
<button class="button" @click="login">{{ t('login.3') }}</button> <button class="button" @click="login">{{ t('login.3') }}</button>
</div> </div>
@ -27,21 +27,21 @@ const { t } = useI18n();
const { state, commit, dispatch } = useStore(); const { state, commit, dispatch } = useStore();
const user = reactive({ const user = reactive({
username: '', username: '',
passowrd: '', password: '',
}) })
const login = () => { const login = () => {
const username = user.username; const username = user.username;
const passowrd = user.passowrd; const password = user.password;
if (!username) { if (!username) {
commit('set_sys_info', { msg: t('login.4'), type: 'warning' }) commit('set_sys_info', { msg: t('login.4'), type: 'warning' })
return; return;
} }
if (!passowrd) { if (!password) {
commit('set_sys_info', { msg: t('login.5'), type: 'warning' }) commit('set_sys_info', { msg: t('login.5'), type: 'warning' })
return; return;
} }
const param = { username: username, passowrd: MD5(passowrd) }; const param = { username: username, password: MD5(password) };
loginOrRegister(param).then(rsp => { loginOrRegister(param).then(rsp => {
rsp && (state.showLogin = false); rsp && (state.showLogin = false);
}) })

Loading…
Cancel
Save