XMWAI 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. xmwai-0.3.1/MANIFEST.in +4 -0
  2. {xmwai-0.3.0/XMWAI.egg-info → xmwai-0.3.1}/PKG-INFO +2 -1
  3. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/__init__.py +2 -1
  4. xmwai-0.3.1/XMWAI/static/burger.js +165 -0
  5. xmwai-0.3.1/XMWAI/static/images/BottomBun.png +0 -0
  6. xmwai-0.3.1/XMWAI/static/images/TopBun.png +0 -0
  7. xmwai-0.3.1/XMWAI/static/images/beef.png +0 -0
  8. xmwai-0.3.1/XMWAI/static/images/bg.png +0 -0
  9. xmwai-0.3.1/XMWAI/static/images/cheese.png +0 -0
  10. xmwai-0.3.1/XMWAI/static/images/lettuce.png +0 -0
  11. xmwai-0.3.1/XMWAI/static/images/sauce.png +0 -0
  12. xmwai-0.3.1/XMWAI/static/images/tomato.png +0 -0
  13. xmwai-0.3.1/XMWAI/templates/burger.html +134 -0
  14. xmwai-0.3.1/XMWAI/web_core.py +69 -0
  15. {xmwai-0.3.0 → xmwai-0.3.1/XMWAI.egg-info}/PKG-INFO +2 -1
  16. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI.egg-info/SOURCES.txt +12 -1
  17. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI.egg-info/requires.txt +1 -0
  18. {xmwai-0.3.0 → xmwai-0.3.1}/setup.py +17 -5
  19. xmwai-0.3.0/MANIFEST.in +0 -2
  20. {xmwai-0.3.0 → xmwai-0.3.1}/LICENSE.txt +0 -0
  21. {xmwai-0.3.0 → xmwai-0.3.1}/README.md +0 -0
  22. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/bomb_core.py +0 -0
  23. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/cookbook_core.py +0 -0
  24. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/core.py +0 -0
  25. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/file/__init__.py +0 -0
  26. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/file/idiom.json +0 -0
  27. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/0.gif +0 -0
  28. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/1.gif +0 -0
  29. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/10.gif +0 -0
  30. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/11.gif +0 -0
  31. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/12.gif +0 -0
  32. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/13.gif +0 -0
  33. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/14.gif +0 -0
  34. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/15.gif +0 -0
  35. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/16.gif +0 -0
  36. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/17.gif +0 -0
  37. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/18.gif +0 -0
  38. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/19.gif +0 -0
  39. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/2.gif +0 -0
  40. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/20.gif +0 -0
  41. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/21.gif +0 -0
  42. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/22.gif +0 -0
  43. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/23.gif +0 -0
  44. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/24.gif +0 -0
  45. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/25.gif +0 -0
  46. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/26.gif +0 -0
  47. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/27.gif +0 -0
  48. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/28.gif +0 -0
  49. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/29.gif +0 -0
  50. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/3.gif +0 -0
  51. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/30.gif +0 -0
  52. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/31.gif +0 -0
  53. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/32.gif +0 -0
  54. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/33.gif +0 -0
  55. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/34.gif +0 -0
  56. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/35.gif +0 -0
  57. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/36.gif +0 -0
  58. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/37.gif +0 -0
  59. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/38.gif +0 -0
  60. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/39.gif +0 -0
  61. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/4.gif +0 -0
  62. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/40.gif +0 -0
  63. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/41.gif +0 -0
  64. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/42.gif +0 -0
  65. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/43.gif +0 -0
  66. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/44.gif +0 -0
  67. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/45.gif +0 -0
  68. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/46.gif +0 -0
  69. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/47.gif +0 -0
  70. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/48.gif +0 -0
  71. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/49.gif +0 -0
  72. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/5.gif +0 -0
  73. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/50.gif +0 -0
  74. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/51.gif +0 -0
  75. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/52.gif +0 -0
  76. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/53.gif +0 -0
  77. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/54.gif +0 -0
  78. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/55.gif +0 -0
  79. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/56.gif +0 -0
  80. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/57.gif +0 -0
  81. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/58.gif +0 -0
  82. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/59.gif +0 -0
  83. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/6.gif +0 -0
  84. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/60.gif +0 -0
  85. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/61.gif +0 -0
  86. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/62.gif +0 -0
  87. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/63.gif +0 -0
  88. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/64.gif +0 -0
  89. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/65.gif +0 -0
  90. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/66.gif +0 -0
  91. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/67.gif +0 -0
  92. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/68.gif +0 -0
  93. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/69.gif +0 -0
  94. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/7.gif +0 -0
  95. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/70.gif +0 -0
  96. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/71.gif +0 -0
  97. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/72.gif +0 -0
  98. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/73.gif +0 -0
  99. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/74.gif +0 -0
  100. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/75.gif +0 -0
  101. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/76.gif +0 -0
  102. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/77.gif +0 -0
  103. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/78.gif +0 -0
  104. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/79.gif +0 -0
  105. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/8.gif +0 -0
  106. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/80.gif +0 -0
  107. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/81.gif +0 -0
  108. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/82.gif +0 -0
  109. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/83.gif +0 -0
  110. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/84.gif +0 -0
  111. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/85.gif +0 -0
  112. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/9.gif +0 -0
  113. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/gif/__init__.py +0 -0
  114. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/idiom_core.py +0 -0
  115. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/magic_core.py +0 -0
  116. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI/trial_class.py +0 -0
  117. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI.egg-info/dependency_links.txt +0 -0
  118. {xmwai-0.3.0 → xmwai-0.3.1}/XMWAI.egg-info/top_level.txt +0 -0
  119. {xmwai-0.3.0 → xmwai-0.3.1}/setup.cfg +0 -0
