create-lupine 1.0.31 → 1.2.0

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 (126) hide show
  1. package/README.md +25 -0
  2. package/index.js +11 -9
  3. package/package.json +1 -1
  4. package/templates/common/.agents/skills/lupine-framework/SKILL.md +63 -0
  5. package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +98 -0
  6. package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +71 -0
  7. package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +100 -0
  8. package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +167 -0
  9. package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +54 -0
  10. package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +108 -0
  11. package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +119 -0
  12. package/templates/common/_env +2 -0
  13. package/templates/lupine-template-cv-starter/README.md +5 -0
  14. package/templates/lupine-template-cv-starter/web/src/index.tsx +1 -10
  15. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +1 -10
  16. package/templates/lupine-template-doc-starter/README.md +5 -0
  17. package/templates/lupine-template-doc-starter/web/src/index.tsx +1 -10
  18. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +1 -10
  19. package/templates/lupine-template-fullstack-starter/README.md +21 -0
  20. package/templates/lupine-template-fullstack-starter/api/package.json +10 -0
  21. package/templates/lupine-template-fullstack-starter/api/resources/install.mysql.sql +107 -0
  22. package/templates/lupine-template-fullstack-starter/api/resources/install.sqlite.sql +75 -0
  23. package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-en.ts +39 -0
  24. package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-zh-cn.ts +37 -0
  25. package/templates/lupine-template-fullstack-starter/api/src/service/admin-api.ts +139 -0
  26. package/templates/lupine-template-fullstack-starter/api/src/service/api.ts +111 -0
  27. package/templates/lupine-template-fullstack-starter/api/src/service/contact-api.ts +50 -0
  28. package/templates/lupine-template-fullstack-starter/api/src/service/file-api-base.ts +30 -0
  29. package/templates/lupine-template-fullstack-starter/api/src/service/root-api.ts +28 -0
  30. package/templates/lupine-template-fullstack-starter/api/src/service/send-email.ts +47 -0
  31. package/templates/lupine-template-fullstack-starter/api/src/service/setting-api.ts +60 -0
  32. package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +1041 -0
  33. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/lupine.json +10 -1
  34. package/templates/lupine-template-fullstack-starter/web/assets/android-chrome-192x192.png +0 -0
  35. package/templates/lupine-template-fullstack-starter/web/assets/apple-touch-icon.png +0 -0
  36. package/templates/lupine-template-fullstack-starter/web/assets/favicon-16x16.png +0 -0
  37. package/templates/lupine-template-fullstack-starter/web/assets/favicon-32x32.png +0 -0
  38. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-carbon-icons.txt +71 -0
  39. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-material-design.txt +20 -0
  40. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/i-font.woff2 +0 -0
  41. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/sample.html +124 -0
  42. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/style.css +103 -0
  43. package/templates/lupine-template-fullstack-starter/web/assets/images/sample.png +0 -0
  44. package/templates/lupine-template-fullstack-starter/web/assets/lupine-flower.png +0 -0
  45. package/templates/lupine-template-fullstack-starter/web/assets/lupine.svg +71 -0
  46. package/templates/lupine-template-fullstack-starter/web/assets/site.webmanifest +14 -0
  47. package/templates/lupine-template-fullstack-starter/web/icons-font.config.js +129 -0
  48. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/package.json +1 -1
  49. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-about.tsx +16 -0
  50. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-patch.ts +22 -0
  51. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/index.html +22 -0
  52. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/index.tsx +64 -0
  53. package/templates/lupine-template-fullstack-starter/web/src/components/footer-menu.tsx +52 -0
  54. package/templates/lupine-template-fullstack-starter/web/src/components/footer.tsx +15 -0
  55. package/templates/lupine-template-fullstack-starter/web/src/components/header.tsx +75 -0
  56. package/templates/lupine-template-fullstack-starter/web/src/components/home-search-component.tsx +132 -0
  57. package/templates/lupine-template-fullstack-starter/web/src/components/login-code-zh.tsx +162 -0
  58. package/templates/lupine-template-fullstack-starter/web/src/components/login-code.tsx +165 -0
  59. package/templates/lupine-template-fullstack-starter/web/src/components/login-zh.tsx +118 -0
  60. package/templates/lupine-template-fullstack-starter/web/src/components/login.tsx +122 -0
  61. package/templates/lupine-template-fullstack-starter/web/src/components/not-found-page.tsx +12 -0
  62. package/templates/lupine-template-fullstack-starter/web/src/components/register-zh.tsx +161 -0
  63. package/templates/lupine-template-fullstack-starter/web/src/components/register.tsx +163 -0
  64. package/templates/lupine-template-fullstack-starter/web/src/components/reset-password-zh.tsx +166 -0
  65. package/templates/lupine-template-fullstack-starter/web/src/components/reset-password.tsx +177 -0
  66. package/templates/lupine-template-fullstack-starter/web/src/components/story-card.tsx +96 -0
  67. package/templates/lupine-template-fullstack-starter/web/src/components/story-list.tsx +106 -0
  68. package/templates/lupine-template-fullstack-starter/web/src/components/story-props.ts +34 -0
  69. package/templates/lupine-template-fullstack-starter/web/src/components/user-info.tsx +84 -0
  70. package/templates/lupine-template-fullstack-starter/web/src/frames/admin-page-frame.tsx +48 -0
  71. package/templates/lupine-template-fullstack-starter/web/src/frames/frame1-page-frame.tsx +61 -0
  72. package/templates/lupine-template-fullstack-starter/web/src/frames/frame2-page-frame.tsx +61 -0
  73. package/templates/lupine-template-fullstack-starter/web/src/frames/top-frame.tsx +23 -0
  74. package/templates/lupine-template-fullstack-starter/web/src/frames/user-page-frame.tsx +90 -0
  75. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/index.html +6 -0
  76. package/templates/lupine-template-fullstack-starter/web/src/index.tsx +155 -0
  77. package/templates/lupine-template-fullstack-starter/web/src/models/client-env-keys.ts +5 -0
  78. package/templates/lupine-template-fullstack-starter/web/src/models/index.ts +15 -0
  79. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-cfg.tsx +140 -0
  80. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-item-edit.tsx +21 -0
  81. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-item-list.tsx +24 -0
  82. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-user.tsx +150 -0
  83. package/templates/lupine-template-fullstack-starter/web/src/pages/contact.tsx +105 -0
  84. package/templates/lupine-template-fullstack-starter/web/src/pages/page1-page.tsx +38 -0
  85. package/templates/lupine-template-fullstack-starter/web/src/pages/page2-page.tsx +38 -0
  86. package/templates/lupine-template-fullstack-starter/web/src/pages/user-favorite-page.tsx +58 -0
  87. package/templates/lupine-template-fullstack-starter/web/src/pages/user-home-page.tsx +27 -0
  88. package/templates/lupine-template-fullstack-starter/web/src/pages/user-mine-page.tsx +54 -0
  89. package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page-zh.tsx +112 -0
  90. package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page.tsx +112 -0
  91. package/templates/lupine-template-fullstack-starter/web/src/pages/user1-page.tsx +57 -0
  92. package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +55 -0
  93. package/templates/lupine-template-fullstack-starter/web/src/services/shared-data.ts +19 -0
  94. package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +17 -0
  95. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/global.css +10 -57
  96. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/theme.ts +3 -1
  97. package/templates/lupine-template-responsive-starter/README.md +7 -0
  98. package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +1 -1
  99. package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +2 -1
  100. package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +2 -1
  101. package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +8 -17
  102. package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +15 -27
  103. package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +2 -8
  104. package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +26 -36
  105. package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +16 -21
  106. package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +9 -9
  107. package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +3 -16
  108. package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +3 -2
  109. package/templates/lupine-template-responsive-starter/web/src/index.tsx +2 -11
  110. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +1 -10
  111. package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +3 -14
  112. package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +3 -14
  113. package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +7 -15
  114. package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +7 -14
  115. package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +3 -14
  116. package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +2 -1
  117. package/templates/common/AI_CONTEXT.md +0 -1002
  118. package/templates/lupine-template-hello-world/api/package.json +0 -6
  119. package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +0 -4
  120. package/templates/lupine-template-hello-world/api/src/service/root-api.ts +0 -18
  121. package/templates/lupine-template-hello-world/web/src/index.tsx +0 -73
  122. package/templates/lupine-template-hello-world/web/src/styles/base-css.ts +0 -1
  123. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/api/resources/config_default.json +0 -0
  124. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/api/src/index.ts +0 -0
  125. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/assets/favicon.ico +0 -0
  126. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/app.css +0 -0
