├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmrc
├── .prettierrc.js
├── .stylelintignore
├── .stylelintrc.js
├── .vscode
└── settings.json
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── bin
└── weconsole
├── build
├── build.js
├── fs.js
├── full.js
├── mini-wxml.js
├── mini.js
├── npm.js
├── sass.js
└── watch.js
├── docs
└── img
│ ├── ad.png
│ ├── ad.psd
│ ├── api-actions.jpg
│ ├── api-detail.jpg
│ ├── api.jpg
│ ├── component-detail.jpg
│ ├── component.jpg
│ ├── console-actions.jpg
│ ├── console.jpg
│ ├── other-demos.jpg
│ ├── other.jpg
│ ├── storage-detail.jpg
│ ├── storage.jpg
│ ├── wcapi.gif
│ └── weconsole logo.png
├── examples
├── my
│ ├── full
│ │ ├── .mini-ide
│ │ │ └── project-ide.json
│ │ ├── app.acss
│ │ ├── app.js
│ │ ├── app.json
│ │ ├── demo
│ │ │ ├── index.acss
│ │ │ ├── index.axml
│ │ │ ├── index.js
│ │ │ └── index.json
│ │ ├── demo2
│ │ │ ├── index.acss
│ │ │ ├── index.axml
│ │ │ ├── index.js
│ │ │ └── index.json
│ │ ├── mini.project.json
│ │ └── pages
│ │ │ └── index
│ │ │ ├── console.jpg
│ │ │ ├── index.acss
│ │ │ ├── index.axml
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── network.jpg
│ │ │ └── storage.jpg
│ └── npm
│ │ ├── .mini-ide
│ │ └── project-ide.json
│ │ ├── app.acss
│ │ ├── app.js
│ │ ├── app.json
│ │ ├── demo
│ │ ├── index.acss
│ │ ├── index.axml
│ │ ├── index.js
│ │ └── index.json
│ │ ├── mini.project.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── pages
│ │ └── index
│ │ ├── console.jpg
│ │ ├── index.acss
│ │ ├── index.axml
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── network.jpg
│ │ └── storage.jpg
├── swan
│ └── full
│ │ ├── .swan
│ │ └── editor.json
│ │ ├── app.css
│ │ ├── app.js
│ │ ├── app.json
│ │ ├── demo
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.swan
│ │ └── tpl.swan
│ │ ├── demo2
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── index.json
│ │ └── index.swan
│ │ ├── pages
│ │ └── index
│ │ │ ├── index.css
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ └── index.swan
│ │ ├── pkginfo.json
│ │ └── project.swan.json
├── wx
│ └── full
│ │ ├── app.js
│ │ ├── app.json
│ │ ├── app.wxss
│ │ ├── demo
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ │ ├── demo2
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.wxml
│ │ └── index.wxss
│ │ ├── pages
│ │ └── index
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.wxml
│ │ │ └── index.wxss
│ │ ├── project.config.json
│ │ ├── project.private.config.json
│ │ └── sitemap.json
└── xhs
│ └── full
│ ├── app.css
│ ├── app.js
│ ├── app.json
│ ├── demo
│ ├── index.css
│ ├── index.js
│ ├── index.json
│ └── index.xhsml
│ ├── demo2
│ ├── index.css
│ ├── index.js
│ ├── index.json
│ ├── index.xhsml
│ └── tpl.xhsml
│ ├── pages
│ └── index
│ │ ├── console.jpg
│ │ ├── el.jpg
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── index.json
│ │ ├── index.xhsml
│ │ ├── net.jpg
│ │ └── xhs.jpg
│ ├── project.config.json
│ ├── sitemap.json
│ └── xhs-sumi
│ └── settings.json
├── package.json
├── pnpm-lock.yaml
├── scripts
├── _copy.ts
├── bin.ts
├── build.ts
├── cli.ts
├── fs.ts
├── inject.ts
├── mp.ts
├── other.ts
├── sass.ts
├── translator
│ ├── ali.ts
│ ├── parse.ts
│ ├── swan.ts
│ └── xhs.ts
├── tsconfig.json
└── vars.ts
├── src
├── main
│ ├── config.ts
│ ├── global.d.ts
│ ├── index.ts
│ ├── init.ts
│ └── modules
│ │ ├── category.ts
│ │ ├── controller.ts
│ │ ├── ebus.ts
│ │ ├── event-emitter.ts
│ │ ├── hooker.ts
│ │ ├── hooks.ts
│ │ ├── reader-state.ts
│ │ ├── state-controller.ts
│ │ ├── util.ts
│ │ └── view-store.ts
├── subpackage
│ ├── components
│ │ ├── api-detail
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── api-reader
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── collapse
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── component-reader
│ │ │ ├── element.json
│ │ │ ├── element.scss
│ │ │ ├── element.ts
│ │ │ ├── element.wxml
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── console-reader-item
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── console-reader
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── custom-action
│ │ │ ├── buttons.wxml
│ │ │ ├── content.json
│ │ │ ├── content.wxml
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── data-table
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── filter-bar
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── json-viewer
│ │ │ ├── chunk-left.wxml
│ │ │ ├── chunk-right.wxml
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ ├── index.wxml
│ │ │ ├── node.json
│ │ │ ├── node.scss
│ │ │ ├── node.ts
│ │ │ └── node.wxml
│ │ ├── main
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── movable
│ │ │ ├── index.json
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── storage-reader
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── style
│ │ │ ├── detail.scss
│ │ │ ├── headers.scss
│ │ │ ├── icon.scss
│ │ │ ├── reader.scss
│ │ │ ├── status.scss
│ │ │ ├── table.scss
│ │ │ └── var.scss
│ │ ├── table-cell
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── table-row
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ ├── tabs
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ │ └── vl-item
│ │ │ ├── index.json
│ │ │ ├── index.scss
│ │ │ ├── index.ts
│ │ │ └── index.wxml
│ ├── mixins
│ │ ├── ali.ts
│ │ ├── component.ts
│ │ ├── dr.ts
│ │ ├── no-wx.ts
│ │ ├── tool.ts
│ │ └── vl.ts
│ └── modules
│ │ ├── category.ts
│ │ ├── cookie.ts
│ │ ├── cross.ts
│ │ ├── custom-action.ts
│ │ ├── detail.ts
│ │ ├── element.ts
│ │ ├── json-viewer.ts
│ │ ├── json.ts
│ │ ├── reader.ts
│ │ ├── rect.ts
│ │ ├── storage-reader.ts
│ │ └── util.ts
└── types
│ ├── api-reader.ts
│ ├── common.ts
│ ├── config.ts
│ ├── console-reader.ts
│ ├── element.ts
│ ├── hook.ts
│ ├── json-viewer.ts
│ ├── json.ts
│ ├── other.ts
│ ├── product.ts
│ ├── reader-state.ts
│ ├── reader.ts
│ ├── scope.ts
│ ├── table.ts
│ ├── util.ts
│ └── view.ts
├── tsconfig-base.json
├── tsconfig-eslint.json
└── tsconfig.json
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | scripts-dist
3 | examples/**/weconsole
4 | vl-temp
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['standard', 'alloy', 'alloy/typescript'],
4 | parserOptions: {
5 | project: './tsconfig-eslint.json'
6 | },
7 | globals: {
8 | global: 'readonly',
9 | wx: 'writable',
10 | getApp: 'writable',
11 | getCurrentPages: 'writable',
12 | Page: 'writable',
13 | App: 'writable',
14 | Component: 'writable'
15 | },
16 | rules: {
17 | indent: ['error', 4],
18 | quotes: ['error', 'single'],
19 | semi: 0,
20 | radix: ['error', 'as-needed'],
21 | 'func-name-matching': [0, 'always'],
22 | 'no-param-reassign': [0],
23 | 'max-params': ['error', 6],
24 | 'space-before-function-paren': ['warn', 'never'],
25 | 'max-nested-callbacks': ['error', 5]
26 | },
27 | overrides: [
28 | {
29 | extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
30 | files: ['./**/*.{ts,tsx,vue}']
31 | },
32 | {
33 | extends: ['plugin:@typescript-eslint/disable-type-checked'],
34 | files: ['./**/*.js']
35 | },
36 | {
37 | files: ['**/*.{ts,tsx,vue}'],
38 | rules: {
39 | 'no-unused-vars': 'off',
40 | '@typescript-eslint/no-unused-vars': ['error'],
41 | '@typescript-eslint/no-unsafe-assignment': 'off',
42 | '@typescript-eslint/unbound-method': 'off',
43 | '@typescript-eslint/no-unsafe-return': 'off',
44 | '@typescript-eslint/no-unsafe-argument': 'off',
45 | '@typescript-eslint/no-unsafe-call': 'off',
46 | '@typescript-eslint/no-unsafe-member-access': 'off',
47 | '@typescript-eslint/no-floating-promises': 'off',
48 | '@typescript-eslint/no-explicit-any': 'off',
49 | '@typescript-eslint/explicit-member-accessibility': 'off'
50 | }
51 | },
52 | {
53 | files: ['**/*.ts'],
54 | rules: {
55 | 'no-unused-vars': 'off',
56 | '@typescript-eslint/no-unused-vars': ['error'],
57 | '@typescript-eslint/explicit-member-accessibility': 'off'
58 | }
59 | },
60 | {
61 | files: ['**/*.js'],
62 | rules: {
63 | '@typescript-eslint/no-require-imports': 'off'
64 | }
65 | }
66 | ]
67 | };
68 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
106 |
107 | .DS_Store
108 |
109 | scripts-dist
110 | examples/**/weconsole
111 | vl-temp
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | # registry=https://registry.npmjs.org/
2 | auto-install-peers=true
3 | strict-peer-dependencies=false
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // 一行最多 120 字符
3 | printWidth: 120,
4 | // 使用 4 个空格缩进
5 | tabWidth: 4,
6 | // 不使用缩进符,而使用空格
7 | useTabs: false,
8 | // 行尾需要有分号
9 | semi: true,
10 | // 使用单引号
11 | singleQuote: true,
12 | // 对象的 key 仅在必要时用引号
13 | quoteProps: 'as-needed',
14 | trailingComma: 'none'
15 | };
16 |
--------------------------------------------------------------------------------
/.stylelintignore:
--------------------------------------------------------------------------------
1 | dist
2 | scripts-dist
--------------------------------------------------------------------------------
/.stylelintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['stylelint-config-standard', 'stylelint-config-recess-order'],
3 | rules: {
4 | 'at-rule-no-unknown': [
5 | true,
6 | {
7 | ignoreAtRules: ['mixin', 'extend', 'content', 'include']
8 | }
9 | ],
10 | indentation: 4,
11 | 'unit-no-unknown': [
12 | true,
13 | {
14 | ignoreUnits: ['rpx']
15 | }
16 | ],
17 | 'no-descending-specificity': null
18 | }
19 | };
20 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "node_modules/typescript/lib",
3 | "editor.formatOnSave": true,
4 | "eslint.validate": ["javascript", "typescript"],
5 | "files.associations": {
6 | "*.wxss": "css",
7 | "*.wxs": "javascript",
8 | "*.wxml": "html"
9 | },
10 | "editor.codeActionsOnSave": {
11 | "source.fixAll.eslint": "explicit",
12 | "source.fixAll.stylelint": "explicit"
13 | },
14 | "[html]": {
15 | "editor.formatOnSave": false,
16 | "editor.defaultFormatter": "vscode.html-language-features"
17 | },
18 | "[javascript]": {
19 | "editor.defaultFormatter": "esbenp.prettier-vscode"
20 | },
21 | "[typescript]": {
22 | "editor.defaultFormatter": "esbenp.prettier-vscode"
23 | },
24 | "[css]": {
25 | "editor.defaultFormatter": "esbenp.prettier-vscode"
26 | },
27 | "[scss]": {
28 | "editor.defaultFormatter": "esbenp.prettier-vscode"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # WeConsole 贡献指南
2 |
3 | 我们非常欢迎社区的开发者向 WeConsole 做出贡献。在提交贡献之前,请花一些时间阅读以下内容,保证贡献是符合规范并且能帮助到社区。
4 |
5 | ## 提交 commit
6 |
7 | 整个 WeConsole 仓库遵从 [Angular Style Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153),在输入 commit message 的时候请务必遵从此规范。
8 |
9 | ## 代码风格
10 |
11 | - `JavaScript`:JavaScript 风格遵从 [JavaScript Standard Style](https://github.com/standard/standard)。
12 | - `TypeScript`:TypeScript 风格也是 [JavaScript Standard Style](https://github.com/standard/standard) 的变种,详情请看相关包目录下的 `.eslintrc.js` 和 `tsconfig.json`。
13 | - 样式:遵循相关包目录下的 `.stylelintrc` 风格。
14 |
15 | ## Pull Request 指南
16 |
17 | 1. 务必保证 `npm run build` 能够编译成功;
18 | 2. 务必保证提交的代码遵循相关包中的 `.eslintrc`, `.stylelintrc` 所规定的规范;
19 | 3. 当相关包的 `package.json` 含有 `npm test` 命令时,必须保证所有测试用例都需要通过;
20 | 4. 当相关包有测试用例时,请给你提交的代码也添加相应的测试用例;
21 | 5. 提交代码 commit 时,commit 信息需要遵循 [Angular Style Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153)。
22 | 6. 如果提交的代码非常多或功能复杂,可以把 PR 分成几个 commit 一起提交。我们在合并时会根据情况 squash。
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 weimob
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bin/weconsole:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env node
2 |
3 | require('../scripts-dist/bin');
4 |
--------------------------------------------------------------------------------
/build/full.js:
--------------------------------------------------------------------------------
1 | const { buildFull } = require('./build');
2 | const path = require('path');
3 |
4 | const targetDir = path.resolve(__dirname, '../dist/full');
5 | console.log('开始编译');
6 | buildFull(targetDir)
7 | .then(() => {
8 | console.log('编译成功');
9 | })
10 | .catch((err) => {
11 | console.log(`编译失败:${err.message}`);
12 | console.error(err);
13 | });
14 |
--------------------------------------------------------------------------------
/build/mini-wxml.js:
--------------------------------------------------------------------------------
1 | const { parseMpXml, serialize } = require('@mpkit/mpxml-parser');
2 | const { uuid } = require('@mpkit/util');
3 |
4 | exports.minify = (wxmlCode) => {
5 | const parseResult = parseMpXml(wxmlCode);
6 | if (parseResult.nodes) {
7 | const ids = [];
8 | let res = serialize(parseResult.nodes, {
9 | // eslint-disable-next-line max-params
10 | nodeSerializeHandler(node, siblingNodes, rootNodes, rootSerialer, parent, adapter, content) {
11 | if (node.type === 'text') {
12 | if (!node.content.trim()) {
13 | ids.push(uuid());
14 | return ``;
15 | }
16 | return node.content.trim();
17 | }
18 | if (node.type === 'comment') {
19 | ids.push(uuid());
20 | return ``;
21 | }
22 | return content;
23 | }
24 | });
25 | ids.forEach((item) => {
26 | res = res.replace(new RegExp(``), '');
27 | });
28 | return res;
29 | }
30 | return wxmlCode;
31 | };
32 |
33 | exports.minify(`
34 |
35 | {{'<'}}
36 | {{data.name}}
37 |
38 |
39 | {{item.name}}
40 |
41 | =
42 | {{'"'}}
43 | {{item.content}}
44 | {{'"'}}
45 |
46 |
47 |
48 |
49 |
50 | {{'>'}}
51 | {{'…'}}
52 | {{''}}
53 | {{data.name}}
54 | {{'>'}}
55 |
56 | {{' />'}}
57 |
58 | {{'>'}}
59 |
60 |
61 |
62 |
63 |
64 |
69 |
70 | `);
71 |
--------------------------------------------------------------------------------
/build/mini.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { rmDir, replaceDir, whereRemove, eachFile, readFile, writeFile, removeFile } = require('./fs');
3 | const terser = require('terser');
4 | const cssnano = require('cssnano');
5 | const postcss = require('postcss');
6 | const WxmlHelper = require('./mini-wxml.js');
7 | const minifyJS = terser.minify;
8 |
9 | const distDir = path.resolve(__dirname, '../dist');
10 | const fullDir = path.join(distDir, 'full');
11 | const fullMiniDir = path.join(distDir, 'full-mini');
12 | const npmDir = path.join(distDir, 'npm');
13 | const npmMiniDir = path.join(distDir, 'npm-mini');
14 |
15 | rmDir(fullMiniDir);
16 | rmDir(npmMiniDir);
17 |
18 | // 复制到mini目录
19 | replaceDir(fullDir, fullMiniDir);
20 | replaceDir(npmDir, npmMiniDir);
21 |
22 | // 删除types文件夹
23 | rmDir(path.join(fullMiniDir, 'types'));
24 | removeFile(path.join(fullMiniDir, 'mpkit') + '/types.js');
25 | rmDir(path.join(npmMiniDir, 'types'));
26 |
27 | // 删除所有*.d.ts
28 | const removeDTS = (filename) => filename.endsWith('.d.ts');
29 | whereRemove(fullMiniDir, removeDTS);
30 | whereRemove(npmMiniDir, removeDTS);
31 |
32 | // 压缩js/json/wxml/wxss
33 | const miniFile = async(filePath, isFile, fileName) => {
34 | if (isFile) {
35 | const code = readFile(filePath);
36 | if (fileName.endsWith('.js') || fileName.endsWith('.wxs')) {
37 | const res = await minifyJS(code, {
38 | sourceMap: false
39 | });
40 | writeFile(filePath, res.code);
41 | // writeFile(filePath + '.map', res.map.replace(`"sources":["0"]`,`"sources":["${fileName}"]`));
42 | return;
43 | }
44 | if (fileName.endsWith('.json')) {
45 | writeFile(filePath, JSON.stringify(JSON.parse(code)));
46 | return;
47 | }
48 | if (fileName.endsWith('.wxml')) {
49 | writeFile(filePath, WxmlHelper.minify(code));
50 | return;
51 | }
52 | if (fileName.endsWith('.wxss')) {
53 | postcss([cssnano])
54 | .process(code)
55 | .then((res) => {
56 | writeFile(filePath, res.css);
57 | });
58 | }
59 | }
60 | };
61 | eachFile(fullMiniDir, miniFile);
62 | eachFile(npmMiniDir, miniFile);
63 |
--------------------------------------------------------------------------------
/build/npm.js:
--------------------------------------------------------------------------------
1 | const { buildNpmComponents } = require('./build');
2 | const path = require('path');
3 |
4 | const targetDir = path.resolve(__dirname, '../dist/npm');
5 | console.log('开始编译');
6 | buildNpmComponents(path.join(targetDir, 'components'))
7 | .then(() => {
8 | console.log('编译成功');
9 | })
10 | .catch((err) => {
11 | console.log(`编译失败:${err.message}`);
12 | console.error(err);
13 | });
14 |
--------------------------------------------------------------------------------
/build/sass.js:
--------------------------------------------------------------------------------
1 | const sass = require('node-sass');
2 | const autoprefixer = require('autoprefixer');
3 | const postcss = require('postcss');
4 | // TODO:处理style文件夹中的公共样式,不应该以scss导入,而是以wxss的导入
5 | module.exports = (filePath) => {
6 | return new Promise((resolve, reject) => {
7 | const res = !filePath
8 | ? ''
9 | : sass.renderSync({
10 | file: filePath,
11 | outputStyle: 'expanded'
12 | }).css;
13 | if (res) {
14 | postcss([autoprefixer]).process(res).then(result => {
15 | resolve(result.css)
16 | }).catch(err => {
17 | reject(err)
18 | })
19 | } else {
20 | resolve(res)
21 | }
22 | })
23 | }
24 |
--------------------------------------------------------------------------------
/build/watch.js:
--------------------------------------------------------------------------------
1 | const watch = require('watch');
2 | const { buildFull } = require('./build');
3 | const path = require('path');
4 |
5 | let hasNew;
6 | let timer;
7 | let running;
8 | const build = () => {
9 | if (running) {
10 | return;
11 | }
12 | running = true;
13 | const targetDir = path.resolve(__dirname, '../dist/full');
14 | console.log('开始编译');
15 | buildFull(targetDir)
16 | .then(() => {
17 | console.log('编译成功');
18 | running = false;
19 | if (hasNew) {
20 | hasNew = false;
21 | build();
22 | }
23 | })
24 | .catch((err) => {
25 | console.log(`编译失败:${err.message}`);
26 | console.error(err);
27 | running = false;
28 | if (hasNew) {
29 | hasNew = false;
30 | build();
31 | }
32 | });
33 | };
34 |
35 | build();
36 |
37 | watch.watchTree(path.resolve(__dirname, '../src'), (f, curr, prev) => {
38 | // eslint-disable-next-line no-empty
39 | if (typeof f === 'object' && prev === null && curr === null) {
40 | } else {
41 | hasNew = true;
42 | if (timer) {
43 | clearTimeout(timer);
44 | }
45 | timer = setTimeout(() => {
46 | build();
47 | }, 500);
48 | }
49 | });
50 |
--------------------------------------------------------------------------------
/docs/img/ad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/ad.png
--------------------------------------------------------------------------------
/docs/img/ad.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/ad.psd
--------------------------------------------------------------------------------
/docs/img/api-actions.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/api-actions.jpg
--------------------------------------------------------------------------------
/docs/img/api-detail.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/api-detail.jpg
--------------------------------------------------------------------------------
/docs/img/api.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/api.jpg
--------------------------------------------------------------------------------
/docs/img/component-detail.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/component-detail.jpg
--------------------------------------------------------------------------------
/docs/img/component.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/component.jpg
--------------------------------------------------------------------------------
/docs/img/console-actions.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/console-actions.jpg
--------------------------------------------------------------------------------
/docs/img/console.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/console.jpg
--------------------------------------------------------------------------------
/docs/img/other-demos.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/other-demos.jpg
--------------------------------------------------------------------------------
/docs/img/other.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/other.jpg
--------------------------------------------------------------------------------
/docs/img/storage-detail.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/storage-detail.jpg
--------------------------------------------------------------------------------
/docs/img/storage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/storage.jpg
--------------------------------------------------------------------------------
/docs/img/wcapi.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/wcapi.gif
--------------------------------------------------------------------------------
/docs/img/weconsole logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/docs/img/weconsole logo.png
--------------------------------------------------------------------------------
/examples/my/full/.mini-ide/project-ide.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignoreHttpDomainCheck": true,
3 | "ignoreWebViewDomainCheck": true,
4 | "ignoreCertificateDomainCheck": true
5 | }
--------------------------------------------------------------------------------
/examples/my/full/app.acss:
--------------------------------------------------------------------------------
1 | page {
2 | background: #f7f7f7;
3 | }
4 |
--------------------------------------------------------------------------------
/examples/my/full/app.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable indent */
2 | const { replace, showWeConsole, addCustomAction } = require('./weconsole/main/index');
3 |
4 | replace();
5 | showWeConsole();
6 |
7 | addCustomAction({
8 | id: 'customTableDemo',
9 | title: '自定义表格示例',
10 | cases: [
11 | {
12 | id: 'showList',
13 | button: '查看数据',
14 | showMode: 'grid',
15 | handler() {
16 | return {
17 | cols: [
18 | {
19 | title: '序号',
20 | field: 'id',
21 | width: '10'
22 | },
23 | {
24 | title: '页面',
25 | field: 'page',
26 | width: '40'
27 | },
28 | {
29 | title: '门店',
30 | field: 'vid',
31 | width: '50'
32 | }
33 | ],
34 | data: Array.from({ length: 100 }).map((i, index) => {
35 | return {
36 | id: String(index),
37 | page: `/pages/p${index}`,
38 | vid:
39 | index % 2 === 0
40 | ? '门店信息:\n测试门店' + (index + 1)
41 | : {
42 | tableCell: true,
43 | blocks: [
44 | {
45 | block: true,
46 | items: [
47 | '门店信息',
48 | {
49 | type: 'text',
50 | content: '='
51 | },
52 | {
53 | type: 'json',
54 | value: {
55 | id: index,
56 | type: 3,
57 | name: `测试门店${index + 1}`
58 | }
59 | }
60 | ]
61 | }
62 | ]
63 | }
64 | };
65 | })
66 | };
67 | }
68 | }
69 | ]
70 | });
71 |
72 | App({
73 | data1: global,
74 | data2: { name: 'weconsole' }
75 | });
76 |
77 | console.log('console.log 来啦');
78 | console.error('console.error 来啦');
79 | console.info('console.info 来啦');
80 | console.warn('console.warn 来啦');
81 |
82 | console.log(
83 | '数字',
84 | 123,
85 | '布尔',
86 | true,
87 | '字符串',
88 | '函数',
89 | () => {
90 | console.log('123');
91 | },
92 | '类',
93 | class Box {
94 | show() {
95 | console.log('123');
96 | }
97 | }
98 | );
99 |
--------------------------------------------------------------------------------
/examples/my/full/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": ["pages/index/index"],
3 | "window": {
4 | "defaultTitle": "WeConsole示例"
5 | },
6 | "behavior": {
7 | "requestReferrerStrategy": "page",
8 | "requestReferrerStyle": "full",
9 | "requestDefaultEnableCookie": true,
10 | "connectSocketDefaultMultiple": true
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/examples/my/full/demo/index.acss:
--------------------------------------------------------------------------------
1 | .action-list {
2 | display: flex;
3 | flex-wrap: wrap;
4 | justify-content: space-between;
5 | }
6 |
7 | .action {
8 | position: relative;
9 | box-sizing: border-box;
10 | width: 48%;
11 | padding: 40rpx 30rpx;
12 | margin-bottom: 30rpx;
13 | line-height: 1.8;
14 | text-align: center;
15 | border-radius: 10rpx;
16 | box-shadow: rgb(255 255 255) 0 0 0 0, rgb(0 0 0 / 5%) 0 0 0 1px, rgb(0 0 0 / 10%) 0 10px 15px -3px,
17 | rgb(0 0 0 / 10%) 0 4px 6px -4px;
18 | }
19 |
20 | .lock {
21 | opacity: 0.5;
22 | }
23 |
24 | .action text {
25 | color: red;
26 | }
27 |
--------------------------------------------------------------------------------
/examples/my/full/demo/index.axml:
--------------------------------------------------------------------------------
1 |
2 | 随机console
3 | my.showToast
4 | my.setStorageSync
5 | my.getStorage
6 | my.removeStorage
7 | my.request{{requesting?'(发送中...)':''}}
8 |
9 |
--------------------------------------------------------------------------------
/examples/my/full/demo/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "demo2": "../demo2/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/my/full/demo2/index.acss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/full/demo2/index.acss
--------------------------------------------------------------------------------
/examples/my/full/demo2/index.axml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/examples/my/full/demo2/index.js:
--------------------------------------------------------------------------------
1 | Component({
2 | options: {
3 | lifetimes: true
4 | },
5 | data: {
6 | message: 'hi demo2'
7 | }
8 | });
9 |
--------------------------------------------------------------------------------
/examples/my/full/demo2/index.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/examples/my/full/mini.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": 2,
3 | "compileOptions": {
4 | "component2": true,
5 | "globalObjectMode": "enable",
6 | "transpile": {
7 | "script": {
8 | "ignore": [
9 | "node_modules/**"
10 | ]
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/my/full/pages/index/console.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/full/pages/index/console.jpg
--------------------------------------------------------------------------------
/examples/my/full/pages/index/index.acss:
--------------------------------------------------------------------------------
1 | /* stylelint-disable declaration-block-no-redundant-longhand-properties */
2 | /* stylelint-disable order/properties-order */
3 | /* stylelint-disable-next-line selector-type-no-unknown */
4 | page {
5 | box-sizing: border-box;
6 | padding: 30rpx;
7 | font-size: 28rpx;
8 | }
9 |
10 | .alert-warn,
11 | .alert-success {
12 | padding: 20rpx 30rpx;
13 | margin-top: 30rpx;
14 | margin-bottom: 30rpx;
15 | font-size: 24rpx;
16 | border-style: solid;
17 | border-width: 1px;
18 | }
19 |
20 | .alert-success {
21 | color: #3c763d;
22 | background-color: #dff0d8;
23 | border-color: #d6e9c6;
24 | }
25 |
26 | .alert-success text {
27 | font-size: 140%;
28 | font-weight: bold;
29 | color: #1b9af7;
30 | }
31 |
32 | .alert-warn {
33 | color: #8a6d3b;
34 | background-color: #fcf8e3;
35 | border-color: #faebcc;
36 | }
37 |
38 | .alert-warn view {
39 | margin-bottom: 30rpx;
40 | }
41 |
42 | .alert-warn text {
43 | color: blue;
44 | text-decoration: underline;
45 | }
46 |
47 | .box {
48 | height: 30rpx;
49 | padding: 5rpx 15rpx 5rpx 50rpx;
50 | background-color: red;
51 | }
52 |
53 | button {
54 | font-size: 24rpx;
55 | }
56 |
57 | .pk-modal {
58 | position: fixed;
59 | top: 30%;
60 | left: 0;
61 | right: 0;
62 | bottom: 0;
63 | z-index: 1200;
64 | display: flex;
65 | flex-direction: column;
66 | background-color: rgb(0 0 0 / 40%);
67 | box-shadow: 0 -10rpx 10rpx rgb(0 0 0 / 40%);
68 | }
69 |
70 | .btn-close {
71 | flex-shrink: 0;
72 | height: 80rpx;
73 | line-height: 80rpx;
74 | }
75 |
76 | .pk-content {
77 | flex-basis: 75%;
78 | flex-shrink: 1;
79 | }
80 |
81 | .pk-modal .alert-warn {
82 | margin: 0;
83 | }
84 |
85 | swiper,
86 | swiper-item,
87 | image {
88 | height: 100%;
89 | }
90 |
91 | image {
92 | display: block;
93 | margin: 0 auto;
94 | }
95 |
--------------------------------------------------------------------------------
/examples/my/full/pages/index/index.axml:
--------------------------------------------------------------------------------
1 |
2 | 真机调试小程序,就用 WeConsole !
3 | 高效、便捷、免代理抓包请求。
4 | 点击屏幕右侧的【蓝色图标】开启调试之旅~
5 |
6 |
7 |
8 | 版本:v{{version}}
9 |
10 | Github: https://github.com/weimob-tech/WeConsole
12 |
13 |
14 | NPM: https://www.npmjs.com/package/WeConsole
16 |
17 |
18 |
19 |
20 |
21 |
22 | 支付宝无法通过API方式开启调试,请参考截图(可左右滑动)
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/my/full/pages/index/index.js:
--------------------------------------------------------------------------------
1 | const { version } = require('../../weconsole/main/index');
2 | Page({
3 | data: {
4 | version,
5 | message: 'hi WeConsole',
6 | pkShow: false
7 | },
8 | copy(e) {
9 | wx.setClipboardData({
10 | data: e.currentTarget.dataset.url
11 | });
12 | },
13 | pk() {
14 | this.setData({
15 | pkShow: true
16 | });
17 | },
18 | closePk() {
19 | this.setData({
20 | pkShow: false
21 | });
22 | }
23 | });
24 |
--------------------------------------------------------------------------------
/examples/my/full/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 | "demo": "../../demo/index",
4 | "weconsole": "../../weconsole/subpackage/components/main/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/my/full/pages/index/network.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/full/pages/index/network.jpg
--------------------------------------------------------------------------------
/examples/my/full/pages/index/storage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/full/pages/index/storage.jpg
--------------------------------------------------------------------------------
/examples/my/npm/.mini-ide/project-ide.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignoreHttpDomainCheck": true,
3 | "ignoreWebViewDomainCheck": true,
4 | "ignoreCertificateDomainCheck": true
5 | }
--------------------------------------------------------------------------------
/examples/my/npm/app.acss:
--------------------------------------------------------------------------------
1 | page {
2 | background: #f7f7f7;
3 | }
4 |
--------------------------------------------------------------------------------
/examples/my/npm/app.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable indent */
2 | const { replace, showWeConsole, addCustomAction } = require('./weconsole/main/index');
3 |
4 | replace();
5 | showWeConsole();
6 |
7 | addCustomAction({
8 | id: 'customTableDemo',
9 | title: '自定义表格示例',
10 | cases: [
11 | {
12 | id: 'showList',
13 | button: '查看数据',
14 | showMode: 'grid',
15 | handler() {
16 | return {
17 | cols: [
18 | {
19 | title: '序号',
20 | field: 'id',
21 | width: '10'
22 | },
23 | {
24 | title: '页面',
25 | field: 'page',
26 | width: '40'
27 | },
28 | {
29 | title: '门店',
30 | field: 'vid',
31 | width: '50'
32 | }
33 | ],
34 | data: Array.from({ length: 100 }).map((i, index) => {
35 | return {
36 | id: String(index),
37 | page: `/pages/p${index}`,
38 | vid:
39 | index % 2 === 0
40 | ? '门店信息:\n测试门店' + (index + 1)
41 | : {
42 | tableCell: true,
43 | blocks: [
44 | {
45 | block: true,
46 | items: [
47 | '门店信息:',
48 | {
49 | type: 'text',
50 | content: '='
51 | },
52 | {
53 | type: 'json',
54 | value: {
55 | id: index,
56 | type: 3,
57 | name: `测试门店${index + 1}`
58 | }
59 | }
60 | ]
61 | }
62 | ]
63 | }
64 | };
65 | })
66 | };
67 | }
68 | }
69 | ]
70 | });
71 |
72 | App({
73 | data1: global,
74 | data2: { name: 'weconsole' }
75 | });
76 |
77 | console.log('console.log 来啦');
78 | console.error('console.error 来啦');
79 | console.info('console.info 来啦');
80 | console.warn('console.warn 来啦');
81 |
--------------------------------------------------------------------------------
/examples/my/npm/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": ["pages/index/index"],
3 | "window": {
4 | "defaultTitle": "WeConsole示例"
5 | },
6 | "behavior": {
7 | "requestReferrerStrategy": "page",
8 | "requestReferrerStyle": "full",
9 | "requestDefaultEnableCookie": true,
10 | "connectSocketDefaultMultiple": true
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/examples/my/npm/demo/index.acss:
--------------------------------------------------------------------------------
1 | .action-list {
2 | display: flex;
3 | flex-wrap: wrap;
4 | justify-content: space-between;
5 | }
6 |
7 | .action {
8 | position: relative;
9 | box-sizing: border-box;
10 | width: 48%;
11 | padding: 40rpx 30rpx;
12 | margin-bottom: 30rpx;
13 | line-height: 1.8;
14 | text-align: center;
15 | border-radius: 10rpx;
16 | box-shadow: rgb(255 255 255) 0 0 0 0, rgb(0 0 0 / 5%) 0 0 0 1px, rgb(0 0 0 / 10%) 0 10px 15px -3px,
17 | rgb(0 0 0 / 10%) 0 4px 6px -4px;
18 | }
19 |
20 | .lock {
21 | opacity: 0.5;
22 | }
23 |
24 | .action text {
25 | color: red;
26 | }
27 |
--------------------------------------------------------------------------------
/examples/my/npm/demo/index.axml:
--------------------------------------------------------------------------------
1 |
2 | 随机console
3 | my.showToast
4 | my.setStorageSync
5 | my.getStorage
6 | my.removeStorage
7 | my.request{{requesting?'(发送中...)':''}}
8 |
--------------------------------------------------------------------------------
/examples/my/npm/demo/index.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/examples/my/npm/mini.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": 2,
3 | "compileOptions": {
4 | "component2": true,
5 | "globalObjectMode": "enable",
6 | "transpile": {
7 | "script": {
8 | "ignore": [
9 | "node_modules/**"
10 | ]
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/my/npm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "weconsole": "^1.3.0"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/console.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/npm/pages/index/console.jpg
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/index.acss:
--------------------------------------------------------------------------------
1 | /* stylelint-disable declaration-block-no-redundant-longhand-properties */
2 | /* stylelint-disable order/properties-order */
3 | /* stylelint-disable-next-line selector-type-no-unknown */
4 | page {
5 | box-sizing: border-box;
6 | padding: 30rpx;
7 | font-size: 28rpx;
8 | }
9 |
10 | .alert-warn,
11 | .alert-success {
12 | padding: 20rpx 30rpx;
13 | margin-top: 30rpx;
14 | margin-bottom: 30rpx;
15 | font-size: 24rpx;
16 | border-style: solid;
17 | border-width: 1px;
18 | }
19 |
20 | .alert-success {
21 | color: #3c763d;
22 | background-color: #dff0d8;
23 | border-color: #d6e9c6;
24 | }
25 |
26 | .alert-success text {
27 | font-size: 140%;
28 | font-weight: bold;
29 | color: #1b9af7;
30 | }
31 |
32 | .alert-warn {
33 | color: #8a6d3b;
34 | background-color: #fcf8e3;
35 | border-color: #faebcc;
36 | }
37 |
38 | .alert-warn view {
39 | margin-bottom: 30rpx;
40 | }
41 |
42 | .alert-warn text {
43 | color: blue;
44 | text-decoration: underline;
45 | }
46 |
47 | .box {
48 | height: 30rpx;
49 | padding: 5rpx 15rpx 5rpx 50rpx;
50 | background-color: red;
51 | }
52 |
53 | button {
54 | font-size: 24rpx;
55 | }
56 |
57 | .pk-modal {
58 | position: fixed;
59 | top: 30%;
60 | left: 0;
61 | right: 0;
62 | bottom: 0;
63 | z-index: 1200;
64 | display: flex;
65 | flex-direction: column;
66 | background-color: rgb(0 0 0 / 40%);
67 | box-shadow: 0 -10rpx 10rpx rgb(0 0 0 / 40%);
68 | }
69 |
70 | .btn-close {
71 | flex-shrink: 0;
72 | height: 80rpx;
73 | line-height: 80rpx;
74 | }
75 |
76 | .pk-content {
77 | flex-basis: 75%;
78 | flex-shrink: 1;
79 | }
80 |
81 | .pk-modal .alert-warn {
82 | margin: 0;
83 | }
84 |
85 | swiper,
86 | swiper-item,
87 | image {
88 | height: 100%;
89 | }
90 |
91 | image {
92 | display: block;
93 | margin: 0 auto;
94 | }
95 |
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/index.axml:
--------------------------------------------------------------------------------
1 |
2 | 真机调试小程序,就用 WeConsole !
3 | 高效、便捷、免代理抓包请求。
4 | 点击屏幕右侧的【蓝色图标】开启调试之旅~
5 |
6 |
7 |
8 | 版本:v{{version}}
9 |
10 | Github: https://github.com/weimob-tech/WeConsole
12 |
13 |
14 | NPM: https://www.npmjs.com/package/WeConsole
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | 支付宝无法通过API方式开启调试,请参考截图(可左右滑动)
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/index.js:
--------------------------------------------------------------------------------
1 | const { version } = require('weconsole/dist/my/npm/main/index');
2 | Page({
3 | data: {
4 | version,
5 | message: 'hi WeConsole',
6 | pkShow: false
7 | },
8 | copy(e) {
9 | wx.setClipboardData({
10 | data: e.currentTarget.dataset.url
11 | });
12 | },
13 | pk() {
14 | this.setData({
15 | pkShow: true
16 | });
17 | },
18 | closePk() {
19 | this.setData({
20 | pkShow: false
21 | });
22 | }
23 | });
24 |
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 | "demo": "../../demo/index",
4 | "weconsole": "weconsole/dist/my/npm/subpackage/components/main/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/network.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/npm/pages/index/network.jpg
--------------------------------------------------------------------------------
/examples/my/npm/pages/index/storage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/my/npm/pages/index/storage.jpg
--------------------------------------------------------------------------------
/examples/swan/full/.swan/editor.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/swan/full/.swan/editor.json
--------------------------------------------------------------------------------
/examples/swan/full/app.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/swan/full/app.css
--------------------------------------------------------------------------------
/examples/swan/full/app.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable indent */
2 | const { replace, showWeConsole, addCustomAction } = require('./weconsole/main/index');
3 |
4 | replace();
5 | showWeConsole();
6 |
7 | addCustomAction({
8 | id: 'customTableDemo',
9 | title: '自定义表格示例',
10 | cases: [
11 | {
12 | id: 'showList',
13 | button: '查看数据',
14 | showMode: 'grid',
15 | handler() {
16 | return {
17 | cols: [
18 | {
19 | title: '序号',
20 | field: 'id',
21 | width: '10'
22 | },
23 | {
24 | title: '页面及状态',
25 | field: 'page',
26 | width: '40'
27 | },
28 | {
29 | title: '门店',
30 | field: 'vid',
31 | width: '50'
32 | }
33 | ],
34 | data: Array.from({ length: 100 }).map((i, index) => {
35 | return {
36 | id: String(index),
37 | page: `/pages/p${index}`,
38 | vid:
39 | index % 2 === 0
40 | ? '门店信息:\n测试门店' + (index + 1)
41 | : {
42 | tableCell: true,
43 | blocks: [
44 | {
45 | block: true,
46 | items: [
47 | '门店信息',
48 | {
49 | type: 'text',
50 | content: '='
51 | },
52 | {
53 | type: 'json',
54 | value: {
55 | id: index,
56 | type: 3,
57 | name: `测试门店${index + 1}`
58 | }
59 | }
60 | ]
61 | }
62 | ]
63 | }
64 | };
65 | })
66 | };
67 | }
68 | }
69 | ]
70 | });
71 |
72 | App({
73 | data1: global,
74 | data2: { name: 'weconsole' }
75 | });
76 |
77 | console.log('console.log 来啦');
78 | console.error('console.error 来啦');
79 | console.info('console.info 来啦');
80 | console.warn('console.warn 来啦');
81 |
82 | console.log(
83 | '数字',
84 | 123,
85 | '布尔',
86 | true,
87 | '字符串',
88 | '函数',
89 | () => {
90 | console.log('123');
91 | },
92 | '类',
93 | class Box {
94 | show() {
95 | console.log('123');
96 | }
97 | }
98 | );
99 |
--------------------------------------------------------------------------------
/examples/swan/full/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": ["pages/index/index"],
3 | "window": {
4 | "navigationBarBackgroundColor": "#ffffff",
5 | "navigationBarTextStyle": "black",
6 | "navigationBarTitleText": "WeConsole示例",
7 | "backgroundTextStyle": "light"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/swan/full/demo/index.css:
--------------------------------------------------------------------------------
1 | .action-list {
2 | display: flex;
3 | flex-wrap: wrap;
4 | justify-content: space-between;
5 | }
6 |
7 | .action {
8 | position: relative;
9 | box-sizing: border-box;
10 | width: 48%;
11 | padding: 40rpx 30rpx;
12 | margin-bottom: 30rpx;
13 | line-height: 1.8;
14 | text-align: center;
15 | border-radius: 10rpx;
16 | box-shadow: rgb(255 255 255) 0 0 0 0, rgb(0 0 0 / 5%) 0 0 0 1px, rgb(0 0 0 / 10%) 0 10px 15px -3px,
17 | rgb(0 0 0 / 10%) 0 4px 6px -4px;
18 | }
19 |
20 | .lock {
21 | opacity: 0.5;
22 | }
23 |
24 | .action text {
25 | color: red;
26 | }
27 |
--------------------------------------------------------------------------------
/examples/swan/full/demo/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "demo2": "../demo2/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/swan/full/demo/index.swan:
--------------------------------------------------------------------------------
1 |
2 |
3 | 随机console
4 | swan.showToast
5 | swan.setStorageSync
6 | swan.getStorage
7 | swan.removeStorage
8 | swan.request{{requesting?'(发送中...)':''}}
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/swan/full/demo/tpl.swan:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/swan/full/demo2/index.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/swan/full/demo2/index.css
--------------------------------------------------------------------------------
/examples/swan/full/demo2/index.js:
--------------------------------------------------------------------------------
1 | Component({
2 | data: {
3 | message: 'hi demo2'
4 | }
5 | });
6 |
--------------------------------------------------------------------------------
/examples/swan/full/demo2/index.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/examples/swan/full/demo2/index.swan:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/swan/full/demo2/index.swan
--------------------------------------------------------------------------------
/examples/swan/full/pages/index/index.css:
--------------------------------------------------------------------------------
1 | /* stylelint-disable-next-line selector-type-no-unknown */
2 | page {
3 | box-sizing: border-box;
4 | padding: 30rpx;
5 | font-size: 28rpx;
6 | }
7 |
8 | .alert-warn,
9 | .alert-success {
10 | padding: 20rpx 30rpx;
11 | margin-top: 30rpx;
12 | margin-bottom: 30rpx;
13 | font-size: 24rpx;
14 | border-style: solid;
15 | border-width: 1px;
16 | }
17 |
18 | .alert-success {
19 | color: #3c763d;
20 | background-color: #dff0d8;
21 | border-color: #d6e9c6;
22 | }
23 |
24 | .alert-success text {
25 | font-size: 140%;
26 | font-weight: bold;
27 | color: #1b9af7;
28 | }
29 |
30 | .alert-warn {
31 | color: #8a6d3b;
32 | background-color: #fcf8e3;
33 | border-color: #faebcc;
34 | }
35 |
36 | .alert-warn view {
37 | margin-bottom: 30rpx;
38 | }
39 |
40 | .alert-warn text {
41 | color: blue;
42 | text-decoration: underline;
43 | }
44 |
45 | .box {
46 | height: 30rpx;
47 | padding: 5rpx 15rpx 5rpx 50rpx;
48 | background-color: red;
49 | }
50 |
51 | button {
52 | font-size: 24rpx;
53 | }
54 |
--------------------------------------------------------------------------------
/examples/swan/full/pages/index/index.js:
--------------------------------------------------------------------------------
1 | const { version } = require('../../weconsole/main/index');
2 | Page({
3 | data: {
4 | version,
5 | message: 'hi WeConsole',
6 | enableDebug: swan.getSystemInfoSync().enableDebug
7 | },
8 | copy(e) {
9 | swan.setClipboardData({
10 | data: e.currentTarget.dataset.url
11 | });
12 | }
13 | });
14 |
--------------------------------------------------------------------------------
/examples/swan/full/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "WeConsole示例",
3 | "usingComponents": {
4 | "demo": "../../demo/index",
5 | "weconsole": "../../weconsole/subpackage/components/main/index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/swan/full/pages/index/index.swan:
--------------------------------------------------------------------------------
1 |
2 | 真机调试小程序,就用 WeConsole !
3 | 高效、便捷、免代理抓包请求。
4 | 点击屏幕右侧的【蓝色图标】开启调试之旅~
5 |
6 |
7 |
8 | 版本:v{{version}}
9 |
10 | Github: https://github.com/weimob-tech/WeConsole
12 |
13 |
14 | NPM: https://www.npmjs.com/package/WeConsole
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/swan/full/pkginfo.json:
--------------------------------------------------------------------------------
1 | {
2 | "host_min_version": "0.0.0.0",
3 | "host_max_version": "255.255.255.255",
4 | "version_name": "1.0.9",
5 | "package_name": "swan-program-demo"
6 | }
--------------------------------------------------------------------------------
/examples/swan/full/project.swan.json:
--------------------------------------------------------------------------------
1 | {
2 | "appid": "17767960",
3 | "setting": {
4 | "urlCheck": false
5 | },
6 | "compilation-args": {
7 | "common": {
8 | "enhance": true,
9 | "quickPreview": true,
10 | "quickCompile": false,
11 | "useThread": true
12 | },
13 | "forceChanged": {},
14 | "useOldCompiler": false
15 | },
16 | "project-create-info": {
17 | "dev-tool-version": "4.33.0-rc",
18 | "date": "3/7/2024"
19 | },
20 | "host": "baiduboxapp",
21 | "swan": {
22 | "baiduboxapp": {
23 | "swanJsVersion": "3.830.1",
24 | "extensionJsVersion": "1.21.2"
25 | }
26 | },
27 | "projectname": "WeConsole示例",
28 | "preview": {
29 | "packageId": 1710583
30 | }
31 | }
--------------------------------------------------------------------------------
/examples/wx/full/app.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable indent */
2 | const { replace, showWeConsole, addCustomAction } = require('./weconsole/main/index');
3 |
4 | replace();
5 | showWeConsole();
6 |
7 | addCustomAction({
8 | id: 'customTableDemo',
9 | title: '自定义表格示例',
10 | cases: [
11 | {
12 | id: 'showList',
13 | button: '查看数据',
14 | showMode: 'grid',
15 | handler() {
16 | return {
17 | cols: [
18 | {
19 | title: '序号',
20 | field: 'id',
21 | width: '10'
22 | },
23 | {
24 | title: '页面及状态',
25 | field: 'page',
26 | width: '40'
27 | },
28 | {
29 | title: '门店',
30 | field: 'vid',
31 | width: '50'
32 | }
33 | ],
34 | data: Array.from({ length: 100 }).map((i, index) => {
35 | return {
36 | id: String(index),
37 | page: `/pages/p${index}`,
38 | vid:
39 | index % 2 === 0
40 | ? '门店信息:\n测试门店' + (index + 1)
41 | : {
42 | tableCell: true,
43 | blocks: [
44 | {
45 | block: true,
46 | items: [
47 | '门店信息',
48 | {
49 | type: 'text',
50 | content: '='
51 | },
52 | {
53 | type: 'json',
54 | value: {
55 | id: index,
56 | type: 3,
57 | name: `测试门店${index + 1}`
58 | }
59 | }
60 | ]
61 | }
62 | ]
63 | }
64 | };
65 | })
66 | };
67 | }
68 | }
69 | ]
70 | });
71 |
72 | App({
73 | data1: global,
74 | data2: { name: 'weconsole' }
75 | });
76 |
77 | console.log('console.log 来啦');
78 | console.error('console.error 来啦');
79 | console.info('console.info 来啦');
80 | console.warn('console.warn 来啦');
81 |
82 | console.log(
83 | '数字',
84 | 123,
85 | '布尔',
86 | true,
87 | '字符串',
88 | '函数',
89 | () => {
90 | console.log('123');
91 | },
92 | '类',
93 | class Box {
94 | show() {
95 | console.log('123');
96 | }
97 | }
98 | );
99 |
--------------------------------------------------------------------------------
/examples/wx/full/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": ["pages/index/index"],
3 | "sitemapLocation": "sitemap.json",
4 | "lazyCodeLoading": "requiredComponents"
5 | }
6 |
--------------------------------------------------------------------------------
/examples/wx/full/app.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/wx/full/app.wxss
--------------------------------------------------------------------------------
/examples/wx/full/demo/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "demo2": "../demo2/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/wx/full/demo/index.wxml:
--------------------------------------------------------------------------------
1 |
2 | 随机console
3 | wx.showToast
4 | wx.setStorageSync
5 | wx.getStorage
6 | wx.removeStorage
7 | wx.request{{requesting?'(发送中...)':''}}
8 |
9 |
--------------------------------------------------------------------------------
/examples/wx/full/demo/index.wxss:
--------------------------------------------------------------------------------
1 | .action-list {
2 | display: flex;
3 | flex-wrap: wrap;
4 | justify-content: space-between;
5 | }
6 |
7 | .action {
8 | position: relative;
9 | box-sizing: border-box;
10 | width: 48%;
11 | padding: 40rpx 30rpx;
12 | margin-bottom: 30rpx;
13 | line-height: 1.8;
14 | text-align: center;
15 | border-radius: 10rpx;
16 | box-shadow: rgb(255 255 255) 0 0 0 0, rgb(0 0 0 / 5%) 0 0 0 1px, rgb(0 0 0 / 10%) 0 10px 15px -3px,
17 | rgb(0 0 0 / 10%) 0 4px 6px -4px;
18 | }
19 |
20 | .lock {
21 | opacity: 0.5;
22 | }
23 |
24 | .action text {
25 | color: red;
26 | }
27 |
--------------------------------------------------------------------------------
/examples/wx/full/demo2/index.js:
--------------------------------------------------------------------------------
1 | Component({
2 | data: {
3 | message: 'hi demo2'
4 | }
5 | });
6 |
--------------------------------------------------------------------------------
/examples/wx/full/demo2/index.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/examples/wx/full/demo2/index.wxml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/wx/full/demo2/index.wxml
--------------------------------------------------------------------------------
/examples/wx/full/demo2/index.wxss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/wx/full/demo2/index.wxss
--------------------------------------------------------------------------------
/examples/wx/full/pages/index/index.js:
--------------------------------------------------------------------------------
1 | const { version } = require('../../weconsole/main/index');
2 | Page({
3 | data: {
4 | version,
5 | message: 'hi WeConsole',
6 | enableDebug: wx.getSystemInfoSync().enableDebug
7 | },
8 | copy(e) {
9 | wx.setClipboardData({
10 | data: e.currentTarget.dataset.url
11 | });
12 | },
13 | toggleDebug() {
14 | wx.setEnableDebug({
15 | enableDebug: !this.data.enableDebug
16 | });
17 | }
18 | });
19 |
--------------------------------------------------------------------------------
/examples/wx/full/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "WeConsole示例",
3 | "usingComponents": {
4 | "demo": "../../demo/index",
5 | "weconsole": "../../weconsole/subpackage/components/main/index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/wx/full/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 | 真机调试小程序,就用 WeConsole !
3 | 高效、便捷、免代理抓包请求。
4 | 点击屏幕右侧的【蓝色图标】开启调试之旅~
5 |
6 |
7 |
8 | 版本:v{{version}}
9 |
10 | Github: https://github.com/weimob-tech/WeConsole
12 |
13 |
14 | NPM: https://www.npmjs.com/package/WeConsole
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/wx/full/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /* stylelint-disable-next-line selector-type-no-unknown */
2 | page {
3 | box-sizing: border-box;
4 | padding: 30rpx;
5 | font-size: 28rpx;
6 | }
7 |
8 | .alert-warn,
9 | .alert-success {
10 | padding: 20rpx 30rpx;
11 | margin-top: 30rpx;
12 | margin-bottom: 30rpx;
13 | font-size: 24rpx;
14 | border-style: solid;
15 | border-width: 1px;
16 | }
17 |
18 | .alert-success {
19 | color: #3c763d;
20 | background-color: #dff0d8;
21 | border-color: #d6e9c6;
22 | }
23 |
24 | .alert-success text {
25 | font-size: 140%;
26 | font-weight: bold;
27 | color: #1b9af7;
28 | }
29 |
30 | .alert-warn {
31 | color: #8a6d3b;
32 | background-color: #fcf8e3;
33 | border-color: #faebcc;
34 | }
35 |
36 | .alert-warn view {
37 | margin-bottom: 30rpx;
38 | }
39 |
40 | .alert-warn text {
41 | color: blue;
42 | text-decoration: underline;
43 | }
44 |
45 | .box {
46 | height: 30rpx;
47 | padding: 5rpx 15rpx 5rpx 50rpx;
48 | background-color: red;
49 | }
50 |
51 | button {
52 | font-size: 24rpx;
53 | }
54 |
--------------------------------------------------------------------------------
/examples/wx/full/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileType": "miniprogram",
3 | "libVersion": "3.3.4",
4 | "packOptions": {
5 | "ignore": [],
6 | "include": []
7 | },
8 | "setting": {
9 | "coverView": true,
10 | "es6": true,
11 | "postcss": true,
12 | "minified": true,
13 | "enhance": true,
14 | "showShadowRootInWxmlPanel": true,
15 | "packNpmRelationList": [],
16 | "babelSetting": {
17 | "ignore": [],
18 | "disablePlugins": [],
19 | "outputPath": ""
20 | },
21 | "urlCheck": true,
22 | "compileHotReLoad": false,
23 | "bigPackageSizeSupport": false
24 | },
25 | "condition": {},
26 | "editorSetting": {
27 | "tabIndent": "insertSpaces",
28 | "tabSize": 4
29 | },
30 | "appid": "wx38a8d84858e383c3",
31 | "projectname": "WeConsole%E7%A4%BA%E4%BE%8B"
32 | }
--------------------------------------------------------------------------------
/examples/wx/full/project.private.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3 | "setting": {
4 | "urlCheck": false
5 | }
6 | }
--------------------------------------------------------------------------------
/examples/wx/full/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/examples/xhs/full/app.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/xhs/full/app.css
--------------------------------------------------------------------------------
/examples/xhs/full/app.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable indent */
2 | const { replace, showWeConsole, addCustomAction } = require('./weconsole/main/index');
3 |
4 | replace();
5 | showWeConsole();
6 |
7 | addCustomAction({
8 | id: 'customTableDemo',
9 | title: '自定义表格示例',
10 | cases: [
11 | {
12 | id: 'showList',
13 | button: '查看数据',
14 | showMode: 'grid',
15 | handler() {
16 | return {
17 | cols: [
18 | {
19 | title: '序号',
20 | field: 'id',
21 | width: '10'
22 | },
23 | {
24 | title: '页面',
25 | field: 'page',
26 | width: '40'
27 | },
28 | {
29 | title: '门店',
30 | field: 'vid',
31 | width: '50'
32 | }
33 | ],
34 | data: Array.from({ length: 100 }).map((i, index) => {
35 | return {
36 | id: String(index),
37 | page: `/pages/p${index}`,
38 | vid:
39 | index % 2 === 0
40 | ? '门店信息:\n测试门店' + (index + 1)
41 | : {
42 | tableCell: true,
43 | blocks: [
44 | {
45 | block: true,
46 | items: [
47 | '门店信息',
48 | {
49 | type: 'text',
50 | content: '='
51 | },
52 | {
53 | type: 'json',
54 | value: {
55 | id: index,
56 | type: 3,
57 | name: `测试门店${index + 1}`
58 | }
59 | }
60 | ]
61 | }
62 | ]
63 | }
64 | };
65 | })
66 | };
67 | }
68 | }
69 | ]
70 | });
71 |
72 | App({
73 | data1: global,
74 | data2: { name: 'weconsole' }
75 | });
76 |
77 | console.log('console.log 来啦');
78 | console.error('console.error 来啦');
79 | console.info('console.info 来啦');
80 | console.warn('console.warn 来啦');
81 |
82 | console.log(
83 | '数字',
84 | 123,
85 | '布尔',
86 | true,
87 | '字符串',
88 | '函数',
89 | () => {
90 | console.log('123');
91 | },
92 | '类',
93 | class Box {
94 | show() {
95 | console.log('123');
96 | }
97 | }
98 | );
99 |
--------------------------------------------------------------------------------
/examples/xhs/full/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": ["pages/index/index"],
3 | "sitemapLocation": "sitemap.json",
4 | "lazyCodeLoading": "requiredComponents"
5 | }
6 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo/index.css:
--------------------------------------------------------------------------------
1 | .action-list {
2 | display: flex;
3 | flex-wrap: wrap;
4 | justify-content: space-between;
5 | }
6 |
7 | .action {
8 | position: relative;
9 | box-sizing: border-box;
10 | width: 48%;
11 | padding: 40rpx 30rpx;
12 | margin-bottom: 30rpx;
13 | line-height: 1.8;
14 | text-align: center;
15 | border-radius: 10rpx;
16 | box-shadow: rgb(255 255 255) 0 0 0 0, rgb(0 0 0 / 5%) 0 0 0 1px, rgb(0 0 0 / 10%) 0 10px 15px -3px,
17 | rgb(0 0 0 / 10%) 0 4px 6px -4px;
18 | }
19 |
20 | .lock {
21 | opacity: 0.5;
22 | }
23 |
24 | .action text {
25 | color: red;
26 | }
27 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "demo2": "../demo2/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo/index.xhsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 随机console
5 | xhs.showToast
6 | xhs.setStorageSync
7 | xhs.getStorage
8 | xhs.removeStorage
9 |
10 | xhs.request{{requesting?'(发送中...)':''}}
11 |
12 |
13 |
14 | 9999{{item.value}}
15 |
16 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo2/index.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/xhs/full/demo2/index.css
--------------------------------------------------------------------------------
/examples/xhs/full/demo2/index.js:
--------------------------------------------------------------------------------
1 | Component({
2 | properties: {
3 | tabs: {
4 | type: Array
5 | }
6 | },
7 | data: {
8 | message: 'hi demo2',
9 | name: 456,
10 | val: {
11 | age: 123
12 | }
13 | }
14 | });
15 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo2/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true
3 | }
4 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo2/index.xhsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/xhs/full/demo2/tpl.xhsml:
--------------------------------------------------------------------------------
1 |
2 | {{name}}
3 | {{val.age}}
4 |
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/console.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/xhs/full/pages/index/console.jpg
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/el.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/xhs/full/pages/index/el.jpg
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/index.css:
--------------------------------------------------------------------------------
1 | /* stylelint-disable-next-line selector-type-no-unknown */
2 | page {
3 | box-sizing: border-box;
4 | padding: 30rpx;
5 | font-size: 28rpx;
6 | }
7 |
8 | .alert-warn,
9 | .alert-success {
10 | padding: 20rpx 30rpx;
11 | margin-top: 30rpx;
12 | margin-bottom: 30rpx;
13 | font-size: 24rpx;
14 | border-style: solid;
15 | border-width: 1px;
16 | }
17 |
18 | .alert-success {
19 | color: #3c763d;
20 | background-color: #dff0d8;
21 | border-color: #d6e9c6;
22 | }
23 |
24 | .alert-success text {
25 | font-size: 140%;
26 | font-weight: bold;
27 | color: #1b9af7;
28 | }
29 |
30 | .alert-warn {
31 | color: #8a6d3b;
32 | background-color: #fcf8e3;
33 | border-color: #faebcc;
34 | }
35 |
36 | .alert-warn view {
37 | margin-bottom: 30rpx;
38 | }
39 |
40 | .alert-warn text {
41 | color: blue;
42 | text-decoration: underline;
43 | }
44 |
45 | .box {
46 | height: 30rpx;
47 | padding: 5rpx 15rpx 5rpx 50rpx;
48 | background-color: red;
49 | }
50 |
51 | button {
52 | font-size: 24rpx;
53 | }
54 |
55 | .pk-modal {
56 | position: fixed;
57 | inset: 30% 0 0;
58 | z-index: 1200;
59 | display: flex;
60 | flex-direction: column;
61 | background-color: rgb(0 0 0 / 40%);
62 | box-shadow: 0 -10rpx 10rpx rgb(0 0 0 / 40%);
63 | }
64 |
65 | .btn-close {
66 | flex-shrink: 0;
67 | width: 100%;
68 | height: 80rpx;
69 | line-height: 80rpx;
70 | border-radius: 0;
71 | }
72 |
73 | .pk-content {
74 | flex-basis: 75%;
75 | flex-shrink: 1;
76 | background-color: #fff;
77 | }
78 |
79 | .pk-modal .alert-warn {
80 | margin: 0;
81 | }
82 |
83 | swiper,
84 | swiper-item,
85 | image {
86 | height: 100%;
87 | }
88 |
89 | image {
90 | display: block;
91 | margin: 0 auto;
92 | }
93 |
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/index.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | message: 'hi WeConsole',
4 | pkShow: false
5 | },
6 | copy(e) {
7 | xhs.setClipboardData({
8 | data: e.currentTarget.dataset.url
9 | });
10 | },
11 | pk() {
12 | this.setData({
13 | pkShow: true
14 | });
15 | },
16 | closePk() {
17 | this.setData({
18 | pkShow: false
19 | });
20 | }
21 | });
22 |
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "示例首页",
3 | "usingComponents": {
4 | "demo": "../../demo/index",
5 | "weconsole": "../../weconsole/subpackage/components/main/index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/index.xhsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Github: https://github.com/weimob-tech/WeConsole
6 |
7 |
8 | NPM: https://www.npmjs.com/package/WeConsole
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | 小红书无法通过API方式开启调试,请参考截图(可左右滑动)
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/net.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/xhs/full/pages/index/net.jpg
--------------------------------------------------------------------------------
/examples/xhs/full/pages/index/xhs.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/examples/xhs/full/pages/index/xhs.jpg
--------------------------------------------------------------------------------
/examples/xhs/full/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileType": "miniprogram",
3 | "libVersion": "3.83.1",
4 | "packOptions": {
5 | "ignore": [],
6 | "include": []
7 | },
8 | "setting": {
9 | "coverView": true,
10 | "es6": true,
11 | "postcss": true,
12 | "minified": true,
13 | "enhance": true,
14 | "showShadowRootInWxmlPanel": true,
15 | "packNpmRelationList": [],
16 | "babelSetting": {
17 | "ignore": [],
18 | "disablePlugins": [],
19 | "outputPath": ""
20 | },
21 | "useLiteCompiler": false,
22 | "useNewCompiler": true,
23 | "enableV2": true
24 | },
25 | "condition": {},
26 | "editorSetting": {
27 | "tabIndent": "insertSpaces",
28 | "tabSize": 4
29 | },
30 | "appid": "616d0cfa53d0ba0001db1528"
31 | }
32 |
--------------------------------------------------------------------------------
/examples/xhs/full/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/examples/xhs/full/xhs-sumi/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "*.xhsml": "html"
4 | }
5 | }
--------------------------------------------------------------------------------
/scripts/_copy.ts:
--------------------------------------------------------------------------------
1 | import copy from 'copy';
2 |
3 | export const copyPromise = (source: string, target: string): Promise => {
4 | return new Promise((resolve, reject) => {
5 | copy(source, target, (err) => {
6 | err ? reject(err) : resolve();
7 | });
8 | });
9 | };
10 |
--------------------------------------------------------------------------------
/scripts/bin.ts:
--------------------------------------------------------------------------------
1 | import { VERSION } from './vars';
2 | import { parseInjectConfig, injectMpProject } from './inject';
3 |
4 | const run = () => {
5 | if (process.argv[2] === 'inject') {
6 | const config = parseInjectConfig(process.argv, process.cwd());
7 | console.log('开始注入weconsole');
8 | injectMpProject(config);
9 | console.log('注入weconsole成功');
10 | return;
11 | }
12 |
13 | if (process.argv[2] === '-v' || process.argv[2] === 'version' || process.argv[2] === '-V') {
14 | console.log(VERSION);
15 | return;
16 | }
17 |
18 | console.error(
19 | `暂不支持${process.argv[2]}命令,注入项目请使用inject命令,其他请参考文档:https://github.com/weimob-tech/WeConsole`
20 | );
21 | };
22 |
23 | run();
24 |
--------------------------------------------------------------------------------
/scripts/cli.ts:
--------------------------------------------------------------------------------
1 | import { build } from './build';
2 |
3 | console.log('开始编译');
4 | build()
5 | .then(() => {
6 | console.log('编译成功');
7 | })
8 | .catch((err) => {
9 | console.log('编译失败');
10 | console.error(err);
11 | });
12 |
--------------------------------------------------------------------------------
/scripts/mp.ts:
--------------------------------------------------------------------------------
1 | import { compileFile } from './sass';
2 | import { getFiles, readFile, writeFile } from './fs';
3 | import { copyPromise } from './_copy';
4 | import { renameSync } from 'fs';
5 | import { toXhsML } from './translator/xhs';
6 | import { toAliXml } from './translator/ali';
7 | import { MpXmlFileSuffix } from './vars';
8 | import { toSwanXML } from './translator/swan';
9 |
10 | const cssFileSuffix = {
11 | wx: 'wxss',
12 | my: 'acss',
13 | xhs: 'css',
14 | qq: 'qss',
15 | swan: 'css',
16 | tt: 'ttss',
17 | ks: 'css'
18 | };
19 | const xjsFileSuffix = {
20 | wx: 'wxs',
21 | my: 'sjs',
22 | xhs: 'SJS',
23 | qq: 'qs',
24 | swan: 'sjs',
25 | tt: 'sjs',
26 | ks: 'sjs' // TODO: 待确认
27 | };
28 |
29 | export const compilerMpResource = (
30 | src: string,
31 | dist: string,
32 | targetPlatform: 'wx' | 'my' | 'xhs' | 'qq' | 'swan' | 'tt' | 'ks'
33 | ) => {
34 | return Promise.all([
35 | copyPromise(`${src}/**/*.png`, dist),
36 | copyPromise(`${src}/**/*.jpg`, dist),
37 | copyPromise(`${src}/**/*.jpeg`, dist),
38 | copyPromise(`${src}/**/*.gif`, dist),
39 | copyPromise(`${src}/**/*.wxs`, dist),
40 | copyPromise(`${src}/**/*.wxml`, dist),
41 | copyPromise(`${src}/**/*.wxss`, dist),
42 | copyPromise(`${src}/**/*.json`, dist),
43 | ...getFiles(src, true).reduce((sum: Array>, fileName) => {
44 | if (fileName.endsWith('.scss')) {
45 | sum.push(
46 | compileFile(
47 | fileName,
48 | dist + fileName.substring(src.length).replace('.scss', `.${cssFileSuffix[targetPlatform]}`)
49 | )
50 | );
51 | }
52 | return sum;
53 | }, [])
54 | ]).then(() => {
55 | if (targetPlatform === 'wx') {
56 | return;
57 | }
58 | getFiles(dist, true).forEach((fileName) => {
59 | if (fileName.endsWith('.wxss')) {
60 | const newFileName = fileName.substring(0, fileName.length - 5) + `.${cssFileSuffix[targetPlatform]}`;
61 | renameSync(fileName, newFileName);
62 |
63 | return;
64 | }
65 | if (fileName.endsWith('.wxml')) {
66 | const newFileName = fileName.substring(0, fileName.length - 5) + `.${MpXmlFileSuffix[targetPlatform]}`;
67 | renameSync(fileName, newFileName);
68 | const xml = readFile(newFileName);
69 | if (targetPlatform === 'xhs') {
70 | writeFile(newFileName, toXhsML(xml));
71 | return;
72 | }
73 | if (targetPlatform === 'my') {
74 | writeFile(newFileName, toAliXml(xml));
75 | return;
76 | }
77 | if (targetPlatform === 'swan') {
78 | writeFile(newFileName, toSwanXML(xml));
79 | return;
80 | }
81 | return;
82 | }
83 | if (fileName.endsWith('.wxs')) {
84 | const newFileName = fileName.substring(0, fileName.length - 4) + `.${xjsFileSuffix[targetPlatform]}`;
85 | renameSync(fileName, newFileName);
86 | if (targetPlatform === 'my') {
87 | const content = readFile(newFileName);
88 | writeFile(newFileName, content.replace('module.exports = ', 'export default'));
89 | }
90 | return;
91 | }
92 | });
93 | });
94 | };
95 |
--------------------------------------------------------------------------------
/scripts/other.ts:
--------------------------------------------------------------------------------
1 | import { spawn } from 'child_process';
2 |
3 | export const toCamelCase = (str: string): string => {
4 | const res = str.replace(/^-/, '').replace(/-(\w)(\w+)/g, (a, b, c) => {
5 | return b.toUpperCase() + c.toLowerCase();
6 | });
7 | return res[0].toUpperCase() + res.substr(1);
8 | };
9 |
10 | export const toJSON = (str: string): any => {
11 | try {
12 | return JSON.parse(str.trim());
13 | } catch (error) {
14 | try {
15 | // eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
16 | return new Function(`return ${str.trim()}`)();
17 | } catch (error) {}
18 | }
19 | };
20 | /** 创建一个唯一的uuid */
21 | export const uuid = (): string => {
22 | return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
23 | // tslint:disable-next-line:no-bitwise
24 | const r = (Math.random() * 16) | 0;
25 | // tslint:disable-next-line:no-bitwise
26 | const v = c === 'x' ? r : (r & 0x3) | 0x8;
27 | return v.toString(16);
28 | });
29 | };
30 |
31 | export const oneByOne = (promiseHandlers: Array<() => Promise>, rejectBreak: boolean): Promise => {
32 | return new Promise((resolve, reject) => {
33 | let index = -1;
34 | const exec = () => {
35 | index++;
36 | if (index >= promiseHandlers.length) {
37 | resolve();
38 | return;
39 | }
40 | promiseHandlers[index]()
41 | .then(() => {
42 | exec();
43 | })
44 | .catch((err) => {
45 | rejectBreak ? reject(err) : exec();
46 | });
47 | };
48 | exec();
49 | });
50 | };
51 |
52 | const supportPadStart = 'padStart' in String.prototype;
53 | export const padStart = (str: string, count: number, char: string): string => {
54 | if (supportPadStart) {
55 | return (str as any).padStart(count, char);
56 | }
57 | if (str.length >= count) {
58 | return str;
59 | }
60 | return new Array(count - str.length).fill(char).join('') + str;
61 | };
62 |
63 | export const runCommand = (command: string): Promise => {
64 | return new Promise((resolve, reject) => {
65 | console.log(`command=${command}`);
66 | const child = spawn(command, {
67 | shell: true,
68 | stdio: 'inherit'
69 | });
70 |
71 | child.on('exit', (code) => {
72 | if (code !== 0) {
73 | reject(new Error(`Command failed with exit code ${code}`));
74 | return;
75 | }
76 | resolve();
77 | });
78 | });
79 | };
80 |
--------------------------------------------------------------------------------
/scripts/sass.ts:
--------------------------------------------------------------------------------
1 | import * as sass from 'node-sass';
2 | import autoprefixer from 'autoprefixer';
3 | import PostCSS from 'postcss';
4 | import { writeFile } from './fs';
5 | export const compileFile = (srcFile: string, targetFile: string): Promise => {
6 | if (!srcFile) {
7 | return Promise.resolve();
8 | }
9 | const res = sass.renderSync({
10 | file: srcFile,
11 | outputStyle: 'expanded'
12 | }).css;
13 | return PostCSS([autoprefixer as any])
14 | .process(res, {
15 | from: srcFile
16 | })
17 | .then((result) => {
18 | writeFile(targetFile, result.css);
19 | });
20 | };
21 |
--------------------------------------------------------------------------------
/scripts/translator/parse.ts:
--------------------------------------------------------------------------------
1 | import type { FxNode } from 'forgiving-xml-parser';
2 | import { parse } from 'forgiving-xml-parser';
3 | export const parseXML = (xml: string) => {
4 | const res = parse(xml, {
5 | allowStartTagBoundaryNearSpace: true,
6 | allowEndTagBoundaryNearSpace: true,
7 | allowTagNameHasSpace: false
8 | });
9 | if (res.error) {
10 | throw res.error;
11 | }
12 | return res.nodes as FxNode[];
13 | };
14 |
--------------------------------------------------------------------------------
/scripts/translator/xhs.ts:
--------------------------------------------------------------------------------
1 | import type { FxNode } from 'forgiving-xml-parser';
2 | import { serialize } from 'forgiving-xml-parser';
3 | import { parseXML } from './parse';
4 |
5 | const translatorAttr = (attr: FxNode, node: FxNode) => {
6 | if (attr.name?.startsWith('wx:')) {
7 | attr.name = `xhs:${attr.name.substring(3)}`;
8 | return;
9 | }
10 | if ((node.name === 'include' || node.name === 'import') && attr.name === 'src' && attr.content) {
11 | attr.content = `${attr.content.substring(0, attr.content.length - 5)}.xhsml`;
12 | return;
13 | }
14 |
15 | if (node.name === 'wxs' && attr.name === 'src' && attr.content) {
16 | attr.content = `${attr.content.substring(0, attr.content.length - 4)}.sjs`;
17 | return;
18 | }
19 | };
20 |
21 | const loopTranslator = (nodes: FxNode[]) => {
22 | nodes.forEach((node) => {
23 | let notAttr = true;
24 | let hasSrcAttr = false;
25 | if (node.attrs) {
26 | notAttr = node.attrs.length === 0;
27 | node.attrs.forEach((attr) => {
28 | hasSrcAttr = hasSrcAttr || attr.name === 'src';
29 | translatorAttr(attr, node);
30 | });
31 | }
32 | if (node.name === 'wxs') {
33 | if (notAttr || !hasSrcAttr) {
34 | throw new Error('转换xhs不支持内联的wxs');
35 | }
36 | node.name = 'sjs';
37 | }
38 | if (node.children) {
39 | loopTranslator(node.children);
40 | }
41 | });
42 | };
43 |
44 | export const toXhsML = (wxml: string): string => {
45 | const wxmlNodes = parseXML(wxml);
46 | loopTranslator(wxmlNodes);
47 | return serialize(wxmlNodes);
48 | };
49 |
--------------------------------------------------------------------------------
/scripts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig-base.json",
3 | "compilerOptions": {
4 | "baseUrl": ".",
5 | "rootDir": ".",
6 | "lib": ["ESNext"],
7 | "module": "CommonJS",
8 | "target": "ES6",
9 | "skipLibCheck": true,
10 | "outDir": "../scripts-dist",
11 | "sourceMap": true,
12 | "esModuleInterop": true,
13 | "types": ["node"],
14 | "typeRoots": ["../node_modules/@types", "../node_modules"]
15 | },
16 | "include": ["./*.ts", "./**/*.ts"],
17 | "exclude": ["node_modules", "dist"]
18 | }
19 |
--------------------------------------------------------------------------------
/scripts/vars.ts:
--------------------------------------------------------------------------------
1 | import * as path from 'path';
2 | import { readFile } from './fs';
3 | import { toJSON } from './other';
4 |
5 | export const ROOT_DIR = path.resolve(__dirname, '../');
6 | export const VERSION = toJSON(readFile(ROOT_DIR + '/package.json')).version;
7 | export const MpXmlFileSuffix = {
8 | wx: 'wxml',
9 | my: 'axml',
10 | xhs: 'xhsml',
11 | qq: 'qml',
12 | swan: 'swan',
13 | tt: 'ttml',
14 | ks: 'kxml'
15 | };
16 |
--------------------------------------------------------------------------------
/src/main/global.d.ts:
--------------------------------------------------------------------------------
1 | import type { MpApiVar, MpViewFactory } from '@mpkit/types';
2 |
3 | declare global {
4 | let global: any;
5 | let getApp: (config?: any) => any;
6 | let getCurrentPages: () => undefined | any[];
7 | let wx: MpApiVar;
8 | let my: MpApiVar;
9 | let swan: MpApiVar;
10 | let tt: MpApiVar;
11 | let xhs: MpApiVar;
12 | let qq: MpApiVar;
13 | let ks: MpApiVar;
14 | let App: MpViewFactory;
15 | let Page: MpViewFactory;
16 | let Component: MpViewFactory;
17 | /** 编译目标 */
18 | let BUILD_TARGET: 'wx' | 'my' | 'swan' | 'qq' | 'tt' | 'ks' | 'xhs';
19 | let __wxConfig: any;
20 | let __qqConfig: any;
21 | let __appxStartupParams: any;
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/index.ts:
--------------------------------------------------------------------------------
1 | import { Hooker } from '@/main/modules/hooker';
2 | import { FormatApiMethodCallbackHook, FuncIDHook, MpProductHook, MpViewFactoryHook } from '@/main/modules/hooks';
3 | import { MpProductController } from '@/main/modules/controller';
4 | import type { MkFuncHook } from '@mpkit/types';
5 | import type { WeFuncHookState } from '@/types/hook';
6 | import { HookScope } from '@/types/common';
7 | import { emit } from '@/main/modules/ebus';
8 | import { WeConsoleEvents } from '@/types/scope';
9 | import { wcScope, wcScopeSingle } from './config';
10 | export * from '@/main/modules/ebus';
11 | export { getUIConfig, setUIConfig, addCustomAction, removeCustomAction } from './config';
12 |
13 | export { log, getWcControlMpViewInstances } from '@/main/modules/util';
14 |
15 | const ProductController = wcScopeSingle(
16 | 'ProductController',
17 | () => new MpProductController()
18 | ) as MpProductController;
19 |
20 | const HookerList = wcScopeSingle('HookerList', () => []) as Hooker[];
21 |
22 | // ProductController.on("all", (type, data) => {
23 | // ((console as any).org || console).log(type, data);
24 | // });
25 |
26 | const ProductControllerHook: MkFuncHook = {
27 | before(state) {
28 | state.state.controller = ProductController;
29 | }
30 | };
31 |
32 | const initHooker = (scope: HookScope) => {
33 | if (scope === HookScope.Api) {
34 | HookerList.push(
35 | Hooker.for(HookScope.Api, [ProductControllerHook, FuncIDHook, FormatApiMethodCallbackHook, MpProductHook])
36 | );
37 | return;
38 | }
39 | if (scope === HookScope.Console) {
40 | HookerList.push(Hooker.for(HookScope.Console, [ProductControllerHook, FuncIDHook, MpProductHook]));
41 | return;
42 | }
43 | if (scope === HookScope.Component) {
44 | HookerList.push(Hooker.for(HookScope.Component, [ProductControllerHook, MpViewFactoryHook]));
45 | return;
46 | }
47 | if (scope === HookScope.Page) {
48 | HookerList.push(Hooker.for(HookScope.Page, [ProductControllerHook, MpViewFactoryHook]));
49 | return;
50 | }
51 | if (scope === HookScope.App) {
52 | HookerList.push(Hooker.for(HookScope.App, [ProductControllerHook, MpViewFactoryHook]));
53 | }
54 | };
55 |
56 | export const replace = (scope?: HookScope) => {
57 | if (!scope) {
58 | replace(HookScope.Console);
59 | replace(HookScope.Api);
60 | replace(HookScope.App);
61 | replace(HookScope.Page);
62 | replace(HookScope.Component);
63 | return;
64 | }
65 | const item = HookerList.find((item) => item.scope === scope);
66 | if (item) {
67 | item.replace();
68 | return;
69 | }
70 | initHooker(scope);
71 | };
72 | export const restore = (scope?: HookScope) => {
73 | if (!scope) {
74 | return HookerList.forEach((item) => item.restore());
75 | }
76 | const item = HookerList.find((item) => item.scope === scope);
77 | if (item) {
78 | item.restore();
79 | }
80 | };
81 |
82 | export const showWeConsole = () => {
83 | const scope = wcScope();
84 | scope.visible = true;
85 | emit(WeConsoleEvents.WcVisibleChange, scope.visible);
86 | };
87 | export const hideWeConsole = () => {
88 | const scope = wcScope();
89 | scope.visible = false;
90 | emit(WeConsoleEvents.WcVisibleChange, scope.visible);
91 | };
92 |
93 | export const version = 'VERSION';
94 | console.log(`欢迎使用WeConsole v${version},让小程序调试更高效!`);
95 |
--------------------------------------------------------------------------------
/src/main/init.ts:
--------------------------------------------------------------------------------
1 | import { replace } from './index';
2 | import { HookScope } from '@/types/common';
3 |
4 | replace(HookScope.Console);
5 | replace(HookScope.Api);
6 | replace(HookScope.App);
7 | replace(HookScope.Page);
8 | replace(HookScope.Component);
9 |
--------------------------------------------------------------------------------
/src/main/modules/category.ts:
--------------------------------------------------------------------------------
1 | import type { MpNameValue } from '@/types/common';
2 |
3 | export const MpApiCategoryMap = {
4 | request: 'xhr',
5 | downloadFile: 'xhr',
6 | uploadFile: 'xhr',
7 | createUDPSocket: 'xhr',
8 | sendSocketMessage: 'ws',
9 | onSocketOpen: 'ws',
10 | onSocketMessage: 'ws',
11 | onSocketError: 'ws',
12 | onSocketClose: 'ws',
13 | connectSocket: 'ws',
14 | closeSocket: 'ws',
15 | canIUse: 'base',
16 | switchTab: 'navigate',
17 | navigateBack: 'navigate',
18 | navigateTo: 'navigate',
19 | redirectTo: 'navigate',
20 | reLaunch: 'navigate',
21 | showToast: 'ui',
22 | showModal: 'ui',
23 | showLoading: 'ui',
24 | showActionSheet: 'ui',
25 | hideToast: 'ui',
26 | hideLoading: 'ui',
27 | nextTick: 'ui',
28 | stopPullDownRefresh: 'scroll',
29 | startPullDownRefresh: 'scroll',
30 | pageScrollTo: 'scroll',
31 | setStorageSync: 'storage',
32 | setStorage: 'storage',
33 | removeStorageSync: 'storage',
34 | removeStorage: 'storage',
35 | getStorageSync: 'storage',
36 | getStorage: 'storage',
37 | getStorageInfo: 'storage',
38 | getStorageInfoSync: 'storage',
39 | clearStorageSync: 'storage',
40 | clearStorage: 'storage',
41 | login: 'user',
42 | checkSession: 'user',
43 | getAccountInfoSync: 'user',
44 | getUserProfile: 'user',
45 | getUserInfo: 'user',
46 | getLocation: 'user',
47 | openLocation: 'user'
48 | };
49 |
50 | export const reportCategoryMapToList = (categoryMap: { [prop: string]: string }): MpNameValue[] => {
51 | return Object.keys(categoryMap).reduce(
52 | (sum, item) => {
53 | if (!sum.mark[categoryMap[item]]) {
54 | const categoryVal = categoryMap[item];
55 | sum.mark[categoryVal] = 1;
56 | let text;
57 | if (categoryVal === 'xhr') {
58 | text = 'XHR';
59 | } else if (categoryVal === 'ws') {
60 | text = 'WS';
61 | } else if (categoryVal === 'ui') {
62 | text = 'UI';
63 | } else {
64 | text = categoryVal[0].toUpperCase() + categoryVal.substr(1);
65 | }
66 | const oldLen = sum.list.length;
67 | sum.list.push({
68 | name: text,
69 | value: categoryVal
70 | });
71 | if (!oldLen) {
72 | sum.list.push({
73 | name: 'Cloud',
74 | value: 'cloud'
75 | });
76 | }
77 | }
78 | return sum;
79 | },
80 | {
81 | mark: {},
82 | list: [] as MpNameValue[]
83 | }
84 | ).list;
85 | };
86 |
--------------------------------------------------------------------------------
/src/main/modules/controller.ts:
--------------------------------------------------------------------------------
1 | import type { HookScope } from '@/types/common';
2 | import type { IMpProductController, MpProductFilter } from '@/types/hook';
3 | import type { MpProduct } from '@/types/product';
4 | import { EventEmitter } from './event-emitter';
5 | import { filter as filterList } from './util';
6 |
7 | export class MpProductController extends EventEmitter implements IMpProductController {
8 | private typeMap: Record>;
9 | private typeList: Record;
10 |
11 | constructor() {
12 | super();
13 | this.typeMap = {};
14 | this.typeList = {};
15 | }
16 |
17 | remove(id: string) {
18 | const item = this.findById(id);
19 | if (!item) {
20 | return;
21 | }
22 | const type = item.type;
23 | if (!(type in this.typeList)) {
24 | return;
25 | }
26 | const index = this.typeList[type].indexOf(this.typeMap[type][id]);
27 | if (index !== -1) {
28 | this.typeList[type].splice(index, 1);
29 | }
30 | delete this.typeMap[type][id];
31 | }
32 |
33 | clear(type: HookScope, keepSaveIdList?: string[]) {
34 | const newList: MpProduct[] = [];
35 | const newMap: Record = {};
36 | if (keepSaveIdList) {
37 | keepSaveIdList.forEach((id) => {
38 | newList.push(this.typeMap[type][id]);
39 | newMap[id] = this.typeMap[type][id];
40 | });
41 | }
42 | delete this.typeMap[type];
43 | delete this.typeList[type];
44 | this.typeMap[type] = newMap;
45 | this.typeList[type] = newList;
46 | }
47 |
48 | findById(id: string): MpProduct | undefined {
49 | const type = id.split('-')[0];
50 | return this.typeMap[type]?.[id];
51 | }
52 |
53 | getList(type: HookScope, filter?: MpProductFilter): MpProduct[] {
54 | if (!type) {
55 | return [];
56 | }
57 | if (!filter) {
58 | return ([] as MpProduct[]).concat(this.typeList[type] || []);
59 | }
60 | return filterList(this.typeList[type], filter);
61 | }
62 |
63 | create(data: Partial & Required>): MpProduct {
64 | return this.push(data, 'create');
65 | }
66 |
67 | change(data: Partial & Required>): MpProduct {
68 | return this.push(data, 'change');
69 | }
70 |
71 | private push(data: Partial & Required>, eventType: string): MpProduct {
72 | if (!(data.type in this.typeMap)) {
73 | this.typeMap[data.type] = {};
74 | }
75 | if (!(data.type in this.typeList)) {
76 | this.typeList[data.type] = [];
77 | }
78 | if (!(data.id in this.typeMap[data.type])) {
79 | this.typeMap[data.type][data.id] = data as MpProduct;
80 | this.typeList[data.type].push(data as MpProduct);
81 | this.emit(eventType, this.typeMap[data.type][data.id]);
82 | return this.typeMap[data.type][data.id];
83 | }
84 | Object.assign(this.typeMap[data.type][data.id], data);
85 | this.emit(eventType, this.typeMap[data.type][data.id]);
86 | return this.typeMap[data.type][data.id];
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/modules/ebus.ts:
--------------------------------------------------------------------------------
1 | export { on, off, emit, once, ebus } from '../config';
2 |
--------------------------------------------------------------------------------
/src/main/modules/event-emitter.ts:
--------------------------------------------------------------------------------
1 | import type { IEventEmitter, EventHandler, AnyFunction } from '@/types/util';
2 | export class EventEmitter implements IEventEmitter {
3 | private events: {
4 | [prop: string]: EventHandler[];
5 | } = {};
6 |
7 | constructor() {
8 | ['on', 'off', 'emit'].forEach((prop) => {
9 | this[prop] = this[prop].bind(this);
10 | });
11 | }
12 |
13 | once(type: string, _handler: EventHandler) {
14 | const handler = (...args: Parameters>) => {
15 | _handler(...args);
16 | this.off(type, handler);
17 | };
18 | this.on(type, handler);
19 | }
20 |
21 | destory() {
22 | this.emit('destory');
23 | // eslint-disable-next-line guard-for-in
24 | for (const prop in this.events) {
25 | delete this.events[prop];
26 | }
27 | }
28 |
29 | on(type: string, handler: EventHandler) {
30 | if (!this.events[type]) {
31 | this.events[type] = [];
32 | }
33 | if (this.events[type].indexOf(handler) === -1) {
34 | this.events[type].push(handler);
35 | }
36 | }
37 |
38 | off(type: string, handler?: EventHandler) {
39 | if (this.events[type]) {
40 | if (handler) {
41 | const index = this.events[type].indexOf(handler);
42 | if (index !== -1) {
43 | this.events[type].splice(index, 1);
44 | }
45 | } else {
46 | delete this.events[type];
47 | }
48 | }
49 | }
50 |
51 | emit(type: string, data?: T) {
52 | const currentIsFireHandlers: AnyFunction[] = [];
53 | const fire = (handleType = type) => {
54 | let needReload;
55 | if (this.events[type]) {
56 | const list = this.events[type];
57 | for (let i = 0, len = list.length; i < len; i++) {
58 | if (!this.events[type]) {
59 | break;
60 | }
61 | if (this.events[type] && i in list && list[i]) {
62 | const handler = list[i];
63 | if (currentIsFireHandlers.indexOf(handler) !== -1) {
64 | continue;
65 | }
66 | const nextHandler = list[i + 1];
67 | currentIsFireHandlers.push(handler);
68 | handler(handleType, data);
69 | if (!list[i] || list[i] !== handler || !list[i + 1] || list[i + 1] !== nextHandler) {
70 | needReload = true;
71 | break;
72 | }
73 | }
74 | }
75 | }
76 | needReload && fire();
77 | };
78 | if (type !== 'all') {
79 | fire();
80 | const old = type;
81 | // eslint-disable-next-line no-param-reassign
82 | type = 'all';
83 | fire(old);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/modules/state-controller.ts:
--------------------------------------------------------------------------------
1 | import type { IMpProductController } from '@/types/hook';
2 | import { getUIConfig, wcScopeSingle } from '../config';
3 | import { ReaderStateController } from './reader-state';
4 |
5 | export const MainStateController = wcScopeSingle(
6 | 'MainStateController',
7 | () => new ReaderStateController('Main')
8 | ) as ReaderStateController;
9 |
10 | export const ApiStateController = wcScopeSingle(
11 | 'ApiStateController',
12 | () => new ReaderStateController('Api', () => wcScopeSingle('ProductController') as IMpProductController)
13 | ) as ReaderStateController;
14 |
15 | export const ConsoleStateController = wcScopeSingle(
16 | 'ConsoleStateController',
17 | () => new ReaderStateController('Console', () => wcScopeSingle('ProductController') as IMpProductController)
18 | ) as ReaderStateController;
19 |
20 | // 选中默认分类
21 | const apiState = ApiStateController;
22 | if (getUIConfig().apiDefaultCategoryValue) {
23 | apiState.setState('activeCategory', getUIConfig().apiDefaultCategoryValue);
24 | }
25 | const consoleState = ConsoleStateController;
26 | if (getUIConfig().consoleDefaultCategoryValue) {
27 | consoleState.setState('activeCategory', getUIConfig().consoleDefaultCategoryValue);
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/modules/view-store.ts:
--------------------------------------------------------------------------------
1 | import type { MpViewInstance } from 'typescript-mp-component';
2 | import { wcScopeSingle } from '../config';
3 |
4 | export const saveView = (vw: any) => {
5 | const store = wcScopeSingle('MpViewInstances', () => []) as Array;
6 | const removeIndexList = wcScopeSingle('MpViewInstanceRemoveIndexList', () => []) as Array;
7 | let index = removeIndexList.shift();
8 | index = index === undefined ? store.length : index;
9 | vw.__wcStoreIndex__ = index;
10 | store[index] = vw;
11 | };
12 | export const removeView = (vw: any) => {
13 | if (!('__wcStoreIndex__' in vw)) {
14 | return;
15 | }
16 | const store = wcScopeSingle('MpViewInstances', () => []) as Array;
17 | store[vw.__wcStoreIndex__] = undefined;
18 | const removeIndexList = wcScopeSingle('MpViewInstanceRemoveIndexList', () => []) as Array;
19 | removeIndexList.push(vw.__wcStoreIndex__);
20 | };
21 | export const getViewList = () => {
22 | return wcScopeSingle('MpViewInstances', () => []) as Array;
23 | };
24 |
--------------------------------------------------------------------------------
/src/subpackage/components/api-detail/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "tabs": "../tabs/index",
5 | "collapse": "../collapse/index",
6 | "json-viewer": "../json-viewer/index"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/subpackage/components/api-detail/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/icon.scss';
3 | @import '../style/headers.scss';
4 | @import '../style/detail.scss';
5 | @import '../style/status.scss';
6 | @import '../style/table.scss';
7 |
8 | .fc-detail-title {
9 | display: flex;
10 | align-items: center;
11 | justify-content: space-between;
12 | width: 100%;
13 | font-size: 24rpx;
14 | font-weight: bold;
15 | color: #616161;
16 | }
17 |
18 | .collapse-action {
19 | margin-right: 20rpx !important;
20 | font-size: 20rpx;
21 | font-weight: normal;
22 | }
23 |
24 | .detail-tab-plc {
25 | height: 20rpx;
26 | }
27 |
28 | .detail-tab-panel {
29 | position: absolute;
30 | top: 0;
31 | right: 0;
32 | bottom: 0;
33 | left: 0;
34 | }
35 |
36 | .wc-link {
37 | margin: 0 20rpx !important;
38 | font-size: 80%;
39 | font-weight: normal;
40 | color: $bg-primary;
41 | }
42 |
--------------------------------------------------------------------------------
/src/subpackage/components/api-reader/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "api-detail": "../api-detail/index",
5 | "filter-bar": "../filter-bar/index",
6 | "data-table": "../data-table/index"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/subpackage/components/api-reader/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/reader.scss';
3 |
--------------------------------------------------------------------------------
/src/subpackage/components/api-reader/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
8 |
9 |
10 |
11 |
13 |
14 |
--------------------------------------------------------------------------------
/src/subpackage/components/collapse/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true
3 | }
--------------------------------------------------------------------------------
/src/subpackage/components/collapse/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/headers.scss';
2 |
3 | .fc-collapse {
4 | box-sizing: border-box;
5 | width: 100%;
6 | height: 40rpx;
7 | padding-left: 30rpx !important;
8 | margin-bottom: 20rpx !important;
9 | overflow: hidden;
10 |
11 | &.is-open {
12 | height: auto;
13 |
14 | .fc-collapse-head {
15 | &::before {
16 | content: '';
17 | transform: rotate(90deg) translateX(4rpx) translateY(8rpx);
18 | }
19 | }
20 | }
21 | }
22 |
23 | .fc-collapse-head {
24 | position: relative;
25 | box-sizing: border-box;
26 | display: flex;
27 | align-items: center;
28 | padding-top: 6rpx !important;
29 | padding-bottom: 6rpx !important;
30 | font-family: $ft-name;
31 | font-size: 26rpx;
32 | color: #616161;
33 |
34 | &::before {
35 | position: relative;
36 | top: 0;
37 | display: block;
38 | margin-left: -15rpx !important;
39 | content: '';
40 | border-color: transparent;
41 | border-style: solid;
42 | border-width: 8rpx 10rpx;
43 | border-left-color: $cr-bar;
44 | transition: all 0.3s;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/subpackage/components/collapse/index.ts:
--------------------------------------------------------------------------------
1 | import type { MpComponentProperties } from 'typescript-mp-component';
2 | import { MpComponent } from 'typescript-mp-component';
3 | import { ToolMixin } from '@/sub/mixins/tool';
4 | import { registerClassComponent } from '@/sub/mixins/component';
5 |
6 | interface Props {
7 | open: boolean;
8 | inner: boolean;
9 | title: string;
10 | border: boolean;
11 | }
12 |
13 | class Collapse extends MpComponent<{ innerOpen: boolean }, Props, Collapse> {
14 | $mx = {
15 | Tool: new ToolMixin()
16 | };
17 | options = {
18 | multipleSlots: true
19 | };
20 | properties: MpComponentProperties = {
21 | open: {
22 | type: Boolean,
23 | observer(val) {
24 | this.$mx.Tool.$updateData({
25 | innerOpen: val
26 | });
27 | }
28 | },
29 | inner: {
30 | type: Boolean,
31 | value: true
32 | },
33 | title: String,
34 | border: {
35 | type: Boolean,
36 | value: true
37 | }
38 | };
39 | initData = {
40 | innerOpen: false
41 | };
42 | toggle() {
43 | this.triggerEvent('toggle');
44 | this.$mx.Tool.$updateData({
45 | innerOpen: !this.data.innerOpen
46 | });
47 | }
48 | }
49 |
50 | registerClassComponent(Collapse);
51 |
--------------------------------------------------------------------------------
/src/subpackage/components/collapse/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/element.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-viewer": "../json-viewer/index",
5 | "wc-element": "./element"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/element.scss:
--------------------------------------------------------------------------------
1 | $sep: 10rpx;
2 |
3 | .wc-el-boundary,
4 | .wc-el-name,
5 | .wc-el-equal,
6 | .wc-el-attr.wc-el-content,
7 | .wc-el-ellipsis {
8 | display: inline;
9 | font-size: 26rpx;
10 | line-height: 1.4;
11 | word-break: break-all;
12 | white-space: normal;
13 | vertical-align: middle;
14 | }
15 |
16 | .wc-el-head {
17 | padding: 4rpx 0 !important;
18 | font-size: 0;
19 | line-height: 0;
20 | word-break: break-all;
21 | white-space: normal;
22 |
23 | &.selected {
24 | background-color: #ebf5fb;
25 | }
26 | }
27 |
28 | .wc-el-head,
29 | .wc-el-body,
30 | .wc-el-footer {
31 | box-sizing: border-box;
32 | padding-left: 20rpx !important;
33 | }
34 |
35 | .wc-el-boundary {
36 | color: #ad9cad;
37 | }
38 |
39 | .wc-el-name {
40 | color: #90258b;
41 | }
42 |
43 | .wc-el-attr.wc-el-name {
44 | margin-left: $sep;
45 | color: #a15619;
46 | }
47 |
48 | .wc-el-equal {
49 | color: #ad9cad;
50 | }
51 |
52 | .wc-el-attr.wc-el-content {
53 | color: #2525ab;
54 | }
55 |
56 | .wc-el-head.has-child {
57 | position: relative;
58 |
59 | &::before {
60 | position: absolute;
61 | top: 16rpx;
62 | left: 0;
63 | content: '';
64 | border-color: transparent;
65 | border-style: solid;
66 | border-width: 8rpx 10rpx;
67 | border-left-color: #565656;
68 | transition: all 0.3s;
69 | }
70 |
71 | &.open::before {
72 | transform: rotate(90deg) translateX(4rpx);
73 | }
74 | }
75 |
76 | .tapable {
77 | position: relative;
78 |
79 | &::after {
80 | position: absolute;
81 | right: 0;
82 | bottom: 0;
83 | left: 0;
84 | content: '';
85 | border-bottom: 1px dashed #ad9cad !important;
86 | }
87 | }
88 |
89 | .wc-el-ellipsis {
90 | font-size: 80%;
91 | }
92 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/element.ts:
--------------------------------------------------------------------------------
1 | import type { MpComponentProperties } from 'typescript-mp-component';
2 | import { MpComponent } from 'typescript-mp-component';
3 | import { registerClassComponent } from '@/sub/mixins/component';
4 |
5 | interface Props {
6 | data: {
7 | open: boolean;
8 | path: string;
9 | id: string;
10 | };
11 | selectId: string;
12 | }
13 |
14 | interface Data {
15 | l: string;
16 | l2: string;
17 | r: string;
18 | r2: string;
19 | }
20 |
21 | class ComponentReaderElement extends MpComponent {
22 | properties: MpComponentProperties = {
23 | data: Object,
24 | selectId: String
25 | };
26 | initData: Data = {
27 | l: '<',
28 | l2: '',
29 | r: '>',
30 | r2: '/>'
31 | };
32 |
33 | tap() {
34 | this.triggerEvent('toggle', {
35 | open: !this.data.data.open,
36 | path: this.data.data.path,
37 | id: this.data.data.id
38 | });
39 | }
40 | tapName() {
41 | this.triggerEvent('tapName', {
42 | path: this.data.data.path,
43 | id: this.data.data.id
44 | });
45 | }
46 | childTapName(e) {
47 | this.triggerEvent('tapName', e.detail);
48 | }
49 | toggle(e) {
50 | this.triggerEvent('toggle', e.detail);
51 | }
52 | }
53 |
54 | registerClassComponent(ComponentReaderElement);
55 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/element.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{l}}
4 | {{data.name}}
5 |
6 |
7 | {{item.name}}
8 |
9 | =
10 | {{'"'}}
11 | {{item.content}}
12 | {{'"'}}
13 |
14 |
15 |
16 |
17 |
18 | {{r}}
19 | {{'…'}}
20 | {{l2}}
21 | {{data.name}}
22 | {{r}}
23 |
24 | {{' '+r2}}
25 |
26 | {{r}}
27 |
28 |
29 |
30 |
31 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "collapse": "../collapse/index",
5 | "filter-bar": "../filter-bar/index",
6 | "json-viewer": "../json-viewer/index",
7 | "wc-element": "./element"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/icon.scss';
3 | @import '../style/reader.scss';
4 | @import '../style/headers.scss';
5 |
6 | .wc-elements {
7 | box-sizing: border-box;
8 | height: 100%;
9 | padding: 0 20rpx !important;
10 | }
11 |
12 | .action-bar {
13 | position: relative;
14 | height: $ht-tab-bar - 20rpx;
15 | border-bottom: 1px solid $bg-tab-border !important;
16 | }
17 |
18 | .fc-detail-close {
19 | @include wic;
20 | @include ic-close;
21 |
22 | width: ($ht-tab-bar - 20rpx) / 2.2;
23 | height: ($ht-tab-bar - 20rpx) / 2.2;
24 | }
25 |
26 | .fc-reader-detail {
27 | position: absolute;
28 | top: 0;
29 | right: 0;
30 | bottom: 0;
31 | left: 30%;
32 | background-color: #fff;
33 | border-left: 2px solid $bg-tab-border !important;
34 | }
35 |
36 | .detail-scroll {
37 | position: absolute;
38 | top: $ht-tab-bar - 20rpx;
39 | right: 0;
40 | bottom: 0;
41 | left: 0;
42 | box-sizing: border-box;
43 | }
44 |
45 | .fc-detail-title {
46 | display: flex;
47 | align-items: center;
48 | justify-content: space-between;
49 | width: 100%;
50 | font-size: 24rpx;
51 | font-weight: bold;
52 | color: #616161;
53 | }
54 |
55 | .fc-headers-item {
56 | padding-right: 20rpx !important;
57 | padding-left: 20rpx !important;
58 | }
59 |
60 | .fc-detail-action {
61 | display: flex;
62 | align-items: center;
63 | justify-content: center;
64 | width: $ht-tab-bar - 20rpx;
65 | height: $ht-tab-bar - 20rpx;
66 |
67 | &.is-last::after {
68 | display: none;
69 | }
70 |
71 | &::after {
72 | position: absolute;
73 | top: 10rpx;
74 | right: 0;
75 | bottom: 10rpx;
76 | width: 1rpx;
77 | content: '';
78 | background-color: $bg-tab-border;
79 | }
80 | }
81 |
82 | .detail-label {
83 | position: absolute;
84 | top: 0;
85 | right: 0;
86 | bottom: 0;
87 | left: $ht-tab-bar - 20rpx;
88 | padding-right: 20rpx !important;
89 | padding-left: 20rpx !important;
90 | font-size: 28rpx;
91 | line-height: $ht-tab-bar - 20rpx;
92 | color: #424242;
93 | }
94 |
95 | .death-tip {
96 | padding: 15rpx !important;
97 | margin-bottom: 15rpx !important;
98 | font-size: 20rpx;
99 | color: #8a6d3b;
100 | text-align: center;
101 | background-color: #fcf8e3;
102 | border-bottom: 1px solid #faebcc !important;
103 | }
104 |
--------------------------------------------------------------------------------
/src/subpackage/components/component-reader/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{detailLable}}
14 |
15 |
16 |
17 |
18 | 该组件实例已不在节点树中
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader-item/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-viewer": "../json-viewer/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader-item/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/icon.scss';
3 |
4 | .console-row {
5 | position: relative;
6 | box-sizing: border-box;
7 | min-height: 44rpx;
8 | padding: 5rpx 15rpx 5rpx 50rpx !important;
9 | font-size: 0;
10 | color: $cr-datagrid;
11 | letter-spacing: 0;
12 | background-color: #fff;
13 | border-bottom: 1px solid $bg-bar !important;
14 |
15 | &.is-warn {
16 | color: $cr-warn;
17 | background-color: #fff3e0;
18 | border-bottom-color: #f7e9a3;
19 | }
20 |
21 | &.is-error {
22 | color: $cr-error;
23 | background-color: #fff0f0;
24 | border-bottom-color: #ffd6d6;
25 | }
26 |
27 | &.wc-selected {
28 | position: relative;
29 | background-color: #ebf5fb;
30 |
31 | &::after {
32 | position: absolute;
33 | right: 0;
34 | bottom: -1px;
35 | left: 0;
36 | z-index: 5;
37 | height: 1px;
38 | content: '';
39 | }
40 |
41 | &.is-error::after {
42 | background-color: #ffd6d6;
43 | }
44 |
45 | &.is-warn::after {
46 | background-color: #f7e9a3;
47 | }
48 |
49 | &.is-info::after,
50 | &.is-log::after {
51 | background-color: #ccdef5;
52 | }
53 |
54 | &.is-log,
55 | &.is-info {
56 | border-bottom-color: #ccdef5;
57 | }
58 | }
59 | }
60 |
61 | .console-wic {
62 | @include wic;
63 |
64 | position: absolute;
65 |
66 | &.wic-error {
67 | top: 13rpx;
68 | left: 18rpx;
69 | width: 16rpx;
70 | height: 16rpx;
71 |
72 | &::before,
73 | &::after {
74 | z-index: 2;
75 | }
76 |
77 | .wic-arrow-1 {
78 | top: -4rpx;
79 | left: -4rpx;
80 | z-index: 1;
81 | width: 24rpx;
82 | height: 24rpx;
83 | background-color: $cr-error;
84 | border-radius: 50%;
85 | }
86 | }
87 |
88 | @include ic-error;
89 | @include ic-warn;
90 | @include ic-info;
91 |
92 | &.wic-warn,
93 | &.wic-info {
94 | left: 10rpx;
95 | width: 30rpx;
96 | height: 30rpx;
97 | font-size: 30rpx;
98 | line-height: 1;
99 | text-align: center;
100 | }
101 | }
102 |
103 | .fc-br {
104 | display: block;
105 | }
106 |
107 | .console-item {
108 | font-size: 22rpx;
109 | word-break: break-all;
110 | white-space: pre-wrap;
111 | display: inline;
112 |
113 | &.type-json {
114 | display: inline-block;
115 | vertical-align: top;
116 | }
117 | &.type-fun {
118 | display: inline-block;
119 | font-family: $ft-code;
120 | font-style: italic;
121 | vertical-align: top;
122 | &:active,
123 | &:focus {
124 | background-color: #fff;
125 | box-shadow: 0 0 10rpx rgba(128, 128, 128, 0.1);
126 | }
127 | }
128 | &.type-division {
129 | padding-left: 16rpx !important;
130 | }
131 | &.type-nail {
132 | color: $cr-nail;
133 | }
134 | &.type-num,
135 | &.type-bool {
136 | color: $cr-num;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader-item/index.ts:
--------------------------------------------------------------------------------
1 | import { registerClassComponent } from '@/sub/mixins/component';
2 | import type { MpConsoleMaterial } from '@/types/product';
3 | import type { MpEvent } from '@/types/view';
4 | import type { MpComponentProperties } from 'typescript-mp-component';
5 | import { MpComponent } from 'typescript-mp-component';
6 | import type { MpVirtualListItemComponentProps } from '@cross-virtual-list/types';
7 |
8 | type Props = MpVirtualListItemComponentProps;
9 |
10 | class ConsoleReaderItemComponent extends MpComponent {
11 | properties: MpComponentProperties = {
12 | value: {
13 | type: Object
14 | },
15 | maxIndex: Number,
16 | index: Number,
17 | state: Object,
18 | direction: String,
19 | scope: String
20 | };
21 |
22 | emitInteractEvent(type: string, detail?: any) {
23 | const id = this.data.value.id;
24 | this.triggerEvent('interact', {
25 | type: type,
26 | id,
27 | detail
28 | });
29 | }
30 |
31 | tapRow() {
32 | this.emitInteractEvent('tapRow');
33 | }
34 |
35 | longpressRow() {
36 | this.emitInteractEvent('longpressRow');
37 | }
38 |
39 | rowJSONViewerToggle(e: MpEvent) {
40 | this.emitInteractEvent('rowJSONViewerToggle', {
41 | index: parseInt(String(e.currentTarget.dataset.index)),
42 | ...(e.detail || {})
43 | });
44 | }
45 | }
46 |
47 | registerClassComponent(ConsoleReaderItemComponent);
48 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader-item/index.wxml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {{rowItem.content||''}}
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "filter-bar": "../filter-bar/index",
5 | "json-viewer": "../json-viewer/index",
6 | "console-item": "../console-reader-item/index",
7 | "dynamic-virtual-list": "@cross-virtual-list/mp-wx/components/dynamic/index"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/icon.scss';
3 | @import '../style/reader.scss';
4 |
5 | .console-affixs {
6 | position: relative;
7 | z-index: 8;
8 | overflow: hidden;
9 | border-bottom: 1px solid $bg-datagrid-border !important;
10 | box-shadow: 0 8rpx 8rpx rgba(0, 0, 0, 0.1);
11 | }
12 |
--------------------------------------------------------------------------------
/src/subpackage/components/console-reader/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/src/subpackage/components/custom-action/buttons.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/src/subpackage/components/custom-action/content.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "data-table": "../data-table/index",
5 | "json-viewer": "../json-viewer/index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/subpackage/components/custom-action/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "data-table": "../data-table/index",
5 | "tabs": "../tabs/index",
6 | "json-viewer": "../json-viewer/index"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/subpackage/components/custom-action/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 |
3 | .ca-button {
4 | box-sizing: border-box;
5 | display: block;
6 | height: 60rpx !important;
7 | padding: 0 20rpx !important;
8 | margin-bottom: 15rpx !important;
9 | overflow: hidden;
10 | font-size: 24rpx !important;
11 | line-height: 60rpx !important;
12 | color: #fff;
13 | text-align: center;
14 | text-overflow: ellipsis;
15 | white-space: nowrap;
16 | background-color: $bg-primary;
17 | border-radius: 30rpx !important;
18 |
19 | &:disabled,
20 | &.disabled {
21 | opacity: 0.5;
22 | }
23 | }
24 |
25 | .ca-scroll {
26 | height: 100%;
27 | }
28 |
29 | .ca-section {
30 | padding: 20rpx !important;
31 | }
32 |
33 | .ca-text {
34 | padding: 0 15rpx !important;
35 | font-size: 24rpx;
36 | line-height: 1.4;
37 | word-break: break-all;
38 | white-space: normal;
39 | }
40 |
41 | .ca-err {
42 | padding: 0 15rpx !important;
43 | font-family: $ft-code;
44 | font-size: 24rpx;
45 | line-height: 1.4;
46 | color: $cr-error;
47 | word-break: break-all;
48 | white-space: pre-wrap;
49 | }
50 |
51 | .ca-grid,
52 | .ca-component {
53 | position: absolute;
54 | top: 100rpx;
55 | right: 0;
56 | bottom: 0;
57 | left: 0;
58 | border-top: 1px solid #ededed !important;
59 | }
60 |
61 | .case-tab-panel {
62 | height: 100%;
63 | }
64 |
--------------------------------------------------------------------------------
/src/subpackage/components/data-table/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-viewer": "../json-viewer/index",
5 | "row": "../table-row/index",
6 | "dynamic-virtual-list": "@cross-virtual-list/mp-wx/components/dynamic/index",
7 | "regular-virtual-list": "@cross-virtual-list/mp-wx/components/regular/index"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/subpackage/components/data-table/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 |
3 | .wc-table {
4 | position: relative;
5 | z-index: 1;
6 | height: 100%;
7 | color: $cr-datagrid;
8 | background-color: $bg-datagrid;
9 | }
10 |
11 | .wc-table-line {
12 | position: absolute;
13 | top: 0;
14 | bottom: 0;
15 | z-index: 10;
16 | width: 1px;
17 | margin-left: -1px !important;
18 | background-color: $bg-datagrid-border;
19 | }
20 |
21 | .wc-table-head {
22 | box-sizing: border-box;
23 | font-size: $sz-datagrid-th;
24 | background-color: $bg-datagrid-head;
25 | }
26 |
27 | .wc-table-affix {
28 | position: relative;
29 | z-index: 8;
30 | border-bottom: 1px solid $bg-datagrid-border !important;
31 | box-shadow: 0 8rpx 8rpx rgba(0, 0, 0, 0.1);
32 | }
33 |
34 | .wc-table-body {
35 | position: absolute;
36 | bottom: 0;
37 | left: 0;
38 | z-index: 5;
39 | width: 100%;
40 | }
41 |
--------------------------------------------------------------------------------
/src/subpackage/components/data-table/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/src/subpackage/components/filter-bar/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true
3 | }
--------------------------------------------------------------------------------
/src/subpackage/components/filter-bar/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/icon.scss';
3 |
4 | .fc-filter-bar {
5 | box-sizing: border-box;
6 | display: flex;
7 | justify-content: space-between;
8 | height: $ht-filter-bar;
9 | font-size: $sz-filter-bar;
10 | color: $cr-filter-bar;
11 | background-color: $bg-filter-bar;
12 | border-bottom: 2px solid $bg-filter-bar-border !important;
13 |
14 | &.has-refresh {
15 | .fc-filter-items {
16 | padding-left: 0;
17 | }
18 | }
19 |
20 | &.has-remove.has-clear {
21 | .fc-filter-main {
22 | width: 740rpx - ($ht-filter-bar + $ht-filter-bar);
23 | }
24 | }
25 |
26 | &.has-remove,
27 | &.has-clear {
28 | .fc-filter-main {
29 | width: 740rpx - $ht-filter-bar;
30 | }
31 | }
32 | }
33 |
34 | .fc-filter-items {
35 | display: flex;
36 | flex-wrap: nowrap;
37 | align-items: center;
38 | height: $ht-filter-bar;
39 | box-sizing: border-box;
40 | padding: 0 15rpx !important;
41 | }
42 |
43 | .fc-filter-input {
44 | flex-shrink: 0;
45 | width: 200rpx;
46 | height: $ht-filter-bar - 16rpx;
47 | padding: 0 5rpx !important;
48 | margin-right: 15rpx !important;
49 | font-size: $sz-filter-bar - 4rpx;
50 | font-weight: bold;
51 | line-height: $ht-filter-bar - 16rpx;
52 | background-color: #fff;
53 | }
54 |
55 | .fc-filter-category {
56 | display: flex;
57 | flex-shrink: 0;
58 | align-items: center;
59 | padding: 8rpx 10rpx !important;
60 | margin-right: 15rpx !important;
61 | line-height: 1;
62 | border-radius: 4rpx;
63 |
64 | &.active {
65 | color: $cr-filter-active;
66 | background-color: $bg-filter-active;
67 | }
68 | }
69 |
70 | .fc-filter-category-br {
71 | height: 100%;
72 | margin-right: 15rpx !important;
73 | }
74 |
75 | .fc-filter-category-br,
76 | .fc-filter-actions {
77 | position: relative;
78 | z-index: 5;
79 |
80 | &::after {
81 | position: absolute;
82 | top: $ht-filter-bar / 4;
83 | bottom: $ht-filter-bar / 4;
84 | left: 1px;
85 | width: 1rpx;
86 | content: '';
87 | background-color: $bg-filter-bar-border;
88 | }
89 | }
90 |
91 | .fc-filter-main,
92 | .fc-filter-actions {
93 | height: $ht-filter-bar;
94 | }
95 |
96 | .fc-filter-main {
97 | flex-grow: 0;
98 | }
99 |
100 | .fc-filter-actions {
101 | display: flex;
102 | flex-shrink: 0;
103 | }
104 |
105 | .fc-filter-action {
106 | display: flex;
107 | align-items: center;
108 | justify-content: center;
109 | width: $ht-filter-bar;
110 | height: $ht-filter-bar;
111 | }
112 |
113 | .fc-filter-clear,
114 | .fc-filter-remove,
115 | .fc-filter-refresh {
116 | @include wic;
117 |
118 | width: $ht-filter-bar / 2;
119 | height: $ht-filter-bar / 2;
120 | }
121 |
122 | .fc-filter-refresh {
123 | @include ic-refresh;
124 | }
125 |
126 | .fc-filter-clear {
127 | @include ic-clear;
128 | }
129 |
130 | .fc-filter-remove {
131 | @include ic-close;
132 | }
133 |
--------------------------------------------------------------------------------
/src/subpackage/components/filter-bar/index.ts:
--------------------------------------------------------------------------------
1 | import type { MpComponentEvent, MpComponentProperties } from 'typescript-mp-component';
2 | import { MpComponent } from 'typescript-mp-component';
3 | import { registerClassComponent } from '@/sub/mixins/component';
4 |
5 | interface Props {
6 | filter: boolean;
7 | refresh: boolean;
8 | filterPlaceholder: string;
9 | remove: boolean;
10 | clear: boolean;
11 | activeCategory: string;
12 | categorys: string[];
13 | }
14 |
15 | class FilterBar extends MpComponent {
16 | properties: MpComponentProperties = {
17 | filter: {
18 | type: Boolean,
19 | value: true
20 | },
21 | refresh: {
22 | type: Boolean,
23 | value: false
24 | },
25 | filterPlaceholder: {
26 | type: String,
27 | value: 'Filter'
28 | },
29 | remove: {
30 | type: Boolean,
31 | value: false
32 | },
33 | clear: {
34 | type: Boolean,
35 | value: false
36 | },
37 | activeCategory: String,
38 | categorys: Array
39 | };
40 | onFilterConfirm(e: Required>) {
41 | const text = e.detail.value;
42 | this.triggerEvent('filter', text);
43 | }
44 | onClear() {
45 | this.triggerEvent('clear');
46 | }
47 | onRemove() {
48 | this.triggerEvent('remove');
49 | }
50 | onRefresh() {
51 | this.triggerEvent('refresh');
52 | }
53 | tapCategory(e: MpComponentEvent) {
54 | if (this.data.activeCategory === e.currentTarget.dataset.val) {
55 | return;
56 | }
57 | this.triggerEvent('category', e.currentTarget.dataset.val);
58 | }
59 | }
60 |
61 | registerClassComponent(FilterBar);
62 |
--------------------------------------------------------------------------------
/src/subpackage/components/filter-bar/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{item.name}}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/chunk-left.wxml:
--------------------------------------------------------------------------------
1 |
2 | {{data.className}}
3 |
4 | {{data.leftBoundary}}
5 |
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/chunk-right.wxml:
--------------------------------------------------------------------------------
1 |
2 | {{data.rightBoundary}}
3 |
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-node": "./node",
5 | "tabs": "../tabs/index"
6 | }
7 | }
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 |
3 | .json-viewer {
4 | padding: 20rpx !important;
5 | font-family: $ft-code;
6 | font-size: 0;
7 | line-height: 0;
8 | color: #424242;
9 |
10 | &.console-jw {
11 | display: inherit;
12 | min-width: 100%;
13 | padding: 0 !important;
14 | }
15 | }
16 | .json-title {
17 | margin-bottom: 10rpx;
18 | white-space: normal;
19 | word-break: break-all;
20 | font-family: $ft-code;
21 | font-weight: bold;
22 | font-size: 28rpx;
23 | line-height: 1.4;
24 | }
25 |
26 | .json-string {
27 | padding: 20rpx !important;
28 | font-family: $ft-code;
29 | font-size: 20rpx;
30 | color: #424242;
31 | word-break: break-all;
32 | white-space: pre-wrap;
33 | }
34 |
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{title}}
6 | {{JSONString}}
7 |
8 |
9 | {{title}}
10 |
11 |
12 |
13 |
14 |
15 |
16 | {{JSONString}}
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/node.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-node": "./node"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/node.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 |
3 | $entity-mgr: 6rpx;
4 |
5 | .json-chunk,
6 | .json-node-content-item,
7 | .json-row-item,
8 | .json-value-item {
9 | display: inline;
10 | font-size: 0;
11 | line-height: 0;
12 | word-break: break-all;
13 | }
14 |
15 | .left-boundary,
16 | .right-boundary,
17 | .json-content,
18 | .jn-remark,
19 | .class-name {
20 | display: inline;
21 | font-size: 28rpx;
22 | line-height: 1.4;
23 | word-break: break-all;
24 | }
25 |
26 | .json-node-content,
27 | .json-tree,
28 | .json-row {
29 | padding-left: 20rpx !important;
30 | }
31 |
32 | .left-boundary.string,
33 | .right-boundary.string,
34 | .json-content.string {
35 | color: $cr-str;
36 | }
37 |
38 | .json-content.num,
39 | .json-content.bool,
40 | .json-content.func {
41 | color: $cr-num;
42 | }
43 |
44 | .json-node-content.has-arrow,
45 | .json-row.has-arrow {
46 | position: relative;
47 |
48 | .json-arrow {
49 | position: absolute;
50 | left: 0;
51 | content: '';
52 | border-color: transparent;
53 | border-style: solid;
54 | border-width: 8rpx 10rpx;
55 | border-left-color: #565656;
56 | transition: all 0.3s;
57 | }
58 | }
59 |
60 | .jn-prop {
61 | color: #881391;
62 |
63 | &.protected {
64 | opacity: 0.5;
65 | }
66 | }
67 |
68 | .json-node-content .jn-prop {
69 | font-size: (28 * 0.8) rpx;
70 | color: #565656;
71 | }
72 |
73 | .jn-remark {
74 | font-style: italic;
75 | }
76 |
77 | .jn-remark,
78 | .class-name,
79 | .ellipsis {
80 | color: #808080;
81 | }
82 |
83 | .undefined,
84 | .null {
85 | color: $cr-nail;
86 | }
87 |
--------------------------------------------------------------------------------
/src/subpackage/components/json-viewer/node.ts:
--------------------------------------------------------------------------------
1 | import type { MpComponentProperties } from 'typescript-mp-component';
2 | import { MpComponent } from 'typescript-mp-component';
3 | import { JSONType } from '@/types/json';
4 | import { registerClassComponent } from '@/sub/mixins/component';
5 | import type { MpEvent } from '@/types/view';
6 |
7 | interface Props {
8 | data: {
9 | open?: boolean;
10 | path?: string;
11 | type: JSONType;
12 | };
13 | fontSize: number;
14 | smallFontSize: number;
15 | outerClass: string;
16 | }
17 |
18 | class JsonNode extends MpComponent, Props> {
19 | properties: MpComponentProperties = {
20 | data: Object,
21 | fontSize: Number,
22 | smallFontSize: Number,
23 | outerClass: String
24 | };
25 | tapRow(e: MpEvent) {
26 | if (e.currentTarget.dataset.tv === 'compute') {
27 | return;
28 | }
29 | this.tap();
30 | }
31 | tapChunkRow(e) {
32 | if (e.currentTarget.dataset.tv !== 'compute') {
33 | return;
34 | }
35 | this.tapChunk();
36 | }
37 | tap() {
38 | this.triggerEvent('toggle', {
39 | open: !this.data.data.open,
40 | path: this.data.data.path
41 | });
42 | }
43 | tapChunk() {
44 | if (this.data.data.type === JSONType.compute) {
45 | this.triggerEvent('toggle', {
46 | path: this.data.data.path,
47 | fromCompute: true
48 | });
49 | }
50 | }
51 | toggle(e) {
52 | this.triggerEvent('toggle', e.detail);
53 | }
54 | }
55 |
56 | registerClassComponent(JsonNode);
57 |
--------------------------------------------------------------------------------
/src/subpackage/components/main/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "tabs": "../tabs/index",
5 | "movable": "../movable/index",
6 | "json-viewer": "../json-viewer/index",
7 | "api-reader": "../api-reader/index",
8 | "console-reader": "../console-reader/index",
9 | "component-reader": "../component-reader/index",
10 | "storage-reader": "../storage-reader/index",
11 | "custom-action": "../custom-action/index"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/subpackage/components/main/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/icon.scss';
3 |
4 | .fc-hand {
5 | &:hover,
6 | &:focus {
7 | outline: none;
8 | -webkit-tap-highlight-color: transparent;
9 | }
10 |
11 | &.is-hide {
12 | display: none;
13 | }
14 | }
15 |
16 | .fc-hand-prefect {
17 | .fc-hand-toggle {
18 | display: flex;
19 | align-items: center;
20 | justify-content: center;
21 | width: $ht-hand;
22 | height: $ht-hand;
23 | cursor: pointer;
24 | background: $bg-primary;
25 | border-radius: 50%;
26 | box-shadow: 0 0 20rpx $bg-primary;
27 | -webkit-tap-highlight-color: transparent;
28 | }
29 | }
30 |
31 | .fc-hand-icon {
32 | width: 80%;
33 | height: 80%;
34 | }
35 |
36 | .fc-modal {
37 | position: fixed;
38 | top: 40%;
39 | right: 0;
40 | bottom: 0;
41 | left: 0;
42 | z-index: 1000;
43 | display: none;
44 | background-color: #fff;
45 | border-top: 1px solid $bg-tab-border !important;
46 |
47 | &.is-show {
48 | display: block;
49 | }
50 |
51 | &.is-full {
52 | top: 0;
53 | }
54 |
55 | &.fc-adap-scroll {
56 | .fc-modal-body {
57 | bottom: 100rpx;
58 | }
59 | }
60 | }
61 |
62 | .fc-modal-adap {
63 | position: absolute;
64 | right: 0;
65 | bottom: 0;
66 | left: 0;
67 | box-sizing: border-box;
68 | height: 100rpx;
69 | margin-bottom: -1px !important;
70 | border-top: 1px solid #ccc !important;
71 | font-family: consolas, menlo, monaco, 'Courier New', monospace;
72 | font-size: 19rpx;
73 | font-weight: bold;
74 | color: #ccc;
75 | text-align: center;
76 | padding: 20rpx 30rpx !important;
77 | display: flex;
78 | align-items: center;
79 | justify-content: space-between;
80 | white-space: nowrap;
81 | }
82 |
83 | .fc-ad-title {
84 | font-size: 40rpx;
85 | opacity: 0.8;
86 | }
87 |
88 | .fc-ad {
89 | opacity: 0.6;
90 | font-weight: 300;
91 | }
92 |
93 | .fc-ad .fc-label {
94 | display: block;
95 | font-size: 65%;
96 | }
97 |
98 | .fc-modal-body {
99 | position: absolute;
100 | top: 0;
101 | right: 0;
102 | bottom: 0;
103 | left: 0;
104 | }
105 |
106 | .fc-tabs-action {
107 | position: relative;
108 | display: flex;
109 | align-items: center;
110 | justify-content: center;
111 | width: $ht-tab-bar;
112 | height: $ht-tab-bar;
113 |
114 | &::after {
115 | position: absolute;
116 | top: 15rpx;
117 | right: 0;
118 | bottom: 15rpx;
119 | z-index: 15;
120 | width: 1rpx;
121 | content: '';
122 | background-color: $bg-tab-border;
123 | }
124 | }
125 |
126 | .fc-tabs-action-right {
127 | &::after {
128 | right: auto;
129 | left: 0;
130 | }
131 | }
132 |
133 | .fc-tabs-zoom,
134 | .fc-tabs-close {
135 | @include wic;
136 |
137 | width: $ht-tab-bar / 2;
138 | height: $ht-tab-bar / 2;
139 | }
140 |
141 | .fc-tabs-zoom {
142 | @include ic-expand-compress;
143 | }
144 |
145 | .fc-tabs-close {
146 | @include ic-close;
147 | }
148 |
149 | .fc-tab-panel-reader {
150 | position: absolute;
151 | top: 1px;
152 | right: 0;
153 | bottom: 0;
154 | left: 0;
155 | display: block;
156 | }
157 |
158 | .sys-tab-panel {
159 | height: 100%;
160 | }
161 | .wc-main-tabs {
162 | height: 100%;
163 | }
164 |
--------------------------------------------------------------------------------
/src/subpackage/components/movable/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true
3 | }
4 |
--------------------------------------------------------------------------------
/src/subpackage/components/movable/index.wxml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/src/subpackage/components/storage-reader/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-viewer": "../json-viewer/index",
5 | "filter-bar": "../filter-bar/index",
6 | "data-table": "../data-table/index"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/subpackage/components/storage-reader/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 | @import '../style/reader.scss';
3 | @import '../style/icon.scss';
4 | @import '../style/detail.scss';
5 |
6 | .fc-detail {
7 | border-left: 1px solid $bg-th-bar-border !important;
8 | }
9 |
10 | .btn-link {
11 | top: 0;
12 | right: 15rpx;
13 | font-size: 80%;
14 | }
15 |
16 | .progress-bar {
17 | position: relative;
18 | min-width: 224rpx;
19 | height: 44rpx;
20 | margin: 0 5rpx !important;
21 | overflow: hidden;
22 | background-color: #cdcdcd;
23 | border-radius: 8rpx;
24 | box-shadow: inset 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
25 |
26 | &.warn {
27 | .progress-val {
28 | background-color: #f0ad4e;
29 | }
30 | }
31 |
32 | &.danger {
33 | .progress-val {
34 | background-color: #d9534f;
35 | }
36 | }
37 | }
38 |
39 | .progress-val {
40 | height: 100%;
41 | background-color: #5cb85c;
42 | }
43 |
44 | .progress-text {
45 | position: absolute;
46 | top: 6rpx;
47 | left: 10rpx;
48 | }
49 |
--------------------------------------------------------------------------------
/src/subpackage/components/storage-reader/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | {{currentSize}}kb/{{limitSize}}kb
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Copy
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/subpackage/components/style/detail.scss:
--------------------------------------------------------------------------------
1 | @import './var.scss';
2 | @import './icon.scss';
3 |
4 | .fc-detail {
5 | display: block;
6 | height: 100%;
7 | background-color: #fff;
8 | border-left: 2px solid $bg-th-bar-border !important;
9 |
10 | &.fc-status-container {
11 | display: flex;
12 | flex-direction: column;
13 | align-items: center;
14 | justify-content: center;
15 | font-size: 12rpx;
16 | color: $cr-muted;
17 |
18 | .fc-status-action {
19 | margin-top: 15rpx !important;
20 | }
21 | }
22 | }
23 |
24 | .btn-link {
25 | font-size: inherit;
26 | color: $cr-link;
27 | text-decoration: underline;
28 | }
29 |
30 | .fc-detail-close {
31 | @include wic;
32 | @include ic-close;
33 |
34 | width: ($ht-tab-bar - 20rpx) / 2.2;
35 | height: ($ht-tab-bar - 20rpx) / 2.2;
36 | }
37 |
38 | .fc-detail-action {
39 | display: flex;
40 | align-items: center;
41 | justify-content: center;
42 | min-width: $ht-tab-bar - 20rpx;
43 | height: $ht-tab-bar - 20rpx;
44 |
45 | &.absolute {
46 | position: absolute;
47 | z-index: 5;
48 | }
49 |
50 | &.right-border {
51 | &::after {
52 | position: absolute;
53 | top: 10rpx;
54 | right: 0;
55 | bottom: 10rpx;
56 | width: 1rpx;
57 | content: '';
58 | background-color: $bg-tab-border;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/subpackage/components/style/headers.scss:
--------------------------------------------------------------------------------
1 | @import './var.scss';
2 |
3 | .fc-headers-item {
4 | padding: 8rpx 10rpx !important;
5 | font-family: $ft-code;
6 | font-size: 24rpx;
7 | line-height: 1.6;
8 | color: #545454;
9 |
10 | &:active {
11 | color: $cr-active !important;
12 | background-color: $bg-active;
13 | }
14 | }
15 |
16 | // .fc-headers-stack {
17 | // .fc-headers-name {
18 | // &:after {
19 | // display: none;
20 | // }
21 | // }
22 | // }
23 |
24 | .fc-headers-hr {
25 | margin: 6rpx 0 !important;
26 | border-bottom: 1px solid $bg-tab-border !important;
27 | }
28 |
29 | .fc-headers-name {
30 | font-family: $ft-name;
31 | font-weight: bold;
32 |
33 | &::after {
34 | display: inline;
35 | margin-right: 8rpx !important;
36 | margin-left: 2rpx !important;
37 | content: ':';
38 | }
39 | }
40 |
41 | .fc-headers-remark {
42 | display: inline;
43 | font-size: 20rpx;
44 | opacity: 0.7;
45 | }
46 |
47 | .fc-headers-name,
48 | .fc-headers-key,
49 | .fc-headers-val {
50 | display: inline;
51 | word-break: break-all;
52 | white-space: normal;
53 | }
54 |
--------------------------------------------------------------------------------
/src/subpackage/components/style/reader.scss:
--------------------------------------------------------------------------------
1 | @import './var.scss';
2 |
3 | .fc-reader {
4 | position: relative;
5 | z-index: 5;
6 | height: 100%;
7 | background-color: $bg-reader;
8 | }
9 |
10 | .fc-reader-detail-container {
11 | position: absolute;
12 | top: 0;
13 | right: 0;
14 | bottom: 0;
15 | left: 30%;
16 | z-index: 10;
17 | display: block;
18 | background-color: #fff;
19 |
20 | &.has-bar {
21 | top: $ht-filter-bar;
22 | }
23 |
24 | .fc-reader-detail-scroll {
25 | height: 100%;
26 | }
27 | }
28 |
29 | .fc-reader-body {
30 | position: absolute;
31 | top: 0;
32 | right: 0;
33 | bottom: 0;
34 | left: 0;
35 | z-index: 5;
36 |
37 | &.has-bar {
38 | top: $ht-filter-bar;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/subpackage/components/style/status.scss:
--------------------------------------------------------------------------------
1 | @import './var.scss';
2 |
3 | .fc-status-success {
4 | color: $cr-success !important;
5 | }
6 |
7 | .fc-status-error {
8 | color: $cr-error !important;
9 | }
10 |
--------------------------------------------------------------------------------
/src/subpackage/components/style/table.scss:
--------------------------------------------------------------------------------
1 | @import './var.scss';
2 |
3 | .fc-table-container {
4 | padding: 15rpx !important;
5 | }
6 |
7 | .fc-table {
8 | display: table;
9 | width: 100%;
10 | font-size: 20rpx;
11 | color: $cr-bar;
12 | border-collapse: collapse;
13 | border: 1px solid $bg-tab-border !important;
14 | }
15 |
16 | .fc-table-tr {
17 | display: table-row;
18 | }
19 |
20 | .fc-table-tr-even {
21 | background-color: $bg-row-odd;
22 | }
23 |
24 | .fc-table-tr-odd {
25 | background-color: $bg-row-even;
26 | }
27 |
28 | .fc-table-th,
29 | .fc-table-td {
30 | display: table-cell;
31 | padding: 6rpx !important;
32 | word-break: break-all;
33 | white-space: normal;
34 | border-right: 1px solid $bg-tab-border !important;
35 | }
36 |
37 | .fc-table-th {
38 | font-size: 22rpx;
39 | background-color: $bg-tab-head;
40 | border-bottom: 1px solid $bg-tab-border !important;
41 | }
42 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-cell/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-viewer": "../json-viewer/index"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-cell/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 |
3 | .table-cell.wc-nowrap {
4 | flex-wrap: nowrap;
5 | overflow: hidden;
6 | text-overflow: ellipsis;
7 | white-space: nowrap;
8 |
9 | .table-cell-block,
10 | .table-cell-block-text {
11 | flex-wrap: nowrap;
12 | overflow: hidden;
13 | text-overflow: ellipsis;
14 | white-space: nowrap;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-cell/index.ts:
--------------------------------------------------------------------------------
1 | import { registerClassComponent } from '@/sub/mixins/component';
2 | import type { TableCellComponentProps } from '@/types/table';
3 | import type { MpEvent } from '@/types/view';
4 | import type { MpComponentProperties } from 'typescript-mp-component';
5 | import { MpComponent } from 'typescript-mp-component';
6 |
7 | class TableCellComponent extends MpComponent {
8 | properties: MpComponentProperties> = {
9 | value: {
10 | type: Object,
11 | optionalTypes: [Object, String]
12 | },
13 | col: Object,
14 | from: String
15 | };
16 | onJSONViewerToggle(e: MpEvent) {
17 | this.triggerEvent('onJSONViewerToggle', {
18 | ...e.detail,
19 | blockIndex: parseInt(e.currentTarget.dataset.block),
20 | jsonItemIndex: parseInt(e.currentTarget.dataset.index)
21 | });
22 | }
23 | }
24 |
25 | registerClassComponent(TableCellComponent);
26 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-cell/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.content}}
6 |
9 | {{item}}
10 |
11 |
12 |
13 | {{value}}
14 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-row/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "json-viewer": "../json-viewer/index",
5 | "cell": "../table-cell/index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-row/index.scss:
--------------------------------------------------------------------------------
1 | @import '../style/var.scss';
2 |
3 | .wc-table-row {
4 | display: flex;
5 | flex-wrap: nowrap;
6 | align-items: center;
7 | color: $cr-renderer-row;
8 |
9 | &.wc-even {
10 | background-color: $bg-row-even;
11 | }
12 |
13 | &.wc-odd {
14 | background-color: $bg-row-odd;
15 | }
16 | &.wc-head-row {
17 | background-color: $bg-datagrid-head;
18 | }
19 |
20 | &.wc-selected {
21 | color: $cr-datagrid-active !important;
22 | background-color: $bg-datagrid-active;
23 | }
24 | }
25 |
26 | .wc-table-col {
27 | box-sizing: border-box;
28 | display: flex;
29 | flex-direction: column;
30 | flex-grow: 0;
31 | flex-shrink: 0;
32 | justify-content: center;
33 | padding: 6rpx 10rpx !important;
34 | font-size: $sz-datagrid-th - 2rpx;
35 | line-height: 1.2;
36 | border-right: 1px solid transparent !important;
37 |
38 | &.wc-last {
39 | border-right: none;
40 | }
41 |
42 | &.wc-col-head {
43 | height: 100%;
44 | border-right: 1px solid $bg-datagrid-border !important;
45 | border-bottom: 1px solid $bg-datagrid-border !important;
46 | &.wc-last {
47 | border-right: none !important;
48 | }
49 | }
50 | }
51 |
52 | .wc-table-col.wc-nowrap {
53 | flex-wrap: nowrap;
54 | overflow: hidden;
55 | text-overflow: ellipsis;
56 | white-space: nowrap;
57 | }
58 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-row/index.ts:
--------------------------------------------------------------------------------
1 | import { registerClassComponent } from '@/sub/mixins/component';
2 | import type { RequireId } from '@/types/common';
3 | import type { TableRowComponentData, TableRowComponentProps } from '@/types/table';
4 | import type { MpEvent } from '@/types/view';
5 | import type { MpComponentProperties } from 'typescript-mp-component';
6 | import { MpComponent } from 'typescript-mp-component';
7 |
8 | class TableRowComponent extends MpComponent<
9 | TableRowComponentData,
10 | TableRowComponentProps
11 | > {
12 | properties: MpComponentProperties, TableRowComponent> = {
13 | value: {
14 | type: Object,
15 | observer() {
16 | this.computeIsSelected();
17 | }
18 | },
19 | maxIndex: Number,
20 | index: Number,
21 | state: {
22 | type: Object,
23 | observer() {
24 | this.computeIsSelected();
25 | }
26 | },
27 | direction: String,
28 | scope: String
29 | };
30 |
31 | initData: TableRowComponentData = {
32 | isSelected: false
33 | };
34 |
35 | attached() {
36 | this.computeIsSelected();
37 | }
38 |
39 | computeIsSelected() {
40 | this.setData({
41 | isSelected: !!this.data.state.selected?.includes(this.data.value?.id)
42 | });
43 | }
44 |
45 | emitInteractEvent(type: string, e: MpEvent, detail?: any) {
46 | if (this.data.state.type === 'head') {
47 | return;
48 | }
49 | const id = this.data.value.id;
50 | this.triggerEvent('interact', {
51 | type: type,
52 | id,
53 | detail: {
54 | type: e.currentTarget.dataset.type,
55 | colIndex: e.currentTarget.dataset.col ? parseInt(String(e.currentTarget.dataset.col)) : -1,
56 | ...(detail || {})
57 | }
58 | });
59 | }
60 | onJSONViewerToggle(e: Required>) {
61 | this.emitInteractEvent('onJSONViewerToggle', e, e.detail);
62 | }
63 |
64 | tapRow(e: MpEvent) {
65 | this.emitInteractEvent('tapRow', e);
66 | }
67 | longpressRow(e: MpEvent) {
68 | this.emitInteractEvent('longpressRow', e);
69 | }
70 |
71 | tapCell(e: MpEvent) {
72 | this.emitInteractEvent('tapCell', e);
73 | }
74 | longpressCell(e: MpEvent) {
75 | this.emitInteractEvent('longpressCell', e);
76 | }
77 | }
78 |
79 | registerClassComponent(TableRowComponent);
80 |
--------------------------------------------------------------------------------
/src/subpackage/components/table-row/index.wxml:
--------------------------------------------------------------------------------
1 |
4 |
8 | |
9 |
10 |
--------------------------------------------------------------------------------
/src/subpackage/components/tabs/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true
3 | }
--------------------------------------------------------------------------------
/src/subpackage/components/tabs/index.ts:
--------------------------------------------------------------------------------
1 | import { ToolMixin } from '@/sub/mixins/tool';
2 | import { registerClassComponent } from '@/sub/mixins/component';
3 | import type { MpComponentEvent, MpComponentProperties } from 'typescript-mp-component';
4 | import { MpComponent } from 'typescript-mp-component';
5 |
6 | interface Props {
7 | tabs: string[];
8 | size: 'normal' | 'small';
9 | active: number;
10 | outerClass: string;
11 | headScroll: boolean;
12 | bodyFill: boolean;
13 | direction: 'horizontal' | 'vertical';
14 | position: 'top' | 'left';
15 | }
16 |
17 | interface Data {
18 | toView: string;
19 | }
20 |
21 | class Tabs extends MpComponent {
22 | $mx = {
23 | Tool: new ToolMixin()
24 | };
25 | options = {
26 | multipleSlots: true
27 | };
28 | properties: MpComponentProperties = {
29 | tabs: {
30 | type: Array
31 | },
32 | size: {
33 | type: String,
34 | value: 'normal'
35 | },
36 | active: {
37 | type: Number,
38 | observer(val) {
39 | this.$mx.Tool.$forceData({
40 | toView: `tabTitle_${val}`
41 | });
42 | }
43 | },
44 | outerClass: String,
45 | headScroll: {
46 | type: Boolean,
47 | value: true
48 | },
49 | bodyFill: {
50 | type: Boolean,
51 | value: true
52 | },
53 | direction: {
54 | type: String,
55 | value: 'horizontal' // horizontal, vertical
56 | },
57 | position: {
58 | type: String,
59 | value: 'top' // top,left
60 | }
61 | };
62 | initData: Data = { toView: '' };
63 | tapTab(e: MpComponentEvent) {
64 | const index = parseInt(e.currentTarget.dataset.tab);
65 | this.triggerEvent('change', index);
66 | setTimeout(() => {
67 | if (index === parseInt(this.data.active)) {
68 | this.$mx.Tool.$forceData({
69 | toView: `tabTitle_${index}`
70 | });
71 | }
72 | });
73 | }
74 | }
75 |
76 | registerClassComponent(Tabs);
77 |
--------------------------------------------------------------------------------
/src/subpackage/components/tabs/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{item.name}}
11 |
12 |
13 |
14 |
15 |
16 |
17 | {{item.name}}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/subpackage/components/vl-item/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {
4 | "console-reader-item": "../console-reader-item/index",
5 | "table-row": "../table-row/index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/subpackage/components/vl-item/index.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weimob-tech/WeConsole/d7abc3d0abae4e9919231c13ea18d21a453a7d52/src/subpackage/components/vl-item/index.scss
--------------------------------------------------------------------------------
/src/subpackage/components/vl-item/index.ts:
--------------------------------------------------------------------------------
1 | import { registerClassComponent } from '@/sub/mixins/component';
2 | import type { RequireId } from '@/types/common';
3 | import type { MpComponentProperties } from 'typescript-mp-component';
4 | import { MpComponent } from 'typescript-mp-component';
5 | import type { MpVirtualListItemComponentProps } from '@cross-virtual-list/types';
6 |
7 | class VlItemComponent extends MpComponent<
8 | NonNullable,
9 | MpVirtualListItemComponentProps
10 | > {
11 | properties: MpComponentProperties, VlItemComponent> = {
12 | value: Object,
13 | maxIndex: Number,
14 | index: Number,
15 | state: Object,
16 | direction: String,
17 | scope: String
18 | };
19 |
20 | emitInteract(e) {
21 | this.triggerEvent('interact', e.detail);
22 | }
23 | }
24 |
25 | registerClassComponent(VlItemComponent);
26 |
--------------------------------------------------------------------------------
/src/subpackage/components/vl-item/index.wxml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/src/subpackage/mixins/component.ts:
--------------------------------------------------------------------------------
1 | import type { MpComponent } from 'typescript-mp-component';
2 | import { toMpComponentConfig } from 'typescript-mp-component';
3 | import { makeSureCreatedPriorPropObserver } from './no-wx';
4 | import { rewriteAliSpec } from './ali';
5 |
6 | export const registerClassComponent = (constructor: new () => MpComponent) => {
7 | registerComponent(toMpComponentConfig(constructor));
8 | };
9 |
10 | export const registerComponent = (spec: any) => {
11 | spec.$wcDisabled = true;
12 | if (BUILD_TARGET !== 'wx') {
13 | makeSureCreatedPriorPropObserver(spec);
14 | }
15 | if (BUILD_TARGET === 'my') {
16 | rewriteAliSpec(spec);
17 | }
18 | Component(spec);
19 | };
20 |
--------------------------------------------------------------------------------
/src/subpackage/mixins/no-wx.ts:
--------------------------------------------------------------------------------
1 | import { nextTick } from 'cross-mp-power';
2 |
3 | /** 重写属性的Observer,确保created在它之前执行 */
4 | export const makeSureCreatedPriorPropObserver = (spec: any) => {
5 | if (spec.properties) {
6 | Object.keys(spec.properties).forEach((k) => {
7 | if (
8 | typeof spec.properties[k] === 'object' &&
9 | spec.properties[k] &&
10 | typeof spec.properties[k].observer === 'function'
11 | ) {
12 | const old = spec.properties[k].observer;
13 | spec.properties[k].observer = function observer(...args) {
14 | if (this.__createdIsFired__) {
15 | return old.apply(this, args);
16 | }
17 | this.__waitObserverQueue = this.__waitObserverQueue || [];
18 | this.__waitObserverQueue.push(() => {
19 | old.apply(this, args);
20 | });
21 | };
22 | }
23 | });
24 | spec.lifetimes = spec.lifetimes || {};
25 | const old = spec.lifetimes.created;
26 | spec.lifetimes.created = function created() {
27 | old?.call(this);
28 | nextTick(() => {
29 | this.__createdIsFired__ = true;
30 | if (this.__waitObserverQueue) {
31 | this.__waitObserverQueue.forEach((item) => {
32 | try {
33 | item();
34 | } catch (error) {
35 | console.error(error);
36 | }
37 | });
38 | delete this.__waitObserverQueue;
39 | }
40 | });
41 | };
42 | }
43 | };
44 |
--------------------------------------------------------------------------------
/src/subpackage/modules/category.ts:
--------------------------------------------------------------------------------
1 | import type { MpNameValue } from '@/types/common';
2 | import { HookScope } from '@/types/common';
3 | import type { MpProductCategoryGetter, MpUIConfig } from '@/types/config';
4 | import type { MpProduct } from '@/types/product';
5 |
6 | /**
7 | * 获取小程序Api数据原料的分类值
8 | */
9 | export const getCategoryValue = (product: Partial, runConfig?: MpUIConfig): string[] => {
10 | let res: string | string[] | undefined = product.category;
11 | if (runConfig && (runConfig.apiCategoryGetter || runConfig.consoleCategoryGetter)) {
12 | let getter;
13 | if (product.type === HookScope.Api && runConfig.apiCategoryGetter) {
14 | getter = runConfig.apiCategoryGetter;
15 | } else if (product.type === HookScope.Console && runConfig.consoleCategoryGetter) {
16 | getter = runConfig.consoleCategoryGetter;
17 | } else {
18 | getter = product.category;
19 | }
20 | const type = typeof getter;
21 | if (type === 'function') {
22 | res = (runConfig.apiCategoryGetter as MpProductCategoryGetter)(product);
23 | } else if (type === 'object' && runConfig.apiCategoryGetter?.[product.category as string]) {
24 | if (typeof runConfig.apiCategoryGetter[product.category as string] === 'function') {
25 | res = runConfig.apiCategoryGetter[product.category as string](product);
26 | } else {
27 | res = String(runConfig.apiCategoryGetter[product.category as string]);
28 | }
29 | } else {
30 | res = getter as string;
31 | }
32 | }
33 | return Array.isArray(res) && res.length ? res : [!res ? 'other' : (res as string)];
34 | };
35 |
36 | /**
37 | * 获取小程序Api数据原料的分类信息列表
38 | */
39 | export const getApiCategoryList = (runConfig?: MpUIConfig) => {
40 | const res: Required>[] = [
41 | {
42 | name: 'All',
43 | value: 'all'
44 | },
45 | {
46 | name: 'Mark',
47 | value: 'mark'
48 | }
49 | ];
50 | if (runConfig && Array.isArray(runConfig.apiCategoryList) && runConfig.apiCategoryList.length) {
51 | runConfig.apiCategoryList.forEach((item) => {
52 | if (typeof item === 'string' && item) {
53 | if (!res.some((it) => it.value === item)) {
54 | res.push({
55 | name: item,
56 | value: item
57 | });
58 | }
59 | } else if (item && (item as MpNameValue).value) {
60 | if (!res.some((it) => it.value === (item as MpNameValue).value)) {
61 | res.push(item as Required>);
62 | }
63 | }
64 | });
65 | }
66 | if (!res.some((item) => item.value === 'other')) {
67 | res.push({
68 | name: 'Other',
69 | value: 'other'
70 | });
71 | }
72 | return res;
73 | };
74 |
--------------------------------------------------------------------------------
/src/subpackage/modules/cookie.ts:
--------------------------------------------------------------------------------
1 | import type { MpCookie } from '@/types/common';
2 |
3 | export const parseCookie = (content: string): MpCookie => {
4 | const arr = content.split(';');
5 | const [name, val] = arr[0].split('=');
6 | const res: MpCookie = {
7 | name,
8 | value: val || ''
9 | };
10 | // TODO:解析其他属性
11 | return res;
12 | };
13 |
--------------------------------------------------------------------------------
/src/subpackage/modules/cross.ts:
--------------------------------------------------------------------------------
1 | import { registerComponent } from '../mixins/component';
2 | export const RegisterCrossComponent = (config: any) => {
3 | registerComponent(config);
4 | };
5 |
--------------------------------------------------------------------------------
/src/subpackage/modules/rect.ts:
--------------------------------------------------------------------------------
1 | import { log } from '@/main/modules/util';
2 | import { selectBoundingClientRect, type CrossMpClientRect } from 'cross-mp-power';
3 |
4 | export const getBoundingClientRect = (ctx: any, selector: string, retryCount = 3): Promise => {
5 | return new Promise((resolve, reject) => {
6 | const fire = () => {
7 | selectBoundingClientRect({
8 | selector,
9 | ctx,
10 | retryCount,
11 | retryDelay: 200
12 | })
13 | .then(resolve)
14 | .catch((err) => {
15 | if (ctx.$wcComponentIsDestroyed) {
16 | const err = new Error(
17 | ctx.$wcComponentIsDestroyed
18 | ? `组件已被销毁,无法获取元素${selector}的boundingClientRect`
19 | : `无法找到元素${selector}进而获取其boundingClientRect`
20 | );
21 | log('log', err);
22 | return reject(err);
23 | }
24 | reject(err);
25 | });
26 | };
27 | fire();
28 | });
29 | };
30 |
--------------------------------------------------------------------------------
/src/subpackage/modules/storage-reader.ts:
--------------------------------------------------------------------------------
1 | import type { MpStorageMaterial } from '@/types/product';
2 | import type { AnyFunction } from '@/types/util';
3 | import { uuid } from '@mpkit/util';
4 | import { clearStorage, getStorage, getStorageInfo, removeStorage } from 'cross-mp-power';
5 | import type { CrossMpStorageInfo } from 'cross-mp-power';
6 |
7 | export const getStorageInfoAndList = (): Promise<[CrossMpStorageInfo, MpStorageMaterial[]]> => {
8 | return getStorageInfo()
9 | .then((res) => {
10 | return Promise.all([res].concat(res.keys.map((key) => getStorageMaterial(key)) as any[]));
11 | })
12 | .then((res) => {
13 | return [res.splice(0, 1)[0], res as unknown as MpStorageMaterial[]];
14 | });
15 | };
16 |
17 | export const getStorageMaterial = (key: string, toString = true): Promise => {
18 | return getStorage(key).then((res) => {
19 | return {
20 | id: uuid(),
21 | key,
22 | value: typeof res === 'string' ? res : toString ? JSON.stringify(res) : res
23 | };
24 | });
25 | };
26 |
27 | export const filterClearStorage = (ignore?: AnyFunction): Promise => {
28 | if (!ignore) {
29 | return clearStorage();
30 | }
31 | return getStorageInfo()
32 | .then((res) => {
33 | return res.keys.map((item) => {
34 | if (ignore(item)) {
35 | return Promise.resolve();
36 | } else {
37 | return removeStorage(item);
38 | }
39 | });
40 | })
41 | .then(() => {});
42 | };
43 |
--------------------------------------------------------------------------------
/src/types/api-reader.ts:
--------------------------------------------------------------------------------
1 | import type { TableCol } from './table';
2 | export interface MpApiReaderComponentData {
3 | rowHeight: number;
4 | detailMaterialId?: string;
5 | detailFrom?: string;
6 | detailTab: number;
7 | readerCols: TableCol[];
8 | affixed: string[];
9 | }
10 |
--------------------------------------------------------------------------------
/src/types/common.ts:
--------------------------------------------------------------------------------
1 | export interface MpStackInfo {
2 | original: string;
3 | lineNumebr?: number;
4 | column?: number;
5 | /** 文件路径 */
6 | fileName?: string;
7 | /** 执行目标,如:Object.keys, obj.show, print */
8 | target?: string;
9 | /** 执行方法名称,如:keys, obj, print */
10 | method?: string;
11 | /** 执行方法归属名称,如:Object, obj */
12 | ascription?: string;
13 | }
14 |
15 | export const enum MethodExecStatus {
16 | Executed = 1,
17 | Success = 2,
18 | Fail = 3
19 | }
20 |
21 | export interface MpMaterialCategoryMap {
22 | [prop: string]: T[];
23 | }
24 |
25 | export const enum HookScope {
26 | App = 'App',
27 | Page = 'Page',
28 | Component = 'Component',
29 | Api = 'Api',
30 | Console = 'Console',
31 | AppMethod = 'AppMethod',
32 | PageMethod = 'PageMethod',
33 | ComponentMethod = 'ComponentMethod'
34 | }
35 | export const enum MpComponentMethodSeat {
36 | methods = 'methods',
37 | pageLifetimes = 'pageLifetimes',
38 | lifetimes = 'lifetimes',
39 | propObserver = 'propObserver',
40 | observers = 'observers'
41 | }
42 |
43 | export interface RequireId {
44 | id: T;
45 | }
46 |
47 | export interface MpNameValue {
48 | name: T;
49 | value?: V;
50 | }
51 |
52 | export interface MpInitiator {
53 | type: string;
54 | fileName?: string;
55 | method?: string;
56 | lineNumber?: number;
57 | column?: number;
58 | }
59 |
60 | export interface MpDetailKV extends MpNameValue {
61 | decodedValue?: string | number;
62 | remark?: string;
63 | }
64 |
65 | export interface MpCookie {
66 | name: string;
67 | value: string;
68 | domain?: string;
69 | path?: string;
70 | expires?: string;
71 | maxAge?: number;
72 | size?: number;
73 | httpOnly?: boolean;
74 | secure?: boolean;
75 | }
76 |
--------------------------------------------------------------------------------
/src/types/config.ts:
--------------------------------------------------------------------------------
1 | import type { MpView } from '@mpkit/types';
2 | import type { MpNameValue } from './common';
3 | import type { WcCustomAction } from './other';
4 | import type { MpProduct } from './product';
5 |
6 | export type MpProductCategoryGetter = (product: Partial) => string | string[];
7 |
8 | /** 取数据的category字段值对应的prop */
9 | export interface MpProductCategoryMap {
10 | [prop: string]: string | MpProductCategoryGetter;
11 | }
12 |
13 | export interface MpProductCopyPolicy {
14 | (product: Partial);
15 | }
16 |
17 | export interface MpUIConfig {
18 | /** 监控小程序API数据后,使用该选项进行该数据的分类值计算,计算后的结果显示在界面上 */
19 | apiCategoryGetter?: MpProductCategoryMap | MpProductCategoryGetter;
20 | /** 监控Console数据后,使用该选项进行该数据的分类值计算,计算后的结果显示在界面上 */
21 | consoleCategoryGetter?: MpProductCategoryMap | MpProductCategoryGetter;
22 | currentPageGetter?: () => MpView;
23 | /** API选项卡下显示的数据分类列表,all、mark、other 分类固定存在 */
24 | apiCategoryList?: Array>;
25 | /** 复制策略,传入复制数据,可通过数据的type字段判断数据哪种类型,比如api/console */
26 | copyPolicy?: MpProductCopyPolicy;
27 | /** 定制化列表 */
28 | customActions?: WcCustomAction[];
29 | /** 默认的api分类值 */
30 | apiDefaultCategoryValue?: string;
31 | /** 默认的console分类值 */
32 | consoleDefaultCategoryValue?: string;
33 | /** 不监控这些API,也就是说这些API调用后不会在【API】选项卡中显示 */
34 | ignoreHookApiNames?: string[];
35 | /** 只监控这些API,也就是除了这些API以外的其他调用都不会在【API】选项卡中显示 */
36 | onlyHookApiNames?: string[];
37 | /** 多页面状态同步是否开启?开启后,将同步更新多个页面的weconsole组件状态(显示隐藏等),会增加性能损耗! */
38 | multiplePageStateEnabled?: boolean;
39 | /** 全局对象,如果你的小程序存在沙盒环境,请务必传递一个可供全局存储数据的单例对象 */
40 | globalObject?: any;
41 | componentPagesGetter?: () => any[];
42 | }
43 |
--------------------------------------------------------------------------------
/src/types/console-reader.ts:
--------------------------------------------------------------------------------
1 | import type { MpConsoleMaterial } from './product';
2 | export interface MpConsoleReaderComponentData {
3 | selfHash: string;
4 | itemMinSize: number;
5 | affixList: MpConsoleMaterial[];
6 | selectRowId: string;
7 | }
8 |
--------------------------------------------------------------------------------
/src/types/element.ts:
--------------------------------------------------------------------------------
1 | export interface MpNode {
2 | name: string;
3 | }
4 | export interface MpAttrNode extends MpNode {
5 | content?: string;
6 | }
7 | export interface MpElement extends MpNode {
8 | id: string;
9 | attrs: MpAttrNode[];
10 | hasChild?: boolean;
11 | children?: MpElement[];
12 | open?: boolean;
13 | path?: string[];
14 | }
15 |
--------------------------------------------------------------------------------
/src/types/hook.ts:
--------------------------------------------------------------------------------
1 | import type { MkFuncHook } from '@mpkit/types';
2 | import type { HookScope } from './common';
3 | import type { MpProduct } from './product';
4 | import type { AnyFunction, IEventEmitter, WcListFilterHandler } from './util';
5 |
6 | export type MpProductFilter = WcListFilterHandler;
7 |
8 | export interface IMpProductController extends IEventEmitter {
9 | findById: (id: string) => MpProduct | undefined;
10 | remove: (id: string) => void;
11 | clear: (type: HookScope, keepSaveIdList?: string[]) => void;
12 | getList: (type: HookScope, filter?: MpProductFilter) => MpProduct[];
13 | create: (data: Partial & Required>) => MpProduct;
14 | change: (data: Partial & Required>) => MpProduct;
15 | }
16 |
17 | export interface IHooker {
18 | replace: () => any;
19 | restore: () => any;
20 | readonly scope: HookScope;
21 | readonly hooks: MkFuncHook[];
22 | readonly target?: AnyFunction;
23 | }
24 |
25 | export interface WeFuncHookState {
26 | id: string;
27 | funcName: string;
28 | scope: HookScope;
29 | product: MpProduct;
30 | controller: IMpProductController;
31 | hookApiCallback?: boolean;
32 | }
33 |
--------------------------------------------------------------------------------
/src/types/json-viewer.ts:
--------------------------------------------------------------------------------
1 | import type { MpNameValue } from './common';
2 | import type { JSONChunk, JSONNode } from './json';
3 |
4 | export const enum MpJSONViewerComponentMode {
5 | full = 1,
6 | tree = 2,
7 | string = 3
8 | }
9 |
10 | export interface MpJSONViewerComponentData {
11 | root: JSONNode | JSONChunk | null;
12 | JSONString?: string;
13 | activeTab?: 0 | 1;
14 | tabs: MpNameValue[];
15 | }
16 | export interface MpJSONViewerComponentProps {
17 | target: any;
18 | from: string;
19 | json: any;
20 | init: boolean;
21 | mode: MpJSONViewerComponentMode;
22 | fontSize: number;
23 | smallFontSize: number;
24 | outerClass: string;
25 | title?: string;
26 | }
27 | export interface MpJSONViewerComponentEventDetail {
28 | path: string[];
29 | open: boolean;
30 | fromCompute?: boolean;
31 | }
32 |
--------------------------------------------------------------------------------
/src/types/json.ts:
--------------------------------------------------------------------------------
1 | export const enum JSONType {
2 | num = 'num',
3 | bigint = 'bigint',
4 | symbol = 'symbol',
5 | bool = 'bool',
6 | undefined = 'undefined',
7 | string = 'string',
8 | null = 'null',
9 | object = 'object',
10 | ellipsis = 'ellipsis',
11 | compute = 'compute',
12 | func = 'func'
13 | }
14 |
15 | export type JSONPropPath = Array;
16 |
17 | export interface JSONChunk {
18 | type?: JSONType;
19 | leftBoundary?: string;
20 | rightBoundary?: string;
21 | remark?: string;
22 | className?: string;
23 | content?: T;
24 | /** 受保护的? */
25 | protected?: boolean;
26 | }
27 |
28 | export interface JSONNode extends JSONChunk {
29 | node: true;
30 | type: JSONType;
31 | open?: boolean;
32 | // eslint-disable-next-line no-use-before-define
33 | tree?: JSONTree;
34 | empty?: boolean;
35 | }
36 | export interface JSONComma extends JSONChunk {
37 | comma: true;
38 | }
39 | export interface JSONProp extends JSONChunk {
40 | prop: true;
41 | }
42 | export interface JSONValue extends JSONNode {
43 | value: true;
44 | path?: JSONPropPath;
45 | }
46 | export interface JSONRow {
47 | row: true;
48 | path: JSONPropPath;
49 | prop?: JSONProp;
50 | value?: JSONValue;
51 | // eslint-disable-next-line no-use-before-define
52 | tree?: JSONTree;
53 | }
54 |
55 | export type MeasureTextHandler = (str: string, fontSize: number) => number;
56 |
57 | export interface JSONViewerOptions {
58 | fontSize: number;
59 | keyFontSize: number;
60 | maxWidth: number;
61 | target: T;
62 | arrowWidth: number;
63 | measureText: MeasureTextHandler;
64 | }
65 |
66 | export type GlobalObjectConstructorNames =
67 | | 'Number'
68 | | 'Object'
69 | | 'Array'
70 | | 'BigInt'
71 | | 'Boolean'
72 | | 'String'
73 | | 'Symbol'
74 | | 'Date'
75 | | 'Map'
76 | | 'Set';
77 |
78 | export interface JSONWord {
79 | fontSize: number;
80 | word: string;
81 | width?: number;
82 | }
83 |
84 | export type JSONPropFilter = (prop: string | symbol, desc: PropertyDescriptor, index: number) => boolean;
85 | export interface JSONPropDesc {
86 | prop: string | symbol;
87 | desc: PropertyDescriptor;
88 | }
89 |
90 | export type JSONItem = JSONChunk | JSONNode | JSONRow | JSONComma | JSONProp | JSONValue;
91 | export type JSONMeasureTextHandler = (str: string | JSONItem, maxWidth?: number) => number;
92 | export type JSONTree = Array;
93 |
94 | export interface IJSONViewer {
95 | readonly options: JSONViewerOptions;
96 | measureText: JSONMeasureTextHandler;
97 | replaceJSONPropPath: (path: JSONPropPath) => string[];
98 | restoreJSONPropPath: (path: string[]) => JSONPropPath;
99 | setTarget: (target?: any) => any;
100 | getPathPropWidth: (path?: JSONPropPath) => number;
101 | getWords: (str: string | JSONItem, maxWidth?: number, readyWidth?: number) => JSONWord[];
102 | getJSONNode: (path?: JSONPropPath, maxWidth?: number) => JSONNode;
103 | getJSONTree: (path?: JSONPropPath) => JSONTree;
104 | }
105 |
--------------------------------------------------------------------------------
/src/types/other.ts:
--------------------------------------------------------------------------------
1 | import type { DynamicTableComponentExports, RegularTableComponentExports, TableCol } from './table';
2 | import type { AnyFunction } from './util';
3 |
4 | /** 定制化 */
5 |
6 | export const enum WcCustomActionShowMode {
7 | /** 显示JSON树 */
8 | json = 'json',
9 | /** 显示数据表格 */
10 | grid = 'grid',
11 | /** 固定显示组件,该组件需要在app.json中注册,同时需要支持传入data属性,属性值就是case handler执行后的结果 */
12 | component = 'component',
13 | /** 显示一段文本 */
14 | text = 'text',
15 | /** 什么都不做 */
16 | none = 'none'
17 | }
18 |
19 | export interface WcCustomActionCase {
20 | id: string;
21 | title?: string;
22 | /** 按钮文案 */
23 | button?: string;
24 | /** 执行逻辑 */
25 | handler: AnyFunction;
26 | /** 显示方式 */
27 | showMode?: WcCustomActionShowMode;
28 | }
29 |
30 | export interface WcCustomActionGrid {
31 | /** 列配置 */
32 | cols: TableCol[];
33 | /** 行数据唯一key字段名 */
34 | rowKeyField?: string;
35 | /** 行高,rowHeightMode=dynamic时代表最小行高 */
36 | rowHeight: number;
37 | /** 行高模式:
38 | * regular=固定高度;
39 | * dynamic=动态高度;
40 | */
41 | rowHeightMode: 'regular' | 'dynamic';
42 | /** 列最小宽度,单位:% */
43 | colMinWidth: number;
44 | /** 完全自主控制数据的设置等 */
45 | autonomy?: boolean;
46 | data?: T[];
47 | onReady?: (grid: RegularTableComponentExports | DynamicTableComponentExports) => void;
48 | }
49 |
50 | export interface WcCustomActionComponent {
51 | name: string;
52 | data?: any;
53 | }
54 |
55 | export interface WcCustomAction {
56 | /** 标识,需要保持唯一 */
57 | id: string;
58 | /** 标题 */
59 | title?: string;
60 | /** 默认执行哪个case? */
61 | autoCase?: string;
62 | /** 该定制化有哪些情况 */
63 | cases: WcCustomActionCase[];
64 | }
65 |
--------------------------------------------------------------------------------
/src/types/product.ts:
--------------------------------------------------------------------------------
1 | import type { HookScope, MethodExecStatus, MpCookie, MpDetailKV, MpStackInfo, RequireId } from './common';
2 | import type { TableCell } from './table';
3 |
4 | export interface MpProduct {
5 | id: string;
6 | /** 大类 */
7 | type: HookScope;
8 | /** 小类 */
9 | category?: string;
10 | request?: any[];
11 | time: number;
12 | status: MethodExecStatus;
13 | endTime?: number;
14 | response?: any[];
15 | execEndTime?: number;
16 | result?: any;
17 | eventTriggerPid?: string;
18 | eventHandlePid?: string;
19 | eventTriggerView?: any;
20 | stack?: MpStackInfo[];
21 | }
22 |
23 | export interface MpMaterial extends RequireId {
24 | /** 分类 */
25 | categorys?: string[];
26 | /** 索引字符串,可用于搜索 */
27 | indexs?: string[];
28 | }
29 |
30 | export interface MpApiMaterial extends MpMaterial {
31 | code?: number | string;
32 | name?: string | TableCell;
33 | category?: string;
34 | method?: string;
35 | nameDesc?: string;
36 | status: string | TableCell;
37 | statusDesc?: string;
38 | startTime?: number;
39 | endTime?: number;
40 | time?: TableCell;
41 | initiator?: string;
42 | initiatorDesc?: string;
43 | rowStyle?: string;
44 | }
45 |
46 | export interface MpConsoleMaterialItem {
47 | type: 'str' | 'nail' | 'num' | 'fun' | 'bool' | 'json' | 'br' | 'division';
48 | index: number;
49 | content?: string;
50 | }
51 |
52 | export interface MpConsoleMaterial extends MpMaterial {
53 | items?: MpConsoleMaterialItem[];
54 | method: string;
55 | }
56 |
57 | export interface MpApiDetail {
58 | id: string;
59 | general: MpDetailKV[];
60 | requestHeaders?: MpDetailKV[];
61 | responseHeaders?: MpDetailKV[];
62 | queryString?: string;
63 | queryStringParameters?: MpDetailKV[];
64 | formData?: MpDetailKV[];
65 | cookies?: MpCookie[];
66 | stack?: MpDetailKV[];
67 | originalRequestData?: any;
68 | response?: string;
69 | // arguments
70 | // requestRayload
71 | }
72 |
73 | export interface MpStorageMaterial extends MpMaterial {
74 | key: string;
75 | value: any;
76 | }
77 |
--------------------------------------------------------------------------------
/src/types/reader-state.ts:
--------------------------------------------------------------------------------
1 | import type { IMpProductController } from './hook';
2 |
3 | export interface MpReaderProductIdMap {
4 | [prop: string]: 1;
5 | }
6 |
7 | export interface MpReaderState {
8 | productIdList: string[];
9 | productIdMap: Record;
10 | keepSaveMap: Record;
11 | markMap: Record;
12 | topList: string[];
13 | state: any;
14 | }
15 |
16 | export type ProductControllerGetter = () => IMpProductController | Promise;
17 |
--------------------------------------------------------------------------------
/src/types/reader.ts:
--------------------------------------------------------------------------------
1 | import type { MpNameValue } from './common';
2 | import type { MpMaterial, MpProduct } from './product';
3 |
4 | export const enum MpDataReaderAction {
5 | /** 留存 */
6 | keepSave = 1,
7 | /** 置顶 */
8 | top = 2,
9 | /** 标记 */
10 | mark = 4,
11 | /** 取消全部标记 */
12 | cancelAllMark = 6,
13 | /** 取消全部留存 */
14 | cancelAllKeepSave = 7,
15 | /** 分类为... */
16 | groupTo = 8,
17 | /** 复制,内容按reader的实现 */
18 | copy = 9
19 | }
20 |
21 | export type MpDataReaderActionTextGetter = (
22 | action: MpDataReaderAction,
23 | id: string,
24 | material?: T,
25 | product?: MpProduct
26 | ) => string;
27 |
28 | export interface MpDataReaderComponentData {
29 | categoryList: Required>[];
30 | activeCategory: string;
31 | materialActions?: MpDataReaderAction[];
32 | }
33 |
--------------------------------------------------------------------------------
/src/types/scope.ts:
--------------------------------------------------------------------------------
1 | import type { Hooker } from '@/main/modules/hooker';
2 | import type { MpProductController } from '@/main/modules/controller';
3 | import type { MpUIConfig } from './config';
4 | import type { AnyFunction } from './util';
5 |
6 | export interface WeConsoleScopeSingleMap {
7 | /** 数据监控控制器 */
8 | ProductController?: MpProductController;
9 | HookerList?: Hooker[];
10 | /** 小程序App/Page/Component实例 */
11 | MpViewInstances?: any[];
12 | }
13 |
14 | export const enum WeConsoleEvents {
15 | /** UIConfig对象发生变化时 */
16 | WcUIConfigChange = 'WcUIConfigChange',
17 | /** 入口图标显示性发生变化时 */
18 | WcVisibleChange = 'WcVisibleChange',
19 | /** CanvasContext准备好时,CanvasContext用于JSON树组件的界面文字宽度计算 */
20 | WcCanvasContextReady = 'WcCanvasContextReady',
21 | WcCanvasContextFail = 'WcCanvasContextFail',
22 | /** CanvasContext销毁时 */
23 | WcCanvasContextDestory = 'WcCanvasContextDestory',
24 | /** 主组件的宽高发生变化时 */
25 | WcMainComponentSizeChange = 'WcMainComponentSizeChange'
26 | }
27 | export interface WeConsoleScope {
28 | /** 是否显示WeConsole入口 */
29 | visible?: boolean;
30 | /** UI配置 */
31 | UIConfig?: MpUIConfig;
32 | SingleMapPromise?: {
33 | [prop: string]: AnyFunction[];
34 | };
35 | SingleMap?: WeConsoleScopeSingleMap;
36 | /** 公用Canvas Context */
37 | CanvasContext?: any;
38 | CanvasContextFail?: boolean;
39 | apiCallMark?: string;
40 | pagePlusId?: number;
41 | }
42 |
--------------------------------------------------------------------------------
/src/types/util.ts:
--------------------------------------------------------------------------------
1 | export interface EventHandler {
2 | (type: string, data?: T);
3 | }
4 | export interface IEventEmitter {
5 | on: (type: string, handler: EventHandler) => any;
6 | once: (type: string, handler: EventHandler) => any;
7 | off: (type: string, handler?: EventHandler) => any;
8 | emit: (type: string, data?: T) => any;
9 | destory: () => any;
10 | }
11 |
12 | export type WcListFilterHandler = (item: T, index: number, list: T[]) => any;
13 |
14 | export type AnyFunction = (...args: any[]) => any;
15 | export type AnyClass = new (...args: any[]) => any;
16 |
17 | export type EmptyObject = Record;
18 |
19 | export type AnyObject = Record;
20 |
--------------------------------------------------------------------------------
/src/types/view.ts:
--------------------------------------------------------------------------------
1 | export interface MpEventTarget {
2 | dataset: {
3 | [prop: string]: any;
4 | };
5 | }
6 | export interface MpEvent {
7 | type: string;
8 | target: MpEventTarget;
9 | currentTarget: MpEventTarget;
10 | detail?: T;
11 | }
12 |
--------------------------------------------------------------------------------
/tsconfig-base.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/tsconfig",
3 | "compilerOptions": {
4 | "baseUrl": ".",
5 | "rootDir": ".",
6 | "moduleResolution": "Node",
7 | "allowJs": false,
8 | "strictNullChecks": true,
9 | "downlevelIteration": true,
10 | "skipLibCheck": true,
11 | "module": "CommonJS",
12 | "target": "es2022",
13 | "types": [],
14 | "typeRoots": [],
15 | "paths": {
16 | "@/types/*": ["src/types/*"],
17 | "@/main/*": ["src/main/*"],
18 | "@/sub/*": ["src/subpackage/*"]
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tsconfig-eslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig-base.json",
3 | "include": ["./*.js", "./src/**/*.wxs", "./build/**/*.js", "./scripts/**/*.ts", "./src/**/*.ts"]
4 | }
5 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig-base.json",
3 | "compilerOptions": {
4 | "lib": ["ES2020", "DOM"]
5 | },
6 | "include": ["src/**/*.ts"],
7 | "exclude": ["node_modules", "dist"]
8 | }
9 |
--------------------------------------------------------------------------------