@@ -0,0 +1,4 @@
1
+ recursive-include XMWAI/gif *
2
+ recursive-include XMWAI/file *.json
3
+ recursive-include XMWAI/templates *.html
4
+ recursive-include XMWAI/static *.js *.css *.png *.jpg *.gif
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -15,6 +15,7 @@ Requires-Dist: requests>=2.32.3
15
15
  Requires-Dist: Pillow>=11.1.0
16
16
  Requires-Dist: opencv-python>=3.4.18.65
17
17
  Requires-Dist: numpy>=1.26.0
18
+ Requires-Dist: flask>=3.1.0
18
19
  Dynamic: author
19
20
  Dynamic: author-email
20
21
  Dynamic: classifier
@@ -3,8 +3,9 @@ from .magic_core import birthday # 从子模块导入函数到顶层
3
3
  from .bomb_core import bomb # 从子模块导入函数到顶层
4
4
  from .idiom_core import idiom, searchIdiom, get_json_path # 从子模块导入函数到顶层
5
5
  from .trial_class import make, get_file_content_as_base64, save_pic, detect_windows_scale, get_file_content_as_base64_2, cartoon # 从子模块导入函数到顶层
6
+ from .web_core import burger # 从子模块导入函数到顶层
6
7
 
7
8
  __all__ = ["story", "photo", "reply", "poem", 'birthday', 'bomb',
8
9
  "idiom", "searchIdiom", "get_json_path", "crack",
9
10
  "make", "get_file_content_as_base64", "save_pic", "detect_windows_scale",
10
- "get_file_content_as_base64_2", "cartoon"] # 可选:明确导出的内容
11
+ "get_file_content_as_base64_2", "cartoon", "burger"] # 可选:明确导出的内容
@@ -0,0 +1,165 @@
1
+ // 等待所有图片加载完成后设置样式
2
+ function setIngredientStyles() {
3
+ const ingredients = document.querySelectorAll(".ingredient");
4
+ console.log("ingredients", ingredients);
5
+
6
+ // 检查所有图片是否都已加载
7
+ const imagePromises = Array.from(ingredients).map((img) => {
8
+ return new Promise((resolve) => {
9
+ if (img.complete) {
10
+ resolve(img);
11
+ } else {
12
+ img.onload = () => resolve(img);
13
+ img.onerror = () => resolve(img); // 即使加载失败也继续
14
+ }
15
+ });
16
+ });
17
+
18
+ // 等待所有图片加载完成
19
+ Promise.all(imagePromises).then(() => {
20
+ let totalTopValue = 0;
21
+ const ingredientsLen = ingredients.length;
22
+
23
+ ingredients.forEach((img, index) => {
24
+ const ingredientType = img.getAttribute("data-ingredient");
25
+ const ingredientIndex = parseInt(img.getAttribute("data-index"));
26
+ img.style.zIndex = ingredientsLen - ingredientIndex;
27
+
28
+ // 获取当前图片高度
29
+ const imgHeight = img.offsetHeight || img.naturalHeight || 60; // 备用默认高度
30
+ let offsetY = 10;
31
+
32
+ // 基础定位:从下往上堆叠
33
+ if (ingredientType === "TopBun") {
34
+ img.style.top = 0;
35
+ totalTopValue = imgHeight;
36
+ } else {
37
+ //判断上一个食材是什么
38
+ const prevIngredient = ingredients[index - 1];
39
+ const prevIngredientType =
40
+ prevIngredient.getAttribute("data-ingredient");
41
+ //获取上一个食材的高度
42
+ const prevIngredientHeight =
43
+ prevIngredient.offsetHeight || prevIngredient.naturalHeight || 60;
44
+
45
+ //上一个食材是否是辅料
46
+ const isAuxiliary = ["cheese", "lettuce", "sauce"].includes(
47
+ prevIngredientType
48
+ );
49
+
50
+ if (isAuxiliary) {
51
+ //百分比
52
+ const percentage = prevIngredientType === "cheese" ? 0.95 : 0.7;
53
+ img.style.top =
54
+ totalTopValue - prevIngredientHeight * percentage + "px";
55
+ totalTopValue =
56
+ totalTopValue - prevIngredientHeight * percentage + imgHeight;
57
+ } else {
58
+ img.style.top = totalTopValue - offsetY + "px";
59
+ totalTopValue += imgHeight - offsetY;
60
+ }
61
+ }
62
+
63
+ console.log(
64
+ "ingredientType",
65
+ ingredientType,
66
+ "totalTopValue",
67
+ totalTopValue,
68
+ "offsetY",
69
+ offsetY,
70
+ "imgHeight",
71
+ imgHeight
72
+ );
73
+ });
74
+
75
+ // 滑动条逻辑处理
76
+ setupBurgerSlider(totalTopValue);
77
+ });
78
+ }
79
+
80
+ // 滑动条设置和控制函数
81
+ function setupBurgerSlider(burgerTotalHeight) {
82
+ const view = document.querySelector(".view");
83
+ const burger = document.querySelector(".burger");
84
+ const sliderContainer = document.getElementById("sliderContainer");
85
+ const slider = document.getElementById("burgerSlider");
86
+
87
+ if (!view || !burger || !sliderContainer || !slider) {
88
+ console.error("找不到必要的DOM元素");
89
+ return;
90
+ }
91
+
92
+ // 获取view的可视高度
93
+ const viewHeight = view.offsetHeight;
94
+
95
+ console.log("汉堡总高度:", burgerTotalHeight, "可视区域高度:", viewHeight);
96
+
97
+ // 判断是否需要显示滑动条
98
+ if (burgerTotalHeight > viewHeight) {
99
+ // 显示滑动条
100
+ sliderContainer.style.display = "flex";
101
+
102
+ // 计算可滑动的最大值
103
+ const maxScrollValue = burgerTotalHeight - viewHeight;
104
+
105
+ // 设置滑动条的最大值
106
+ slider.max = maxScrollValue;
107
+ slider.value = 0; // 初始值为0,滑动条在顶部(未选中状态)
108
+
109
+ // 初始化burger位置(显示汉堡底部)
110
+ burger.style.bottom = maxScrollValue + "px";
111
+
112
+ // 滑动条事件监听
113
+ slider.addEventListener("input", function () {
114
+ const scrollValue = parseFloat(this.value);
115
+ // 滑动条向下拖动时汉堡向下移动
116
+ const bottomValue = maxScrollValue - scrollValue;
117
+ burger.style.bottom = bottomValue + "px";
118
+ console.log("滑动值:", scrollValue, "实际bottom值:", bottomValue);
119
+ });
120
+
121
+ console.log("滑动条已激活,最大滑动值:", maxScrollValue);
122
+ } else {
123
+ // 隐藏滑动条
124
+ sliderContainer.style.display = "none";
125
+ burger.style.bottom = "0px";
126
+ console.log("汉堡高度适合,无需滑动条");
127
+ }
128
+ }
129
+
130
+ // 响应式处理 - 窗口大小改变时重新计算
131
+ function handleResize() {
132
+ console.log("窗口大小改变,重新计算滑动条状态");
133
+ // 重新执行样式设置
134
+ setIngredientStyles();
135
+ }
136
+
137
+ // 防抖函数
138
+ function debounce(func, wait) {
139
+ let timeout;
140
+ return function executedFunction(...args) {
141
+ const later = () => {
142
+ clearTimeout(timeout);
143
+ func(...args);
144
+ };
145
+ clearTimeout(timeout);
146
+ timeout = setTimeout(later, wait);
147
+ };
148
+ }
149
+
150
+ // 页面加载完成后执行样式设置
151
+ document.addEventListener("DOMContentLoaded", setIngredientStyles);
152
+
153
+ // 可选:添加点击事件显示食材信息
154
+ document.addEventListener("DOMContentLoaded", function () {
155
+ document.querySelectorAll(".ingredient").forEach((img) => {
156
+ img.addEventListener("click", function () {
157
+ const ingredient = this.getAttribute("data-ingredient");
158
+ const index = this.getAttribute("data-index");
159
+ console.log(`点击了第${parseInt(index) + 1}层: ${ingredient}`);
160
+ });
161
+ });
162
+ });
163
+
164
+ // 窗口大小改变时重新计算(使用防抖)
165
+ window.addEventListener("resize", debounce(handleResize, 300));
Binary file
Binary file
@@ -0,0 +1,134 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>我的超级汉堡</title>
6
+ <style>
7
+ body {
8
+ background-image: url("{{ url_for('static', filename='images/bg.png') }}");
9
+ background-size: cover;
10
+ background-position: center;
11
+ background-repeat: no-repeat;
12
+ background-attachment: fixed;
13
+ overflow: hidden;
14
+ text-align: center;
15
+ font-family: Arial, sans-serif;
16
+ width: 100vw;
17
+ height: 100vh;
18
+ margin: 0;
19
+ padding: 0;
20
+ display: flex;
21
+ flex-direction: column;
22
+ box-sizing: border-box;
23
+ padding-bottom: 50px;
24
+ }
25
+ .view {
26
+ flex: 1;
27
+ position: relative;
28
+ overflow: hidden;
29
+ }
30
+ .burger {
31
+ position: relative;
32
+ width: 300px;
33
+ margin-left: auto;
34
+ margin-right: auto;
35
+ }
36
+ .ingredient {
37
+ width: 300px;
38
+ display: block;
39
+ position: absolute;
40
+ }
41
+
42
+ /* 滑动条容器样式 */
43
+ .slider-container {
44
+ position: fixed;
45
+ right: 20px;
46
+ top: 50%;
47
+ transform: translateY(-50%) scale(1.5);
48
+ height: 60vh;
49
+ width: 30px;
50
+ z-index: 1000;
51
+ display: flex;
52
+ align-items: center;
53
+ justify-content: center;
54
+ }
55
+
56
+ /* 竖向滑动条样式 */
57
+ .burger-slider {
58
+ -webkit-appearance: slider-vertical; /* WebKit */
59
+ width: 20px;
60
+ height: 100%;
61
+ background: rgba(255, 255, 255, 0.8);
62
+ border-radius: 10px;
63
+ outline: none;
64
+ cursor: pointer;
65
+ }
66
+
67
+ /* Firefox 滑动条样式 */
68
+ .burger-slider::-moz-range-track {
69
+ width: 20px;
70
+ height: 100%;
71
+ background: rgba(255, 255, 255, 0.8);
72
+ border-radius: 10px;
73
+ border: none;
74
+ }
75
+
76
+ .burger-slider::-moz-range-thumb {
77
+ width: 20px;
78
+ height: 40px;
79
+ background: #007bff;
80
+ border-radius: 10px;
81
+ border: none;
82
+ cursor: pointer;
83
+ }
84
+
85
+ /* WebKit 滑动条样式 */
86
+ .burger-slider::-webkit-slider-track {
87
+ width: 20px;
88
+ height: 100%;
89
+ background: rgba(255, 255, 255, 0.8);
90
+ border-radius: 10px;
91
+ }
92
+
93
+ .burger-slider::-webkit-slider-thumb {
94
+ -webkit-appearance: none;
95
+ width: 20px;
96
+ height: 40px;
97
+ background: #007bff;
98
+ border-radius: 10px;
99
+ cursor: pointer;
100
+ }
101
+ </style>
102
+ </head>
103
+ <body>
104
+ <h1>🎉 你的超级汉堡来了!</h1>
105
+ <div class="view">
106
+ <div class="burger">
107
+ {% for ingredient in ingredients %}
108
+ <img
109
+ class="ingredient"
110
+ src="{{ url_for('static', filename='images/' + ingredient + '.png') }}"
111
+ alt="{{ ingredient }}"
112
+ data-index="{{ loop.index0 }}"
113
+ data-ingredient="{{ ingredient }}"
114
+ />
115
+ {% endfor %}
116
+ </div>
117
+ </div>
118
+
119
+ <!-- 竖向滑动条 -->
120
+ <div class="slider-container" id="sliderContainer" style="display: none">
121
+ <input
122
+ type="range"
123
+ id="burgerSlider"
124
+ class="burger-slider"
125
+ min="0"
126
+ max="100"
127
+ value="0"
128
+ orient="vertical"
129
+ />
130
+ </div>
131
+
132
+ <script src="{{ url_for('static', filename='burger.js') }}"></script>
133
+ </body>
134
+ </html>
@@ -0,0 +1,69 @@
1
+ import os
2
+ from flask import Flask, render_template
3
+ import webbrowser
4
+ import threading
5
+ import time
6
+
7
+
8
+ '''Super堡'''
9
+ # 搭建flask框架
10
+ app = Flask(
11
+ __name__,
12
+ template_folder=os.path.join(os.path.dirname(__file__), "templates"),
13
+ static_folder=os.path.join(os.path.dirname(__file__), "static")
14
+ )
15
+
16
+ mapping = {
17
+ "面包底": "BottomBun",
18
+ "生菜": "lettuce",
19
+ "番茄": "tomato",
20
+ "牛肉饼": "beef",
21
+ "芝士": "cheese",
22
+ "酱料": "sauce",
23
+ "面包顶": "TopBun"
24
+ }
25
+
26
+ ingredients_order = []
27
+
28
+
29
+ def burger(result):
30
+ global ingredients_order
31
+ inputs = result.strip().split("→")
32
+ ingredients_order = [mapping[i] for i in inputs]
33
+ ingredients_order = ingredients_order[::-1]
34
+
35
+ # 自动启动服务器
36
+ start_server()
37
+ return ingredients_order
38
+
39
+
40
+ @app.route('/')
41
+ def show_burger():
42
+ return render_template("burger.html", ingredients=ingredients_order)
43
+
44
+
45
+ def run_server(port=5050):
46
+ """在后台线程中运行服务器"""
47
+ app.run(debug=False, host='0.0.0.0', port=port, use_reloader=False)
48
+
49
+
50
+ def start_server(port=5050):
51
+ """启动服务器并打开浏览器"""
52
+ url = f"http://127.0.0.1:{port}/"
53
+
54
+ # 在后台线程中启动服务器
55
+ server_thread = threading.Thread(target=run_server, args=(port,))
56
+ server_thread.daemon = True
57
+ server_thread.start()
58
+
59
+ # 等待服务器启动
60
+ time.sleep(2)
61
+
62
+ # 打开浏览器
63
+ webbrowser.open(url)
64
+
65
+ # 保持服务器运行
66
+ try:
67
+ server_thread.join()
68
+ except KeyboardInterrupt:
69
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -15,6 +15,7 @@ Requires-Dist: requests>=2.32.3
15
15
  Requires-Dist: Pillow>=11.1.0
