Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: 历史记录功能添加 #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

htfc786
Copy link
Contributor

@htfc786 htfc786 commented Aug 7, 2023

add: 历史记录功能添加

您好,在使用网站的过程中,如果重新打开网页,之前的学习进度就没了,所以我又研究了一下

进度数据存在localStorage中,关闭页面不丢失

IndexPage.vue中有几行非常长的注释是解释调用这些函数的原因,我感觉我应该都考虑到了吧,我希望我的逻辑都是正确的,如果觉得没用可以删除,谢谢!

由于本人第二次使写typescript,可能还是不太规范,过了编辑器的的代码检查,应该没问题吧。。。

本人只有14岁,没有专门学过这个,写的不是很好,感觉代码中有一些可以复用的地方我没有做到,希望大佬指点,感谢!

最后再次感谢鱼皮开源整个网站!!!!

@liyupi
Copy link
Owner

liyupi commented Aug 8, 2023

小伙伴你好,英雄出少年啊!首先代码写的还是很不错的,能想到把 level 相关的增删改查抽离成一个独立文件很好。

但是本项目其实使用了 pinia 来做全局的状态管理(https://github.com/liyupi/sql-mother/blob/master/src/core/globalStore.ts),并且使用 pinia-plugin-persistedstate 插件实现了 localStorage 的自动加载和同步,可以重点关注这段代码:https://github.com/liyupi/sql-mother/blob/3ad8917536d40308556d2781fcb48951ff4e7834/src/core/globalStore.ts#L17C1-L27C5 。期待改进

@htfc786
Copy link
Contributor Author

htfc786 commented Aug 9, 2023

感谢鱼皮大佬的回复,我已经看了pinia相关的东西并应用在另一个提交里(#21),您先看一下那个提交,看看我写的对不对,如果我写的对,我在来改这边的代码,谢谢鱼皮大佬!

@htfc786
Copy link
Contributor Author

htfc786 commented Aug 25, 2023

鱼皮大佬您好,我现在也把暂存关卡的这个改成pinia版了,因为刚才在issues那边看到有人要这个功能,我就给做了

@htfc786
Copy link
Contributor Author

htfc786 commented Oct 5, 2023

鱼皮大佬您好,为什么您一个多月都没有回复我?历史记录这个大体应该没什么问题吧。。。

@htfc786
Copy link
Contributor Author

htfc786 commented Nov 11, 2023

鱼皮大佬您好,我期中考试都考完了,您怎么还没回我?这个代码具体有什么问题啊?我感觉这个代码应该没什么问题了吧。。。怕您看不见@您一下 @liyupi

@htfc786
Copy link
Contributor Author

htfc786 commented Nov 11, 2023

突然想起一个问题,好像源代码里本身就带有Store相关的代码,查源码后发现好像鱼皮大佬好像已经写的历史记录的相关属性了,我是不是应该基于这个开发,而不是新建Store?@liyupi

export const useGlobalStore = defineStore("global", {
state: () => ({
// 学习记录
studyHistoryList: [],
// 当前关卡
currentLevel: { ...allLevels[0] },
}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants