@shiqianjiang/ceru-plugin-cli 0.3.16 → 3.0.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 (302) hide show
  1. package/README.md +26 -7
  2. package/assets/compatibility.json +18 -0
  3. package/dist/compatibility.d.ts +24 -0
  4. package/dist/compatibility.js +119 -0
  5. package/dist/component.d.ts +6 -0
  6. package/dist/component.js +60 -0
  7. package/dist/dev-music.d.ts +19 -0
  8. package/dist/dev-music.js +81 -0
  9. package/dist/dev-plugin-services.d.ts +10 -0
  10. package/dist/dev-plugin-services.js +67 -0
  11. package/dist/dev.d.ts +1 -9
  12. package/dist/dev.js +53 -713
  13. package/dist/frameworks.d.ts +5 -2
  14. package/dist/frameworks.js +43 -6
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +54 -23
  17. package/dist/init.js +3 -3
  18. package/dist/migrate.d.ts +3 -0
  19. package/dist/migrate.js +109 -0
  20. package/dist/project.d.ts +5 -2
  21. package/dist/project.js +131 -43
  22. package/dist/test-hooks.d.ts +1 -0
  23. package/dist/test-hooks.js +209 -0
  24. package/dist/test-services.d.ts +4 -0
  25. package/dist/test-services.js +54 -0
  26. package/dist/watch-vue-types.d.ts +17 -0
  27. package/dist/watch-vue-types.js +145 -0
  28. package/package.json +10 -6
  29. package/schemas/config.schema.json +954 -452
  30. package/templates/account-qrcode/js/.vscode/extensions.json +3 -0
  31. package/templates/account-qrcode/js/.vscode/launch.json +19 -0
  32. package/templates/account-qrcode/js/.vscode/settings.json +20 -0
  33. package/templates/account-qrcode/js/.vscode/tasks.json +43 -0
  34. package/templates/account-qrcode/js/README.md +15 -0
  35. package/templates/account-qrcode/js/_gitignore +6 -0
  36. package/templates/account-qrcode/js/ceru-plugin.code-workspace +8 -0
  37. package/templates/account-qrcode/js/ceru.plugin.json +62 -0
  38. package/templates/account-qrcode/js/package.json +24 -0
  39. package/templates/account-qrcode/js/src/Login.vue +25 -0
  40. package/templates/account-qrcode/js/src/index.js +25 -0
  41. package/templates/account-qrcode/js/src/login-html.js +23 -0
  42. package/templates/account-qrcode/js/tsconfig.json +17 -0
  43. package/templates/account-qrcode/ts/.vscode/extensions.json +3 -0
  44. package/templates/account-qrcode/ts/.vscode/launch.json +19 -0
  45. package/templates/account-qrcode/ts/.vscode/settings.json +20 -0
  46. package/templates/account-qrcode/ts/.vscode/tasks.json +43 -0
  47. package/templates/account-qrcode/ts/README.md +15 -0
  48. package/templates/account-qrcode/ts/_gitignore +6 -0
  49. package/templates/account-qrcode/ts/ceru-plugin.code-workspace +8 -0
  50. package/templates/account-qrcode/ts/ceru.plugin.json +62 -0
  51. package/templates/account-qrcode/ts/package.json +24 -0
  52. package/templates/account-qrcode/ts/src/Login.vue +25 -0
  53. package/templates/account-qrcode/ts/src/index.ts +25 -0
  54. package/templates/account-qrcode/ts/src/login-html.ts +23 -0
  55. package/templates/account-qrcode/ts/tsconfig.json +17 -0
  56. package/templates/connected-library/js/.vscode/launch.json +12 -29
  57. package/templates/connected-library/js/.vscode/tasks.json +2 -3
  58. package/templates/connected-library/js/README.md +26 -12
  59. package/templates/connected-library/js/ceru.plugin.json +122 -50
  60. package/templates/connected-library/js/package.json +5 -5
  61. package/templates/connected-library/js/src/index.js +46 -5
  62. package/templates/connected-library/js/src/settings.js +28 -0
  63. package/templates/connected-library/ts/.vscode/launch.json +12 -29
  64. package/templates/connected-library/ts/.vscode/tasks.json +2 -3
  65. package/templates/connected-library/ts/README.md +26 -12
  66. package/templates/connected-library/ts/ceru.plugin.json +122 -50
  67. package/templates/connected-library/ts/package.json +5 -5
  68. package/templates/connected-library/ts/src/index.ts +46 -5
  69. package/templates/connected-library/ts/src/settings.ts +28 -0
  70. package/templates/encrypted-source/README.md +86 -0
  71. package/templates/encrypted-source/js/.prettierrc.json +5 -0
  72. package/templates/encrypted-source/js/.vscode/ceru.code-snippets +55 -0
  73. package/templates/encrypted-source/js/.vscode/extensions.json +3 -0
  74. package/templates/encrypted-source/js/.vscode/launch.json +15 -0
  75. package/templates/encrypted-source/js/.vscode/settings.json +20 -0
  76. package/templates/encrypted-source/js/.vscode/tasks.json +40 -0
  77. package/templates/encrypted-source/js/DEMO.md +77 -0
  78. package/templates/encrypted-source/js/README.md +13 -0
  79. package/templates/encrypted-source/js/_gitignore +6 -0
  80. package/templates/encrypted-source/js/ceru-plugin.code-workspace +8 -0
  81. package/templates/encrypted-source/js/ceru.plugin.json +95 -0
  82. package/templates/encrypted-source/js/package.json +26 -0
  83. package/templates/encrypted-source/js/resources/xor-byte.wasm +0 -0
  84. package/templates/encrypted-source/js/resources/xor-byte.wat +5 -0
  85. package/templates/encrypted-source/js/src/demo.js +200 -0
  86. package/templates/encrypted-source/js/src/fixtures.js +118 -0
  87. package/templates/encrypted-source/js/src/index.js +4 -0
  88. package/templates/encrypted-source/js/tests/demo.test.mjs +357 -0
  89. package/templates/encrypted-source/js/tsconfig.json +16 -0
  90. package/templates/encrypted-source/ts/.prettierrc.json +5 -0
  91. package/templates/encrypted-source/ts/.vscode/ceru.code-snippets +55 -0
  92. package/templates/encrypted-source/ts/.vscode/extensions.json +3 -0
  93. package/templates/encrypted-source/ts/.vscode/launch.json +15 -0
  94. package/templates/encrypted-source/ts/.vscode/settings.json +20 -0
  95. package/templates/encrypted-source/ts/.vscode/tasks.json +40 -0
  96. package/templates/encrypted-source/ts/DEMO.md +77 -0
  97. package/templates/encrypted-source/ts/README.md +13 -0
  98. package/templates/encrypted-source/ts/_gitignore +6 -0
  99. package/templates/encrypted-source/ts/ceru-plugin.code-workspace +8 -0
  100. package/templates/encrypted-source/ts/ceru.plugin.json +95 -0
  101. package/templates/encrypted-source/ts/package.json +26 -0
  102. package/templates/encrypted-source/ts/resources/xor-byte.wasm +0 -0
  103. package/templates/encrypted-source/ts/resources/xor-byte.wat +5 -0
  104. package/templates/encrypted-source/ts/src/demo.ts +212 -0
  105. package/templates/encrypted-source/ts/src/fixtures.ts +125 -0
  106. package/templates/encrypted-source/ts/src/index.ts +4 -0
  107. package/templates/encrypted-source/ts/tests/demo.test.mjs +357 -0
  108. package/templates/encrypted-source/ts/tsconfig.json +17 -0
  109. package/templates/guest-adapter/js/.vscode/launch.json +12 -29
  110. package/templates/guest-adapter/js/.vscode/tasks.json +2 -3
  111. package/templates/guest-adapter/js/README.md +10 -10
  112. package/templates/guest-adapter/js/ceru.plugin.json +67 -62
  113. package/templates/guest-adapter/js/package.json +5 -5
  114. package/templates/guest-adapter/js/src/index.js +1 -1
  115. package/templates/guest-adapter/js/src/settings.js +8 -0
  116. package/templates/guest-adapter/ts/.vscode/launch.json +12 -29
  117. package/templates/guest-adapter/ts/.vscode/tasks.json +2 -3
  118. package/templates/guest-adapter/ts/README.md +10 -10
  119. package/templates/guest-adapter/ts/ceru.plugin.json +67 -62
  120. package/templates/guest-adapter/ts/package.json +5 -5
  121. package/templates/guest-adapter/ts/src/index.ts +1 -1
  122. package/templates/guest-adapter/ts/src/settings.ts +8 -0
  123. package/templates/importer/js/.vscode/launch.json +12 -29
  124. package/templates/importer/js/.vscode/tasks.json +2 -3
  125. package/templates/importer/js/README.md +10 -10
  126. package/templates/importer/js/ceru.plugin.json +23 -21
  127. package/templates/importer/js/package.json +5 -5
  128. package/templates/importer/ts/.vscode/launch.json +12 -29
  129. package/templates/importer/ts/.vscode/tasks.json +2 -3
  130. package/templates/importer/ts/README.md +10 -10
  131. package/templates/importer/ts/ceru.plugin.json +23 -21
  132. package/templates/importer/ts/package.json +5 -5
  133. package/templates/page-extension/js/.vscode/extensions.json +3 -0
  134. package/templates/page-extension/js/.vscode/launch.json +19 -0
  135. package/templates/page-extension/js/.vscode/settings.json +20 -0
  136. package/templates/page-extension/js/.vscode/tasks.json +43 -0
  137. package/templates/page-extension/js/README.md +9 -0
  138. package/templates/page-extension/js/_gitignore +6 -0
  139. package/templates/page-extension/js/ceru-plugin.code-workspace +8 -0
  140. package/templates/page-extension/js/ceru.plugin.json +94 -0
  141. package/templates/page-extension/js/package.json +24 -0
  142. package/templates/page-extension/js/src/Open.vue +6 -0
  143. package/templates/page-extension/js/src/Search.vue +62 -0
  144. package/templates/page-extension/js/src/index.js +54 -0
  145. package/templates/page-extension/js/tsconfig.json +17 -0
  146. package/templates/page-extension/ts/.vscode/extensions.json +3 -0
  147. package/templates/page-extension/ts/.vscode/launch.json +19 -0
  148. package/templates/page-extension/ts/.vscode/settings.json +20 -0
  149. package/templates/page-extension/ts/.vscode/tasks.json +43 -0
  150. package/templates/page-extension/ts/README.md +9 -0
  151. package/templates/page-extension/ts/_gitignore +6 -0
  152. package/templates/page-extension/ts/ceru-plugin.code-workspace +8 -0
  153. package/templates/page-extension/ts/ceru.plugin.json +94 -0
  154. package/templates/page-extension/ts/package.json +24 -0
  155. package/templates/page-extension/ts/src/Open.vue +6 -0
  156. package/templates/page-extension/ts/src/Search.vue +62 -0
  157. package/templates/page-extension/ts/src/index.ts +54 -0
  158. package/templates/page-extension/ts/tsconfig.json +17 -0
  159. package/templates/playback-hook/js/.prettierrc.json +5 -0
  160. package/templates/playback-hook/js/.vscode/extensions.json +3 -0
  161. package/templates/playback-hook/js/.vscode/launch.json +19 -0
  162. package/templates/playback-hook/js/.vscode/settings.json +20 -0
  163. package/templates/playback-hook/js/.vscode/tasks.json +50 -0
  164. package/templates/playback-hook/js/README.md +24 -0
  165. package/templates/playback-hook/js/_gitignore +6 -0
  166. package/templates/playback-hook/js/ceru-plugin.code-workspace +8 -0
  167. package/templates/playback-hook/js/ceru.plugin.json +36 -0
  168. package/templates/playback-hook/js/package.json +23 -0
  169. package/templates/playback-hook/js/src/index.js +25 -0
  170. package/templates/playback-hook/js/tests/hooks.json +316 -0
  171. package/templates/playback-hook/js/tsconfig.json +16 -0
  172. package/templates/playback-hook/ts/.prettierrc.json +5 -0
  173. package/templates/playback-hook/ts/.vscode/extensions.json +3 -0
  174. package/templates/playback-hook/ts/.vscode/launch.json +19 -0
  175. package/templates/playback-hook/ts/.vscode/settings.json +20 -0
  176. package/templates/playback-hook/ts/.vscode/tasks.json +50 -0
  177. package/templates/playback-hook/ts/README.md +24 -0
  178. package/templates/playback-hook/ts/_gitignore +6 -0
  179. package/templates/playback-hook/ts/ceru-plugin.code-workspace +8 -0
  180. package/templates/playback-hook/ts/ceru.plugin.json +36 -0
  181. package/templates/playback-hook/ts/package.json +23 -0
  182. package/templates/playback-hook/ts/src/index.ts +25 -0
  183. package/templates/playback-hook/ts/tests/hooks.json +316 -0
  184. package/templates/playback-hook/ts/tsconfig.json +16 -0
  185. package/templates/player-skin/js/.vscode/extensions.json +3 -0
  186. package/templates/player-skin/js/.vscode/launch.json +19 -0
  187. package/templates/player-skin/js/.vscode/settings.json +20 -0
  188. package/templates/player-skin/js/.vscode/tasks.json +43 -0
  189. package/templates/player-skin/js/README.md +11 -0
  190. package/templates/player-skin/js/_gitignore +6 -0
  191. package/templates/player-skin/js/assets/studio-preview.svg +15 -0
  192. package/templates/player-skin/js/ceru-plugin.code-workspace +8 -0
  193. package/templates/player-skin/js/ceru.plugin.json +77 -0
  194. package/templates/player-skin/js/package.json +24 -0
  195. package/templates/player-skin/js/src/Artwork.vue +9 -0
  196. package/templates/player-skin/js/src/Background.vue +15 -0
  197. package/templates/player-skin/js/src/BuiltinLyrics.vue +15 -0
  198. package/templates/player-skin/js/src/Lyrics.vue +28 -0
  199. package/templates/player-skin/js/tsconfig.json +17 -0
  200. package/templates/player-skin/ts/.vscode/extensions.json +3 -0
  201. package/templates/player-skin/ts/.vscode/launch.json +19 -0
  202. package/templates/player-skin/ts/.vscode/settings.json +20 -0
  203. package/templates/player-skin/ts/.vscode/tasks.json +43 -0
  204. package/templates/player-skin/ts/README.md +11 -0
  205. package/templates/player-skin/ts/_gitignore +6 -0
  206. package/templates/player-skin/ts/assets/studio-preview.svg +15 -0
  207. package/templates/player-skin/ts/ceru-plugin.code-workspace +8 -0
  208. package/templates/player-skin/ts/ceru.plugin.json +77 -0
  209. package/templates/player-skin/ts/package.json +24 -0
  210. package/templates/player-skin/ts/src/Artwork.vue +9 -0
  211. package/templates/player-skin/ts/src/Background.vue +15 -0
  212. package/templates/player-skin/ts/src/BuiltinLyrics.vue +15 -0
  213. package/templates/player-skin/ts/src/Lyrics.vue +28 -0
  214. package/templates/player-skin/ts/tsconfig.json +17 -0
  215. package/templates/react/js/.vscode/launch.json +12 -29
  216. package/templates/react/js/.vscode/tasks.json +2 -3
  217. package/templates/react/js/README.md +10 -10
  218. package/templates/react/js/ceru.plugin.json +27 -22
  219. package/templates/react/js/package.json +5 -5
  220. package/templates/react/js/src/index.js +1 -1
  221. package/templates/react/ts/.vscode/launch.json +12 -29
  222. package/templates/react/ts/.vscode/tasks.json +2 -3
  223. package/templates/react/ts/README.md +10 -10
  224. package/templates/react/ts/ceru.plugin.json +27 -22
  225. package/templates/react/ts/package.json +5 -5
  226. package/templates/react/ts/src/index.ts +1 -1
  227. package/templates/snapshot.json +152 -6
  228. package/templates/source/js/.vscode/launch.json +12 -29
  229. package/templates/source/js/.vscode/tasks.json +2 -3
  230. package/templates/source/js/README.md +12 -10
  231. package/templates/source/js/ceru.plugin.json +44 -26
  232. package/templates/source/js/package.json +5 -5
  233. package/templates/source/js/src/index.js +10 -8
  234. package/templates/source/ts/.vscode/launch.json +12 -29
  235. package/templates/source/ts/.vscode/tasks.json +2 -3
  236. package/templates/source/ts/README.md +12 -10
  237. package/templates/source/ts/ceru.plugin.json +44 -26
  238. package/templates/source/ts/package.json +5 -5
  239. package/templates/source/ts/src/index.ts +10 -8
  240. package/templates/vue/js/.vscode/launch.json +12 -29
  241. package/templates/vue/js/.vscode/tasks.json +2 -3
  242. package/templates/vue/js/README.md +10 -10
  243. package/templates/vue/js/ceru.plugin.json +27 -22
  244. package/templates/vue/js/package.json +5 -5
  245. package/templates/vue/js/src/index.js +1 -1
  246. package/templates/vue/ts/.vscode/launch.json +12 -29
  247. package/templates/vue/ts/.vscode/tasks.json +2 -3
  248. package/templates/vue/ts/README.md +10 -10
  249. package/templates/vue/ts/ceru.plugin.json +27 -22
  250. package/templates/vue/ts/package.json +5 -5
  251. package/templates/vue/ts/src/index.ts +1 -1
  252. package/templates/vue-tsx/js/.vscode/launch.json +12 -29
  253. package/templates/vue-tsx/js/.vscode/tasks.json +2 -3
  254. package/templates/vue-tsx/js/README.md +10 -10
  255. package/templates/vue-tsx/js/ceru.plugin.json +27 -22
  256. package/templates/vue-tsx/js/package.json +5 -5
  257. package/templates/vue-tsx/js/src/index.js +1 -1
  258. package/templates/vue-tsx/ts/.vscode/launch.json +12 -29
  259. package/templates/vue-tsx/ts/.vscode/tasks.json +2 -3
  260. package/templates/vue-tsx/ts/README.md +10 -10
  261. package/templates/vue-tsx/ts/ceru.plugin.json +27 -22
  262. package/templates/vue-tsx/ts/package.json +5 -5
  263. package/templates/vue-tsx/ts/src/index.ts +1 -1
  264. package/templates/web-dist/js/.vscode/launch.json +12 -29
  265. package/templates/web-dist/js/.vscode/tasks.json +2 -3
  266. package/templates/web-dist/js/README.md +10 -10
  267. package/templates/web-dist/js/ceru.plugin.json +27 -22
  268. package/templates/web-dist/js/package.json +5 -5
  269. package/templates/web-dist/js/src/index.js +1 -1
  270. package/templates/web-dist/ts/.vscode/launch.json +12 -29
  271. package/templates/web-dist/ts/.vscode/tasks.json +2 -3
  272. package/templates/web-dist/ts/README.md +10 -10
  273. package/templates/web-dist/ts/ceru.plugin.json +27 -22
  274. package/templates/web-dist/ts/package.json +5 -5
  275. package/templates/web-dist/ts/src/index.ts +1 -1
  276. package/templates/web-surface/js/.vscode/launch.json +12 -29
  277. package/templates/web-surface/js/.vscode/tasks.json +2 -3
  278. package/templates/web-surface/js/README.md +10 -10
  279. package/templates/web-surface/js/ceru.plugin.json +35 -35
  280. package/templates/web-surface/js/package.json +5 -5
  281. package/templates/web-surface/js/src/index.js +1 -1
  282. package/templates/web-surface/ts/.vscode/launch.json +12 -29
  283. package/templates/web-surface/ts/.vscode/tasks.json +2 -3
  284. package/templates/web-surface/ts/README.md +10 -10
  285. package/templates/web-surface/ts/ceru.plugin.json +35 -35
  286. package/templates/web-surface/ts/package.json +5 -5
  287. package/templates/web-surface/ts/src/index.ts +1 -1
  288. package/assets/core-contracts.js +0 -1
  289. package/assets/electron-app/main.cjs +0 -1
  290. package/assets/electron-app/package.json +0 -8
  291. package/assets/electron.cjs +0 -42
  292. package/assets/index.html +0 -94
  293. package/assets/native-view.js +0 -197
  294. package/assets/playground.js +0 -883
  295. package/assets/sandbox.js +0 -67
  296. package/assets/style.css +0 -337
  297. package/dist/socket-broker.d.ts +0 -23
  298. package/dist/socket-broker.js +0 -229
  299. package/templates/connected-library/js/ui/settings.json +0 -24
  300. package/templates/connected-library/ts/ui/settings.json +0 -24
  301. package/templates/guest-adapter/js/ui/settings.json +0 -14
  302. package/templates/guest-adapter/ts/ui/settings.json +0 -14
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["esbenp.prettier-vscode", "Vue.volar"]
3
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Watch Ceru plugin",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "program": "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
9
+ "args": [
10
+ "dev"
11
+ ],
12
+ "cwd": "${workspaceFolder}",
13
+ "console": "integratedTerminal",
14
+ "skipFiles": [
15
+ "<node_internals>/**"
16
+ ]
17
+ }
18
+ ]
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "typescript.tsdk": "node_modules/typescript/lib",
3
+ "typescript.enablePromptUseWorkspaceTsdk": true,
4
+ "editor.formatOnSave": true,
5
+ "[typescript]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
7
+ },
8
+ "[javascript]": {
9
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
10
+ },
11
+ "json.schemas": [
12
+ {
13
+ "fileMatch": ["/ceru.plugin.json"],
14
+ "url": "./node_modules/@shiqianjiang/ceru-plugin-cli/schemas/config.schema.json"
15
+ }
16
+ ],
17
+ "files.exclude": {
18
+ "**/*.tsbuildinfo": true
19
+ }
20
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "Ceru: dev",
6
+ "type": "process",
7
+ "isBackground": true,
8
+ "problemMatcher": {
9
+ "owner": "ceru",
10
+ "pattern": {
11
+ "regexp": "^CERU_ERROR (.*)$",
12
+ "message": 1
13
+ },
14
+ "background": {
15
+ "activeOnStart": true,
16
+ "beginsPattern": "^.*$",
17
+ "endsPattern": "^CERU_BUILD_READY "
18
+ }
19
+ },
20
+ "command": "node",
21
+ "args": [
22
+ "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
23
+ "dev"
24
+ ],
25
+ "options": {
26
+ "cwd": "${workspaceFolder}"
27
+ }
28
+ },
29
+ {
30
+ "label": "Ceru: typecheck",
31
+ "type": "npm",
32
+ "script": "typecheck",
33
+ "problemMatcher": "$tsc",
34
+ "group": "build"
35
+ },
36
+ {
37
+ "label": "Ceru: build",
38
+ "type": "npm",
39
+ "script": "build",
40
+ "problemMatcher": []
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,15 @@
1
+ # 扫码登录:两种内部 UI 模式
2
+
3
+ 运行 `npm install`、`npm run typecheck`、`npm run build`,在软件开发者模式加载 `dist/plugin.js`,从账号菜单选择「扫码登录演示」。
4
+
5
+ 修改 `src/index.js` 的 `loginView`:
6
+
7
+ - `undefined`:使用软件内置扫码模板。
8
+ - `'login'`:使用 `src/Login.vue`,Vue、TDesign 由宿主提供,不把组件实现打包到插件。
9
+ - `'login-html'`:使用纯 HTML/CSS/DOM 的 `src/login-html.js`,内部布局完全由插件设计。
10
+
11
+ 三种方式使用相同的宿主弹窗外壳、标题、关闭按钮和动画。软件负责轮询、过期重试、取消及凭据保存。自定义视图从 `login` 状态读取二维码、`waiting/scanned` 与 `expiresAt`;不要向页面传递账号凭据或自己启动另一套轮询。
12
+
13
+ 样式使用 `--td-brand-color`、`--td-text-color-primary` 等软件 CSS 变量,明暗模式和主题色会同步。组件视图调用 `useView().close()`,纯 DOM 视图调用 `ctx.close()` 即可取消。
14
+
15
+ 本模板不联网、不收集真实凭据。二维码指向保留示例域名,无需扫描;演示约 5 秒显示已扫码、10 秒后完成。接入真实平台时替换二维码申请和 `poll(operation)`,使用本次操作的取消信号与显式网络/凭据权限。
@@ -0,0 +1,6 @@
1
+ node_modules/
2
+ dist/
3
+ .keys/
4
+ .ceru-dev/
5
+ *.private.pem
6
+ *.tsbuildinfo
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": ".",
5
+ },
6
+ ],
7
+ "settings": {},
8
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "manifest": {
3
+ "manifestVersion": 3,
4
+ "id": "local.account-qrcode",
5
+ "name": "扫码登录演示",
6
+ "version": "0.1.0",
7
+ "engines": {
8
+ "hostApi": "^3.0.0",
9
+ "logicRuntime": "ceru-js@1"
10
+ },
11
+ "entry": {
12
+ "logic": {
13
+ "module": "logic.main"
14
+ },
15
+ "views": [
16
+ {
17
+ "id": "login",
18
+ "kind": "component",
19
+ "module": "view.login",
20
+ "presentation": {
21
+ "kind": "drawer",
22
+ "size": 420
23
+ }
24
+ },
25
+ {
26
+ "id": "login-html",
27
+ "kind": "web",
28
+ "module": "view.html",
29
+ "presentation": {
30
+ "kind": "drawer",
31
+ "size": 420
32
+ }
33
+ }
34
+ ]
35
+ },
36
+ "provides": {
37
+ "accounts": [
38
+ {
39
+ "id": "demo",
40
+ "title": "扫码登录演示",
41
+ "loginMethods": [
42
+ "qrcode"
43
+ ],
44
+ "capabilities": [
45
+ "profile"
46
+ ]
47
+ }
48
+ ]
49
+ },
50
+ "uses": {
51
+ "permissions": []
52
+ },
53
+ "description": "宿主模板与插件自定义登录内容"
54
+ },
55
+ "framework": "vue",
56
+ "entries": {
57
+ "logic.main": "src/index.js",
58
+ "view.login": "src/Login.vue",
59
+ "view.html": "src/login-html.js"
60
+ },
61
+ "output": "dist/plugin.js"
62
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "ceru-account-qrcode",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "ceru-plugin dev",
8
+ "build": "ceru-plugin build",
9
+ "typecheck": "ceru-plugin typecheck",
10
+ "validate": "ceru-plugin validate dist/plugin.js",
11
+ "preview": "ceru-plugin preview dist/plugin.js",
12
+ "check:compat": "ceru-plugin check-compat"
13
+ },
14
+ "dependencies": {
15
+ "@shiqianjiang/ceru-plugin-sdk": "^3.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@shiqianjiang/ceru-plugin-cli": "^3.0.0",
19
+ "typescript": "~5.9.3",
20
+ "prettier": "^3.6.2",
21
+ "vue": "^3.5.21",
22
+ "tdesign-vue-next": "1.15.4"
23
+ }
24
+ }
@@ -0,0 +1,25 @@
1
+ <script setup >
2
+ import { Button } from 'tdesign-vue-next'
3
+ import { useView, useViewState } from '@shiqianjiang/ceru-plugin-sdk/vue'
4
+
5
+ const bridge = useView()
6
+ const state = useViewState()
7
+ </script>
8
+ <template>
9
+ <section class="login-content">
10
+ <div class="brand">DEMO · 扫码登录</div>
11
+ <p>这是本地演示二维码,无需使用手机扫描。</p>
12
+ <div class="code"><img :src="state.login?.image" width="208" height="208" alt="演示登录二维码" /></div>
13
+ <p class="status" role="status" aria-live="polite">{{ state.login?.status === 'scanned' ? '已扫码,请在手机确认' : '等待扫码' }}</p>
14
+ <Button block variant="outline" @click="bridge.close()">取消登录</Button>
15
+ </section>
16
+ </template>
17
+ <style scoped>
18
+ .login-content { display: grid; justify-items: center; gap: 16px; padding: 8px; color: var(--td-text-color-primary); }
19
+ .brand { font-size: 20px; font-weight: 600; color: var(--td-brand-color); }
20
+ p { margin: 0; color: var(--td-text-color-secondary); font-size: 13px; }
21
+ .code { padding: 16px; background: white; border-radius: 16px; }
22
+ img { display: block; }
23
+ .status { min-height: 22px; }
24
+ .login-content > :last-child { justify-self: stretch; }
25
+ </style>
@@ -0,0 +1,25 @@
1
+ import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
2
+
3
+ // undefined: 软件默认模板;'login': 宿主 Vue/TDesign;'login-html': 纯 HTML/CSS。
4
+ const loginView = 'login'
5
+ const demoImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAACUCAYAAAB1PADUAAAAAklEQVR4AewaftIAAATiSURBVO3BQY4cSRIEQdNA/f/Lujz6KYBEenWTsyaCf6RqyUnVopOqRSdVi06qFp1ULTqpWnRSteikatFJ1aKTqkUnVYtOqhadVC06qVp0UrXok5eA/CQ1E5AbNROQSc0E5Ak1E5A31ExAfpKaN06qFp1ULTqpWvTJMjWbgGxS84SaGyA3am6APKFmE5BNJ1WLTqoWnVQt+uTLgDyh5gk1E5AbIDdq3lAzAZnUbALyhJpvOqladFK16KRq0Sf/OCDfBORGzQRkUjMBmdT8l5xULTqpWnRSteiTf5yaCcgTap5QMwGZ1DwBZFLzLzupWnRSteikatEnX6bmNwF5AsikZgJyA+QnqfmbnFQtOqladFK16JNlQH4SkEnNBGRSMwGZ1ExAJjUTkEnNBGRSMwF5Asjf7KRq0UnVopOqRfhH/mFANqm5AfKEmv8nJ1WLTqoWnVQt+uQlIJOaCciNmgnIE2pugExqboBMat4AcqPmBsik5gbIpGYCcqPmjZOqRSdVi06qFuEf+YcA+ZuoeQLIN6l5Asik5o2TqkUnVYtOqhZ98mVAnlAzAZnU3ACZ1ExAnlBzA2RSMwGZ1ExAnlDzBJAbNZtOqhadVC06qVr0yUtAJjU3aiYgN2omIDdqJiCTmjeATGpu1ExAbtQ8AWRSM6m5ATKpeeOkatFJ1aKTqkWffJmaCcikZgKySc0NkEnNBGRScwNkUnOjZgIyqblRMwG5UTOp2XRSteikatFJ1SL8I4uA3Kh5A8gTat4A8oaaCcik5gbIpOYJIE+oeeOkatFJ1aKTqkWffJmaGyCTmgnIjZoJyA2QSc0EZFLzk4BMaiYgN2p+00nVopOqRSdViz75ZWpu1ExAbtRMQJ5QMwF5Qs2NmieAvKFmAjKp2XRSteikatFJ1aJPXgJyA+QJNROQbwIyqXlCzQ2QSc0TaiYgN0AmNT/ppGrRSdWik6pFn7yk5g0gE5BJzQTkCTUTkG8CMqm5ATKpeULNBGQC8pNOqhadVC06qVr0yUtAJjU3QCY1E5AJyA2QSc0bQJ4AMqn5TWomIJOabzqpWnRSteikahH+kV8E5EbNE0AmNU8AuVEzAblR8wSQSc0NkEnNBGRS800nVYtOqhadVC36ZBmQGzU3aiYgN2omNTdAJjXfBGRSMwG5AfIEkN90UrXopGrRSdWiT5apeULNjZobIJOaCcikZgIyqflNap4A8gSQGzVvnFQtOqladFK16JOXgPwkNW8AmdTcAJnUTGomIJOaCcgTQCY1T6iZgExqNp1ULTqpWnRSteiTZWo2AXlDzRNA3lAzAZnUTEBu1GxS800nVYtOqhadVC365MuAPKHmCTUTkBs1N2pugExqJiCTmieAvKFmAnKjZtNJ1aKTqkUnVYs++ccBmdRMQCYgk5oJyKTmBsgTQJ5QMwG5ATKpuQEyqXnjpGrRSdWik6pFn/zHqXlCzY2aJ4DcqJmAPKHmBsik5ptOqhadVC06qVr0yZep+SY1E5An1LwBZFJzo2YCcgNkUjMBuVEzAZnUbDqpWnRSteikatEny4D8JCCTmhsgE5BJzQTkRs2NmgnIjZo31Pymk6pFJ1WLTqoW4R+pWnJSteikatFJ1aKTqkUnVYtOqhadVC06qVp0UrXopGrRSdWik6pFJ1WLTqoWnVQt+h8AsUc0QEvSvQAAAABJRU5ErkJggg=="
6
+ export default definePlugin((ctx) => {
7
+ ctx.accounts.register('demo', {
8
+ async login({ auth }) {
9
+ let polls = 0
10
+ return auth.qrcode({
11
+ image: demoImage,
12
+ view: loginView,
13
+ expiresInMs: 120000,
14
+ async poll(operation) {
15
+ operation.signal.throwIfAborted()
16
+ // 本地演示:约 5 秒后“已扫码”,约 10 秒后完成。请替换成平台 API。
17
+ polls++
18
+ if (polls >= 11) return { status: 'done', credential: 'synthetic-demo-only' }
19
+ return { status: polls >= 6 ? 'scanned' : 'waiting' }
20
+ },
21
+ })
22
+ },
23
+ profile: () => ({ id: 'demo', displayName: '扫码演示用户' }),
24
+ })
25
+ })
@@ -0,0 +1,23 @@
1
+ import { defineSurface } from '@shiqianjiang/ceru-plugin-sdk'
2
+
3
+ // 没有 Vue 或 UI 组件依赖;只控制弹窗内部内容,外壳、标题与关闭按钮属于软件。
4
+ export default defineSurface((ctx) => {
5
+ ctx.root.innerHTML = `<style>
6
+ .custom-login { font: 14px/1.6 system-ui; color: var(--td-text-color-primary); padding: 8px; display: grid; gap: 16px; justify-items: center; }
7
+ .custom-login h2 { color: var(--td-brand-color); margin: 0; font-size: 20px; }
8
+ .custom-login p { margin: 0; color: var(--td-text-color-secondary); }
9
+ .custom-login img { display: block; width: 208px; height: 208px; padding: 16px; background: white; border-radius: 16px; }
10
+ .custom-login button { width: 100%; padding: 9px; color: inherit; background: var(--td-bg-color-container); border: 1px solid var(--td-component-border); border-radius: 6px; cursor: pointer; }
11
+ .custom-login button:hover { background: var(--td-bg-color-container-hover); }
12
+ </style><section class="custom-login"><h2>DEMO · 自定义 HTML</h2><p>本地演示,无需扫描</p><img alt="演示登录二维码"><p role="status" aria-live="polite"></p><button type="button">取消登录</button></section>`
13
+ const image = ctx.root.querySelector('img')
14
+ const status = ctx.root.querySelector('[role="status"]')
15
+ const cancel = () => { void ctx.close() }
16
+ ctx.root.querySelector('button').addEventListener('click', cancel)
17
+ const unsubscribe = ctx.subscribe(state => {
18
+ const login = state.login
19
+ if (login?.image) image.src = login.image
20
+ status.textContent = login?.status === 'scanned' ? '已扫码,请在手机确认' : '等待扫码'
21
+ })
22
+ return () => { unsubscribe(); ctx.root.replaceChildren() }
23
+ })
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "skipLibCheck": true,
9
+ "allowJs": true,
10
+ "checkJs": false,
11
+ "lib": ["ES2022", "DOM"],
12
+ "types": [],
13
+ "jsx": "preserve",
14
+ "jsxImportSource": "vue"
15
+ },
16
+ "include": ["src", ".ceru-dev/types/**/*.d.ts"]
17
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["esbenp.prettier-vscode", "Vue.volar"]
3
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Watch Ceru plugin",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "program": "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
9
+ "args": [
10
+ "dev"
11
+ ],
12
+ "cwd": "${workspaceFolder}",
13
+ "console": "integratedTerminal",
14
+ "skipFiles": [
15
+ "<node_internals>/**"
16
+ ]
17
+ }
18
+ ]
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "typescript.tsdk": "node_modules/typescript/lib",
3
+ "typescript.enablePromptUseWorkspaceTsdk": true,
4
+ "editor.formatOnSave": true,
5
+ "[typescript]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
7
+ },
8
+ "[javascript]": {
9
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
10
+ },
11
+ "json.schemas": [
12
+ {
13
+ "fileMatch": ["/ceru.plugin.json"],
14
+ "url": "./node_modules/@shiqianjiang/ceru-plugin-cli/schemas/config.schema.json"
15
+ }
16
+ ],
17
+ "files.exclude": {
18
+ "**/*.tsbuildinfo": true
19
+ }
20
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "Ceru: dev",
6
+ "type": "process",
7
+ "isBackground": true,
8
+ "problemMatcher": {
9
+ "owner": "ceru",
10
+ "pattern": {
11
+ "regexp": "^CERU_ERROR (.*)$",
12
+ "message": 1
13
+ },
14
+ "background": {
15
+ "activeOnStart": true,
16
+ "beginsPattern": "^.*$",
17
+ "endsPattern": "^CERU_BUILD_READY "
18
+ }
19
+ },
20
+ "command": "node",
21
+ "args": [
22
+ "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
23
+ "dev"
24
+ ],
25
+ "options": {
26
+ "cwd": "${workspaceFolder}"
27
+ }
28
+ },
29
+ {
30
+ "label": "Ceru: typecheck",
31
+ "type": "npm",
32
+ "script": "typecheck",
33
+ "problemMatcher": "$tsc",
34
+ "group": "build"
35
+ },
36
+ {
37
+ "label": "Ceru: build",
38
+ "type": "npm",
39
+ "script": "build",
40
+ "problemMatcher": []
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,15 @@
1
+ # 扫码登录:两种内部 UI 模式
2
+
3
+ 运行 `npm install`、`npm run typecheck`、`npm run build`,在软件开发者模式加载 `dist/plugin.js`,从账号菜单选择「扫码登录演示」。
4
+
5
+ 修改 `src/index.ts` 的 `loginView`:
6
+
7
+ - `undefined`:使用软件内置扫码模板。
8
+ - `'login'`:使用 `src/Login.vue`,Vue、TDesign 由宿主提供,不把组件实现打包到插件。
9
+ - `'login-html'`:使用纯 HTML/CSS/DOM 的 `src/login-html.ts`,内部布局完全由插件设计。
10
+
11
+ 三种方式使用相同的宿主弹窗外壳、标题、关闭按钮和动画。软件负责轮询、过期重试、取消及凭据保存。自定义视图从 `login` 状态读取二维码、`waiting/scanned` 与 `expiresAt`;不要向页面传递账号凭据或自己启动另一套轮询。
12
+
13
+ 样式使用 `--td-brand-color`、`--td-text-color-primary` 等软件 CSS 变量,明暗模式和主题色会同步。组件视图调用 `useView().close()`,纯 DOM 视图调用 `ctx.close()` 即可取消。
14
+
15
+ 本模板不联网、不收集真实凭据。二维码指向保留示例域名,无需扫描;演示约 5 秒显示已扫码、10 秒后完成。接入真实平台时替换二维码申请和 `poll(operation)`,使用本次操作的取消信号与显式网络/凭据权限。
@@ -0,0 +1,6 @@
1
+ node_modules/
2
+ dist/
3
+ .keys/
4
+ .ceru-dev/
5
+ *.private.pem
6
+ *.tsbuildinfo
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": ".",
5
+ },
6
+ ],
7
+ "settings": {},
8
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "manifest": {
3
+ "manifestVersion": 3,
4
+ "id": "local.account-qrcode",
5
+ "name": "扫码登录演示",
6
+ "version": "0.1.0",
7
+ "engines": {
8
+ "hostApi": "^3.0.0",
9
+ "logicRuntime": "ceru-js@1"
10
+ },
11
+ "entry": {
12
+ "logic": {
13
+ "module": "logic.main"
14
+ },
15
+ "views": [
16
+ {
17
+ "id": "login",
18
+ "kind": "component",
19
+ "module": "view.login",
20
+ "presentation": {
21
+ "kind": "drawer",
22
+ "size": 420
23
+ }
24
+ },
25
+ {
26
+ "id": "login-html",
27
+ "kind": "web",
28
+ "module": "view.html",
29
+ "presentation": {
30
+ "kind": "drawer",
31
+ "size": 420
32
+ }
33
+ }
34
+ ]
35
+ },
36
+ "provides": {
37
+ "accounts": [
38
+ {
39
+ "id": "demo",
40
+ "title": "扫码登录演示",
41
+ "loginMethods": [
42
+ "qrcode"
43
+ ],
44
+ "capabilities": [
45
+ "profile"
46
+ ]
47
+ }
48
+ ]
49
+ },
50
+ "uses": {
51
+ "permissions": []
52
+ },
53
+ "description": "宿主模板与插件自定义登录内容"
54
+ },
55
+ "framework": "vue",
56
+ "entries": {
57
+ "logic.main": "src/index.ts",
58
+ "view.login": "src/Login.vue",
59
+ "view.html": "src/login-html.ts"
60
+ },
61
+ "output": "dist/plugin.js"
62
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "ceru-account-qrcode",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "ceru-plugin dev",
8
+ "build": "ceru-plugin build",
9
+ "typecheck": "ceru-plugin typecheck",
10
+ "validate": "ceru-plugin validate dist/plugin.js",
11
+ "preview": "ceru-plugin preview dist/plugin.js",
12
+ "check:compat": "ceru-plugin check-compat"
13
+ },
14
+ "dependencies": {
15
+ "@shiqianjiang/ceru-plugin-sdk": "^3.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@shiqianjiang/ceru-plugin-cli": "^3.0.0",
19
+ "typescript": "~5.9.3",
20
+ "prettier": "^3.6.2",
21
+ "vue": "^3.5.21",
22
+ "tdesign-vue-next": "1.15.4"
23
+ }
24
+ }
@@ -0,0 +1,25 @@
1
+ <script setup lang="ts">
2
+ import { Button } from 'tdesign-vue-next'
3
+ import { useView, useViewState } from '@shiqianjiang/ceru-plugin-sdk/vue'
4
+ import type { AccountQrViewState } from '@shiqianjiang/ceru-plugin-sdk'
5
+ const bridge = useView()
6
+ const state = useViewState<{ login: AccountQrViewState }>()
7
+ </script>
8
+ <template>
9
+ <section class="login-content">
10
+ <div class="brand">DEMO · 扫码登录</div>
11
+ <p>这是本地演示二维码,无需使用手机扫描。</p>
12
+ <div class="code"><img :src="state.login?.image" width="208" height="208" alt="演示登录二维码" /></div>
13
+ <p class="status" role="status" aria-live="polite">{{ state.login?.status === 'scanned' ? '已扫码,请在手机确认' : '等待扫码' }}</p>
14
+ <Button block variant="outline" @click="bridge.close()">取消登录</Button>
15
+ </section>
16
+ </template>
17
+ <style scoped>
18
+ .login-content { display: grid; justify-items: center; gap: 16px; padding: 8px; color: var(--td-text-color-primary); }
19
+ .brand { font-size: 20px; font-weight: 600; color: var(--td-brand-color); }
20
+ p { margin: 0; color: var(--td-text-color-secondary); font-size: 13px; }
21
+ .code { padding: 16px; background: white; border-radius: 16px; }
22
+ img { display: block; }
23
+ .status { min-height: 22px; }
24
+ .login-content > :last-child { justify-self: stretch; }
25
+ </style>
@@ -0,0 +1,25 @@
1
+ import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
2
+
3
+ // undefined: 软件默认模板;'login': 宿主 Vue/TDesign;'login-html': 纯 HTML/CSS。
4
+ const loginView = 'login'
5
+ const demoImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAACUCAYAAAB1PADUAAAAAklEQVR4AewaftIAAATiSURBVO3BQY4cSRIEQdNA/f/Lujz6KYBEenWTsyaCf6RqyUnVopOqRSdVi06qFp1ULTqpWnRSteikatFJ1aKTqkUnVYtOqhadVC06qVp0UrXok5eA/CQ1E5AbNROQSc0E5Ak1E5A31ExAfpKaN06qFp1ULTqpWvTJMjWbgGxS84SaGyA3am6APKFmE5BNJ1WLTqoWnVQt+uTLgDyh5gk1E5AbIDdq3lAzAZnUbALyhJpvOqladFK16KRq0Sf/OCDfBORGzQRkUjMBmdT8l5xULTqpWnRSteiTf5yaCcgTap5QMwGZ1DwBZFLzLzupWnRSteikatEnX6bmNwF5AsikZgJyA+QnqfmbnFQtOqladFK16JNlQH4SkEnNBGRSMwGZ1ExAJjUTkEnNBGRSMwF5Asjf7KRq0UnVopOqRfhH/mFANqm5AfKEmv8nJ1WLTqoWnVQt+uQlIJOaCciNmgnIE2pugExqboBMat4AcqPmBsik5gbIpGYCcqPmjZOqRSdVi06qFuEf+YcA+ZuoeQLIN6l5Asik5o2TqkUnVYtOqhZ98mVAnlAzAZnU3ACZ1ExAnlBzA2RSMwGZ1ExAnlDzBJAbNZtOqhadVC06qVr0yUtAJjU3aiYgN2omIDdqJiCTmjeATGpu1ExAbtQ8AWRSM6m5ATKpeeOkatFJ1aKTqkWffJmaCcikZgKySc0NkEnNBGRScwNkUnOjZgIyqblRMwG5UTOp2XRSteikatFJ1SL8I4uA3Kh5A8gTat4A8oaaCcik5gbIpOYJIE+oeeOkatFJ1aKTqkWffJmaGyCTmgnIjZoJyA2QSc0EZFLzk4BMaiYgN2p+00nVopOqRSdViz75ZWpu1ExAbtRMQJ5QMwF5Qs2NmieAvKFmAjKp2XRSteikatFJ1aJPXgJyA+QJNROQbwIyqXlCzQ2QSc0TaiYgN0AmNT/ppGrRSdWik6pFn7yk5g0gE5BJzQTkCTUTkG8CMqm5ATKpeULNBGQC8pNOqhadVC06qVr0yUtAJjU3QCY1E5AJyA2QSc0bQJ4AMqn5TWomIJOabzqpWnRSteikahH+kV8E5EbNE0AmNU8AuVEzAblR8wSQSc0NkEnNBGRS800nVYtOqhadVC36ZBmQGzU3aiYgN2omNTdAJjXfBGRSMwG5AfIEkN90UrXopGrRSdWiT5apeULNjZobIJOaCcikZgIyqflNap4A8gSQGzVvnFQtOqladFK16JOXgPwkNW8AmdTcAJnUTGomIJOaCcgTQCY1T6iZgExqNp1ULTqpWnRSteiTZWo2AXlDzRNA3lAzAZnUTEBu1GxS800nVYtOqhadVC365MuAPKHmCTUTkBs1N2pugExqJiCTmieAvKFmAnKjZtNJ1aKTqkUnVYs++ccBmdRMQCYgk5oJyKTmBsgTQJ5QMwG5ATKpuQEyqXnjpGrRSdWik6pFn/zHqXlCzY2aJ4DcqJmAPKHmBsik5ptOqhadVC06qVr0yZep+SY1E5An1LwBZFJzo2YCcgNkUjMBuVEzAZnUbDqpWnRSteikatEny4D8JCCTmhsgE5BJzQTkRs2NmgnIjZo31Pymk6pFJ1WLTqoW4R+pWnJSteikatFJ1aKTqkUnVYtOqhadVC06qVp0UrXopGrRSdWik6pFJ1WLTqoWnVQt+h8AsUc0QEvSvQAAAABJRU5ErkJggg=="
6
+ export default definePlugin((ctx) => {
7
+ ctx.accounts.register('demo', {
8
+ async login({ auth }) {
9
+ let polls = 0
10
+ return auth.qrcode({
11
+ image: demoImage,
12
+ view: loginView,
13
+ expiresInMs: 120000,
14
+ async poll(operation) {
15
+ operation.signal.throwIfAborted()
16
+ // 本地演示:约 5 秒后“已扫码”,约 10 秒后完成。请替换成平台 API。
17
+ polls++
18
+ if (polls >= 11) return { status: 'done', credential: 'synthetic-demo-only' }
19
+ return { status: polls >= 6 ? 'scanned' : 'waiting' }
20
+ },
21
+ })
22
+ },
23
+ profile: () => ({ id: 'demo', displayName: '扫码演示用户' }),
24
+ })
25
+ })
@@ -0,0 +1,23 @@
1
+ import { defineSurface, type AccountQrViewState } from '@shiqianjiang/ceru-plugin-sdk'
2
+
3
+ // 没有 Vue 或 UI 组件依赖;只控制弹窗内部内容,外壳、标题与关闭按钮属于软件。
4
+ export default defineSurface((ctx) => {
5
+ ctx.root.innerHTML = `<style>
6
+ .custom-login { font: 14px/1.6 system-ui; color: var(--td-text-color-primary); padding: 8px; display: grid; gap: 16px; justify-items: center; }
7
+ .custom-login h2 { color: var(--td-brand-color); margin: 0; font-size: 20px; }
8
+ .custom-login p { margin: 0; color: var(--td-text-color-secondary); }
9
+ .custom-login img { display: block; width: 208px; height: 208px; padding: 16px; background: white; border-radius: 16px; }
10
+ .custom-login button { width: 100%; padding: 9px; color: inherit; background: var(--td-bg-color-container); border: 1px solid var(--td-component-border); border-radius: 6px; cursor: pointer; }
11
+ .custom-login button:hover { background: var(--td-bg-color-container-hover); }
12
+ </style><section class="custom-login"><h2>DEMO · 自定义 HTML</h2><p>本地演示,无需扫描</p><img alt="演示登录二维码"><p role="status" aria-live="polite"></p><button type="button">取消登录</button></section>`
13
+ const image = ctx.root.querySelector<HTMLImageElement>('img')!
14
+ const status = ctx.root.querySelector('[role="status"]')!
15
+ const cancel = () => { void ctx.close() }
16
+ ctx.root.querySelector('button')!.addEventListener('click', cancel)
17
+ const unsubscribe = ctx.subscribe(state => {
18
+ const login = state.login as AccountQrViewState | undefined
19
+ if (login?.image) image.src = login.image
20
+ status.textContent = login?.status === 'scanned' ? '已扫码,请在手机确认' : '等待扫码'
21
+ })
22
+ return () => { unsubscribe(); ctx.root.replaceChildren() }
23
+ })
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "skipLibCheck": true,
9
+ "allowJs": true,
10
+ "checkJs": false,
11
+ "lib": ["ES2022", "DOM"],
12
+ "types": [],
13
+ "jsx": "preserve",
14
+ "jsxImportSource": "vue"
15
+ },
16
+ "include": ["src", ".ceru-dev/types/**/*.d.ts"]
17
+ }