16
16
  Requires-Dist: opencv-python>=3.4.18.65
17
17
  Requires-Dist: numpy>=1.26.0
18
+ Requires-Dist: flask>=3.1.0
18
19
  Dynamic: author
19
20
  Dynamic: author-email
20
21
  Dynamic: classifier
@@ -9,6 +9,7 @@ XMWAI/core.py
9
9
  XMWAI/idiom_core.py
10
10
  XMWAI/magic_core.py
11
11
  XMWAI/trial_class.py
12
+ XMWAI/web_core.py
12
13
  XMWAI.egg-info/PKG-INFO
13
14
  XMWAI.egg-info/SOURCES.txt
14
15
  XMWAI.egg-info/dependency_links.txt
@@ -102,4 +103,14 @@ XMWAI/gif/83.gif
102
103
  XMWAI/gif/84.gif
103
104
  XMWAI/gif/85.gif
104
105
  XMWAI/gif/9.gif
105
- XMWAI/gif/__init__.py
106
+ XMWAI/gif/__init__.py
107
+ XMWAI/static/burger.js
108
+ XMWAI/static/images/BottomBun.png
109
+ XMWAI/static/images/TopBun.png
110
+ XMWAI/static/images/beef.png
111
+ XMWAI/static/images/bg.png
112
+ XMWAI/static/images/cheese.png
113
+ XMWAI/static/images/lettuce.png
114
+ XMWAI/static/images/sauce.png
115
+ XMWAI/static/images/tomato.png
116
+ XMWAI/templates/burger.html
@@ -2,3 +2,4 @@ requests>=2.32.3
2
2
  Pillow>=11.1.0
