From 6b41b8e096f400643b7243f5d582eea572f0911e Mon Sep 17 00:00:00 2001 From: mxr612 Date: Sat, 26 Apr 2025 20:44:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=A4=84=E7=90=86=E5=92=8C=E7=95=8C=E9=9D=A2=E6=96=87?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除tagmap.yml文件,简化标签处理逻辑 - 将标签存储方式从字典改为列表,减少复杂性 - 更新界面文本,将"PsychoScales"替换为"心尺" - 修改README.md中的项目描述,使其更简洁清晰 --- README.md | 32 ++++++++++++++++---------------- app.py | 14 +++++--------- tagmap.yml | 3 --- templates/base.html | 6 +++--- 4 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 tagmap.yml diff --git a/README.md b/README.md index 4880321..71132f0 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ -# 心尺 PsychoScales Org +# 心尺.org -## 关于PsychoScales - -PsychoScales网站是一个专业的心理学资源平台,旨在为用户提供全面的心理学测量工具和评估资源。我们汇集了各种心理测量工具,涵盖了情绪、人格、认知能力、心理健康等多个领域,帮助用户更好地了解自己的心理特点和状况。 - -作为PsychoScales网站的用户,您可以通过简单的在线测试,快速获取关于自己心理特征的详细报告和分析。这些测量工具基于权威的心理学理论和研究,确保了测试结果的准确性和可靠性。 - -本网站旨在提供免费的量表分享和结果计算。 -如果您需要解析,您可以在[心尺PsychoScales](https://www.psychoscales.com/)得到全面、深入的AI结果解析。 - -联系我们:feedback@psygscales.com - -用户社区:QQ 513869177 - -## 关于PsychoScales Org +## 关于心尺.Org 这个一个开源的量表框架,基于Python搭建。 本项目的量表加载完全基于YAML,不使用任何数据库。在易于编辑和易于加载中间达到了平衡。 -[开源地址](https://git.mxr612.io/PsychoScales/PsychoScales) \ No newline at end of file +[开源地址](https://git.mxr612.io/PsychoScales/PsychoScales) + +联系我们:feedback@psychoscales.com + +用户社区:QQ 513869177 + +## 关于心尺 + +心尺是一个专业的心理学资源平台,旨在为用户提供全面的心理学测量工具和评估资源。我们汇集了各种心理测量工具,涵盖了情绪、人格、认知能力、心理健康等多个领域,帮助用户更好地了解自己的心理特点和状况。 + +作为心尺的用户,您可以通过简单的在线测试,快速获取关于自己心理特征的详细报告和分析。这些测量工具基于权威的心理学理论和研究,确保了测试结果的准确性和可靠性。 + +本网站旨在提供免费的量表分享和结果计算。 +如果您需要解析,您可以在[心尺](https://www.psychoscales.com/)得到全面、深入的AI结果解析。 \ No newline at end of file diff --git a/app.py b/app.py index 63dff40..93d069e 100644 --- a/app.py +++ b/app.py @@ -14,12 +14,7 @@ app.mount("/static", StaticFiles(directory="static"), name="static") # 加载所有问卷数据 def load_all_scales(): scales = {} - tags = {} - try: - with open(os.path.join('tagmap.yml'), 'r', encoding='utf-8') as f: - tagmap = yaml.safe_load(f) - except Exception as e: - print(f"Error loading scale langmap: {e}") + tags = [] for root, dirs, files in os.walk(os.path.realpath('scales')): for filename in files: if filename.endswith(('.yaml', '.yml')): @@ -29,9 +24,10 @@ def load_all_scales(): scale['instructions']=markdown.markdown(scale['instructions'], extensions=['fenced_code','tables','mdx_math']) scale['descriptions']=markdown.markdown(scale['descriptions'], extensions=['fenced_code','tables','mdx_math']) scale['abstract']=markdown.markdown(scale['abstract'], extensions=['fenced_code','tables','mdx_math']) - if 'tag' not in scale or scale['tag'] not in tagmap: - scale['tag']='other' - tags[scale['tag']]=tagmap[scale['tag']] + if 'tag' not in scale: + scale['tag']='其他' + if scale['tag'] not in tags: + tags.append(scale['tag']) scale_id = os.path.splitext(filename)[0] # 使用文件名作为标识 scales[scale_id] = scale except Exception as e: diff --git a/tagmap.yml b/tagmap.yml deleted file mode 100644 index be196c1..0000000 --- a/tagmap.yml +++ /dev/null @@ -1,3 +0,0 @@ -other: 未分类 Other -zh: 中文量表 -en: English Scales \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index fbdcee8..831f18d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,13 +14,13 @@