@@ -0,0 +1,38 @@
1
+ import { createSignal, CssProps, getRenderPageProps, onMount } from 'lupine.web';
2
+ import { MediaQueryMaxWidth } from 'lupine.web.components';
3
+
4
+ export const Page2Page = async () => {
5
+ const css: CssProps = {
6
+ display: 'flex',
7
+ flexDirection: 'column',
8
+ width: '100%',
9
+ maxWidth: MediaQueryMaxWidth.DesktopMax,
10
+ margin: 'auto',
11
+ padding: '32px',
12
+ '.page1-title': {
13
+ fontSize: '20px',
14
+ fontWeight: 'bold',
15
+ marginBottom: '16px',
16
+ },
17
+ '.page1-item': {
18
+ fontSize: '16px',
19
+ marginBottom: '16px',
20
+ },
21
+ };
22
+
23
+ const [nodeTest1, setNodeTest1] = createSignal<any>('');
24
+ onMount(() => {
25
+ setNodeTest1('parameter1: ' +
26
+ getRenderPageProps().urlParameters?.parameter1 +
27
+ ', option1: ' +
28
+ getRenderPageProps().urlParameters?.option1);
29
+ });
30
+ return (
31
+ <div css={css} class='page1-top'>
32
+ <div class='page1-box'>
33
+ <div class='page1-title'>This is sample page2 (can be in different frames).</div>
34
+ <div class='page1-item'>{nodeTest1}</div>
35
+ </div>
36
+ </div>
37
+ );
38
+ };
@@ -0,0 +1,58 @@
1
+ import { CssProps, PageProps } from 'lupine.web';
2
+ import { MediaQueryMaxWidth, MediaQueryRange } from 'lupine.web.components';
3
+
4
+ const fetchHomeData = async (props: PageProps) => {
5
+ const data = await props.renderPageFunctions.fetchData('/api/settings');
6
+ return data.json;
7
+ };
8
+
9
+ export const UserFavoritePage = async (props: PageProps) => {
10
+ const css: CssProps = {
11
+ display: 'flex',
12
+ flexDirection: 'column',
13
+ width: '100%',
14
+ maxWidth: MediaQueryMaxWidth.DesktopMax,
15
+ margin: 'auto',
16
+ '.img': {
17
+ width: '100%',
18
+ },
19
+ '.page-title': {
20
+ fontSize: '30px',
21
+ textAlign: 'center',
22
+ padding: '20px 0',
23
+ },
24
+ '.block2': {
25
+ width: '100%',
26
+ margin: '10px 0',
27
+ padding: '100px 0',
28
+ border: '1px solid #aaa',
29
+ borderRadius: '8px',
30
+ color: '#1749ff',
31
+ },
32
+ '.a-text': {
33
+ padding: '20px',
34
+ fontSize: '21px',
35
+ textAlign: 'center',
36
+ },
37
+ [MediaQueryRange.ExtraSmallBelow]: {
38
+ '.header-title, .header-subtitle': {
39
+ fontSize: '11px',
40
+ },
41
+ },
42
+ [MediaQueryRange.DesktopAbove]: {
43
+ '.header-title': {
44
+ fontSize: '32px',
45
+ },
46
+ },
47
+ };
48
+ return (
49
+ <div css={css}>
50
+ <div class='padding-block'>
51
+ <div class='block2'>
52
+ <div class='page-title'>Favorites</div>
53
+ <div class='a-text'>My favorite list.</div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ );
58
+ };
@@ -0,0 +1,27 @@
1
+ import { CssProps, PageProps } from 'lupine.web';
2
+ import { MediaQueryMaxWidth, MediaQueryRange } from 'lupine.web.components';
3
+ import { HomeSearchComponent } from '../components/home-search-component';
4
+
5
+ export const UserHomePage = async (props: PageProps) => {
6
+ const css: CssProps = {
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ flex: '1',
10
+ width: '100%',
11
+ margin: '0 auto',
12
+ maxWidth: MediaQueryMaxWidth.DesktopMax,
13
+ '.search-component-container': {
14
+ padding: '0 32px 16px',
15
+ [MediaQueryRange.MobileBelow]: {
16
+ padding: '0 16px 16px',
17
+ },
18
+ },
19
+ };
20
+ return (
21
+ <div css={css}>
22
+ <div class='search-component-container'>
23
+ <HomeSearchComponent management={false} />
24
+ </div>
25
+ </div>
26
+ );
27
+ };
@@ -0,0 +1,54 @@
1
+ import { clearCookie, CssProps, getRenderPageProps, PageProps, refreshPage } from 'lupine.web';
2
+ import { getCookieUser } from '../services/shared-data';
3
+ import { userCookieName } from '../models';
4
+
5
+ const fetchHomeData = async (props: PageProps) => {
6
+ const data = await props.renderPageFunctions.fetchData('/api/settings');
7
+ return data.json;
8
+ };
9
+
10
+ export const UserMinePage = async (props: PageProps) => {
11
+ const css: CssProps = {
12
+ display: 'flex',
13
+ flexDirection: 'column',
14
+ width: '100%',
15
+ margin: '0 auto',
16
+ '.mine-box': {
17
+ padding: '16px',
18
+ },
19
+ '.login-links': {
20
+ display: 'flex',
21
+ padding: '16px',
22
+ },
23
+ };
24
+
25
+ const onLogout = async () => {
26
+ // DomUtils.clearCookie(tokenCookieName, '/');
27
+ clearCookie(userCookieName, '/');
28
+ // call server to clear cookie
29
+ await getRenderPageProps().renderPageFunctions.fetchData('/api/logout', {});
30
+ await refreshPage('/');
31
+ };
32
+ const userCookie = getCookieUser();
33
+ return (
34
+ <div css={css}>
35
+ <div class='login-links'>
36
+ <div>
37
+ Hi, <a href='/user/profile'>{userCookie.u}</a>
38
+ </div>
39
+ <a class='ml-m' href='javascript:void()' onClick={onLogout}>
40
+ Logout
41
+ </a>
42
+ {userCookie.t === 'admin' && (
43
+ <a class='ml-m' href='/admin'>
44
+ Admin
45
+ </a>
46
+ )}
47
+ </div>
48
+ <div class='mine-box'>
49
+ <div class='page-title'>Mine page</div>
50
+ <div class='a-text'>Mine page</div>
51
+ </div>
52
+ </div>
53
+ );
54
+ };
@@ -0,0 +1,112 @@
1
+ import { createSignal, CssProps, getRenderPageProps, onMount, PageProps } from 'lupine.web';
2
+ import { DomUtils, MediaQueryMaxWidth, NotificationMessage, NotificationColor } from 'lupine.web.components';
3
+ import { getUserInfo, UserInfoType } from '../components/user-info';
4
+
5
+ const PageContent = ({ user }: { user: UserInfoType }) => {
6
+ const css: CssProps = {
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ width: '100%',
10
+ maxWidth: MediaQueryMaxWidth.DesktopMax,
11
+ margin: 'auto',
12
+ '.label': {
13
+ width: '200px',
14
+ marginBottom: '20px',
15
+ },
16
+ '.m-menu': {
17
+ display: 'flex',
18
+ flexDirection: 'row',
19
+ padding: '10px',
20
+ border: '1px solid #aaa',
21
+ borderRadius: '8px',
22
+ margin: '10px 0',
23
+ },
24
+ '.m-label': {
25
+ width: '200px',
26
+ },
27
+ '.m-text': {
28
+ width: '400px',
29
+ marginBottom: '10px',
30
+ },
31
+ 'textarea.m-text': {
32
+ height: '80px',
33
+ },
34
+ };
35
+
36
+ const onSave = async () => {
37
+ const nickname = DomUtils.getValue('.f-nickname');
38
+ const password = DomUtils.getValue('.f-password');
39
+ const password2 = DomUtils.getValue('.f-password2');
40
+ if (!nickname) {
41
+ NotificationMessage.sendMessage('网名不能为空', NotificationColor.Error);
42
+ return;
43
+ }
44
+ if (password && password !== password2) {
45
+ NotificationMessage.sendMessage('两次输入的密码不一致', NotificationColor.Error);
46
+ return;
47
+ }
48
+ if (password && password.length < 6) {
49
+ NotificationMessage.sendMessage('密码长度不能小于6位', NotificationColor.Error);
50
+ return;
51
+ }
52
+ const data: any = {
53
+ nickname,
54
+ password,
55
+ };
56
+
57
+ const result = await getRenderPageProps().renderPageFunctions.fetchData('/api/user-profile', JSON.stringify(data));
58
+ console.log(result);
59
+ NotificationMessage.sendMessage(result.json.message || '更新成功', NotificationColor.Success);
60
+ setTimeout(() => {
61
+ document.location.reload();
62
+ }, 1000);
63
+ };
64
+ return (
65
+ <div css={css}>
66
+ <div class='row-box m-menu'>
67
+ <span>Profile</span>
68
+ </div>
69
+ <div class='row-box'>
70
+ <button class='button-base' onClick={onSave}>
71
+ 更新
72
+ </button>{' '}
73
+ <div>(密码为空时将不更新密码)</div>
74
+ </div>
75
+ <div class='row-box mt-l'>
76
+ <label class='m-label'>邮箱:</label> {user.email}
77
+ </div>
78
+ <div class='row-box mt-l'>
79
+ <label class='m-label'>类型:</label> {user.usertype}
80
+ </div>
81
+ <hr />
82
+ <div class='row-box'>
83
+ <label class='m-label'>网名:</label>{' '}
84
+ <input type='text' class='input-base m-text f-nickname' value={user.nickname} />
85
+ </div>
86
+ <div class='row-box'>
87
+ <label class='m-label'>密码:</label> <input type='password' class='input-base m-text f-password' value='' />
88
+ </div>
89
+ <div class='row-box'>
90
+ <label class='m-label'>确认密码:</label>{' '}
91
+ <input type='password' class='input-base m-text f-password2' value='' />
92
+ </div>
93
+ </div>
94
+ );
95
+ };
96
+
97
+ export const UserProfilePage = async (props: PageProps) => {
98
+ onMount(async () => {
99
+ const user = await getUserInfo();
100
+ setDom(
101
+ <div class='padding-block'>
102
+ <PageContent user={user!}></PageContent>
103
+ </div>
104
+ );
105
+ });
106
+ const [dom, setDom] = createSignal<any>('Loading...');
107
+ return (
108
+ <div>
109
+ <div>{dom}</div>
110
+ </div>
111
+ );
112
+ };
@@ -0,0 +1,112 @@
1
+ import { createSignal, CssProps, getRenderPageProps, onMount, PageProps } from 'lupine.web';
2
+ import { DomUtils, MediaQueryMaxWidth, NotificationMessage, NotificationColor } from 'lupine.web.components';
3
+ import { getUserInfo, UserInfoType } from '../components/user-info';
4
+
5
+ const PageContent = ({ user }: { user: UserInfoType }) => {
6
+ const css: CssProps = {
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ width: '100%',
10
+ maxWidth: MediaQueryMaxWidth.DesktopMax,
11
+ margin: 'auto',
12
+ '.label': {
13
+ width: '200px',
14
+ marginBottom: '20px',
15
+ },
16
+ '.m-menu': {
17
+ display: 'flex',
18
+ flexDirection: 'row',
19
+ padding: '10px',
20
+ border: '1px solid #aaa',
21
+ borderRadius: '8px',
22
+ margin: '10px 0',
23
+ },
24
+ '.m-label': {
25
+ width: '200px',
26
+ },
27
+ '.m-text': {
28
+ // width: '400px',
29
+ marginBottom: '10px',
30
+ },
31
+ 'textarea.m-text': {
32
+ height: '80px',
33
+ },
34
+ };
35
+
36
+ const onSave = async () => {
37
+ const nickname = DomUtils.getValue('.f-nickname');
38
+ const password = DomUtils.getValue('.f-password');
39
+ const password2 = DomUtils.getValue('.f-password2');
40
+ if (!nickname) {
41
+ NotificationMessage.sendMessage("Prefer name can't be empty", NotificationColor.Error);
42
+ return;
43
+ }
44
+ if (password && password !== password2) {
45
+ NotificationMessage.sendMessage('The two passwords do not match', NotificationColor.Error);
46
+ return;
47
+ }
48
+ if (password && password.length < 6) {
49
+ NotificationMessage.sendMessage('Password length must be at least 6 characters', NotificationColor.Error);
50
+ return;
51
+ }
52
+ const data: any = {
53
+ nickname,
54
+ password,
55
+ };
56
+
57
+ const result = await getRenderPageProps().renderPageFunctions.fetchData('/api/user-profile', JSON.stringify(data));
58
+ console.log(result);
59
+ NotificationMessage.sendMessage(result.json.message || 'Update success', NotificationColor.Success);
60
+ setTimeout(() => {
61
+ document.location.reload();
62
+ }, 1000);
63
+ };
64
+ return (
65
+ <div css={css}>
66
+ <div class='row-box m-menu'>
67
+ <span>Profile</span>
68
+ </div>
69
+ <div class='row-box'>
70
+ <button class='button-base' onClick={onSave}>
71
+ Update
72
+ </button>{' '}
73
+ <div>(Password will not be updated if it is empty)</div>
74
+ </div>
75
+ <div class='row-box mt-l'>
76
+ <label class='m-label'>Email:</label> {user.email}
77
+ </div>
78
+ <div class='row-box mt-l'>
79
+ <label class='m-label'>Type:</label> {user.usertype}
80
+ </div>
81
+ <hr />
82
+ <div class='row-box'>
83
+ <label class='m-label'>Prefer name:</label>{' '}
84
+ <input type='text' class='input-base m-text f-nickname' value={user.nickname} />
85
+ </div>
86
+ <div class='row-box'>
87
+ <label class='m-label'>Password:</label> <input type='password' class='input-base m-text f-password' value='' />
88
+ </div>
89
+ <div class='row-box'>
90
+ <label class='m-label'>Confirm password:</label>{' '}
91
+ <input type='password' class='input-base m-text f-password2' value='' />
92
+ </div>
93
+ </div>
94
+ );
95
+ };
96
+
97
+ export const UserProfilePage = async (props: PageProps) => {
98
+ onMount(async () => {
99
+ const user = await getUserInfo();
100
+ setDom(
101
+ <div class='padding-block'>
102
+ <PageContent user={user!}></PageContent>
103
+ </div>
104
+ );
105
+ });
106
+ const [dom, setDom] = createSignal<any>('Loading...');
107
+ return (
108
+ <div>
109
+ <div>{dom}</div>
110
+ </div>
111
+ );
112
+ };
@@ -0,0 +1,57 @@
1
+ import { createSignal, CssProps, getRenderPageProps, onMount } from 'lupine.web';
2
+ import { MediaQueryMaxWidth } from 'lupine.web.components';
3
+
4
+ export const User1Page = async () => {
5
+ const css: CssProps = {
6
+ display: 'flex',
7
+ flexDirection: 'column',
8
+ width: '100%',
9
+ maxWidth: MediaQueryMaxWidth.DesktopMax,
10
+ margin: 'auto',
11
+ '.gauge-box': {
12
+ margin: 'auto',
13
+ width: '90%',
14
+ maxWidth: '500px',
15
+ backgroundColor: '#00000000',
16
+ boxShadow: '#000000 13.02px 13.02px 52.08px 0px',
17
+ borderRadius: '16px',
18
+ padding: '40px',
19
+ textAlign: 'center',
20
+ },
21
+ '.sound-box': {
22
+ margin: 'auto',
23
+ // height: '30px',
24
+ textAlign: 'center',
25
+ fontSize: '20px',
26
+ padding: '10px',
27
+ fontWeight: 'bold',
28
+ fontFamily: 'Roboto, sans-serif',
29
+ },
30
+ '.toggle-box': {
31
+ textAlign: 'center',
32
+ },
33
+ };
34
+
35
+ const [nodeTest1, setNodeTest1] = createSignal<any>('');
36
+ const [nodeTest2, setNodeTest2] = createSignal<any>('Initial Value');
37
+ const onClickTuner = async (checked: boolean) => {
38
+ setNodeTest1('Value set in onClickTuner event: ' + checked);
39
+ };
40
+
41
+ onMount(() => {
42
+ setNodeTest1('parameter1: ' +
43
+ getRenderPageProps().urlParameters?.parameter1 +
44
+ ', option1: ' +
45
+ getRenderPageProps().urlParameters?.option1);
46
+ setNodeTest2('Value set in onLoad event');
47
+ });
48
+ return (
49
+ <div css={css} class='gauge-top'>
50
+ <div class='gauge-box'>
51
+ <div class='sound-box'>{nodeTest1}</div>
52
+ <div class='sound-box'>{nodeTest2}</div>
53
+ <div class='toggle-box'>Sample text</div>
54
+ </div>
55
+ </div>
56
+ );
57
+ };
@@ -0,0 +1,55 @@
1
+ import { getCookie, JsonObject, webEnv } from 'lupine.web';
2
+
3
+ export const baseUrl = (urlWithoutHost?: string) => {
4
+ let baseUrl = webEnv('API_BASE_URL', '');
5
+ if (baseUrl.endsWith('/')) {
6
+ baseUrl = baseUrl.slice(0, -1);
7
+ }
8
+ return baseUrl + (urlWithoutHost || '');
9
+ };
10
+
11
+ export const fetchData = async (
12
+ urlWithoutHost: string,
13
+ postData?: string | JsonObject,
14
+ returnRawResponse?: boolean,
15
+ returnHeaders?: boolean
16
+ ) => {
17
+ const url = baseUrl(urlWithoutHost);
18
+ console.log('========fetchData', url);
19
+
20
+ const keepData =
21
+ typeof postData === 'string' ||
22
+ postData instanceof File ||
23
+ postData instanceof FormData ||
24
+ postData instanceof Blob;
25
+ const option = {
26
+ method: postData ? 'POST' : 'GET',
27
+ credentials: 'include' as RequestCredentials,
28
+ headers: new Headers({
29
+ _token: getCookie('_token') || '',
30
+ }),
31
+ body: postData ? (keepData ? postData : JSON.stringify(postData)) : undefined,
32
+ };
33
+ try {
34
+ const response = await fetch(url, option);
35
+ if (returnRawResponse) {
36
+ return response;
37
+ }
38
+ // const json = await data.json();
39
+ const text = await response.text();
40
+ const headers: { [key: string]: string } = {};
41
+ if (returnHeaders) {
42
+ response.headers.forEach((value, key) => {
43
+ headers[key] = value;
44
+ });
45
+ }
46
+ try {
47
+ const json = JSON.parse(text);
48
+ return returnHeaders ? { json, headers } : { json };
49
+ } catch (e) {
50
+ return returnHeaders ? { text, headers } : { text };
51
+ }
52
+ } catch (e) {
53
+ return { json: { status: 'error', error: e } };
54
+ }
55
+ };
@@ -0,0 +1,19 @@
1
+ import { getEitherCookie, setCookie } from 'lupine.web';
2
+ import { userCookieName } from '../models';
3
+
4
+ export type UserCookieType = {
5
+ u?: string;
6
+ t?: string;
7
+ };
8
+ export const getCookieUser = (): UserCookieType => {
9
+ try {
10
+ return JSON.parse(getEitherCookie(userCookieName) || '{}');
11
+ } catch (e) {
12
+ return {};
13
+ }
14
+ };
15
+ export const setCookieUser = (user: UserCookieType) => {
16
+ // for web, client and server are the same domain
17
+ // for mobile and desktop, client domain is localhost and userCookieName is for the client
18
+ setCookie(userCookieName, JSON.stringify(user || {}), 360, '/');
19
+ };
@@ -0,0 +1,17 @@
1
+ export const baseCss = {
2
+ '.header-title': {
3
+ fontSize: 'var(--page-title-font-size)',
4
+ textAlign: 'center',
5
+ padding: '20px 0',
6
+ },
7
+ '.msg-area': {
8
+ height: '100px',
9
+ },
10
+ '.video-box': {
11
+ width: '100%',
12
+ height: 'auto',
13
+ },
14
+ '.login-form-width': {
15
+ width: '550px',
16
+ },
17
+ };