3
3
  opencv-python>=3.4.18.65
4
4
  numpy>=1.26.0
5
+ flask>=3.1.0
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="XMWAI", # 包名(pip install XMWAI)
5
- version="0.3.0", # 初始版本号
5
+ version="0.3.1", # 每次上传记得升级版本号
6
6
  author="pydevelopment", # 作者
7
7
  author_email="hekai@xiaoma.cn", # 邮箱
8
8
  description="Small code King AI related library", # 简短描述
@@ -10,12 +10,24 @@ setup(
10
10
  long_description_content_type="text/markdown", # 描述格式
11
11
  url="https://github.com/Tonykai88/XMWAI.git", # GitHub 链接
12
12
  packages=find_packages(), # 自动找包
13
- include_package_data=True, # 若没有它,包里面的除代码文件,都无法打包。
13
+ include_package_data=True, # 打包额外资源的开关
14
+ package_data={ # 👇 显式告诉 setuptools 要包含哪些非 py 文件
15
+ "XMWAI.file": ["idiom.json"],
16
+ "XMWAI": [
17
+ "templates/*.html",
18
+ "static/*.js",
19
+ "static/*.css",
20
+ "static/images/*"
21
+ ],
22
+ "XMWAI.gif": ["*.gif"], # gif 文件夹下的所有 GIF
23
+ "XMWAI.file": ["*.json"] # file 文件夹下的 json
24
+ },
14
25
  install_requires=[
15
- "requests>=2.32.3", # 依赖包
16
- "Pillow>=11.1.0", # 图像处理库
26
+ "requests>=2.32.3", # 依赖包
27
+ "Pillow>=11.1.0", # 图像处理库
17
28
  "opencv-python>=3.4.18.65", # OpenCV 库
18
- "numpy>=1.26.0" # 数值计算库
29
+ "numpy>=1.26.0", # 数值计算库
30
+ "flask>=3.1.0" # Web 框架
19
31
  ],
20
32
  classifiers=[
21
33
  "Programming Language :: Python :: 3",
xmwai-0.3.0/MANIFEST.in DELETED
@@ -1,2 +0,0 @@
1
- recursive-include XMWAI/gif *
2
- recursive-include XMWAI/file *.json
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes