Merge remote-tracking branch 'origin/main'
¶Ô±ÈÐÂÎļþ |
| | |
| | | const fs = require('fs') |
| | | const path = require('path') |
| | | const { execSync } = require('child_process') |
| | | |
| | | const scopes = fs |
| | | .readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true }) |
| | | .filter((dirent) => dirent.isDirectory()) |
| | | .map((dirent) => dirent.name.replace(/s$/, '')) |
| | | |
| | | // precomputed scope |
| | | const scopeComplete = execSync('git status --porcelain || true') |
| | | .toString() |
| | | .trim() |
| | | .split('\n') |
| | | .find((r) => ~r.indexOf('M src')) |
| | | ?.replace(/(\/)/g, '%%') |
| | | ?.match(/src%%((\w|-)*)/)?.[1] |
| | | ?.replace(/s$/, '') |
| | | |
| | | module.exports = { |
| | | ignores: [(commit) => commit.includes('init')], |
| | | extends: ['@commitlint/config-conventional'], |
| | | rules: { |
| | | 'body-leading-blank': [2, 'always'], |
| | | 'footer-leading-blank': [1, 'always'], |
| | | 'header-max-length': [2, 'always', 108], |
| | | 'subject-empty': [2, 'never'], |
| | | 'type-empty': [2, 'never'], |
| | | 'subject-case': [0], |
| | | 'type-enum': [ |
| | | 2, |
| | | 'always', |
| | | [ |
| | | 'feat', |
| | | 'fix', |
| | | 'perf', |
| | | 'style', |
| | | 'docs', |
| | | 'test', |
| | | 'refactor', |
| | | 'build', |
| | | 'ci', |
| | | 'chore', |
| | | 'revert', |
| | | 'wip', |
| | | 'workflow', |
| | | 'types', |
| | | 'release', |
| | | ], |
| | | ], |
| | | }, |
| | | prompt: { |
| | | /** @use `pnpm commit :f` */ |
| | | alias: { |
| | | f: 'docs: fix typos', |
| | | r: 'docs: update README', |
| | | s: 'style: update code format', |
| | | b: 'build: bump dependencies', |
| | | c: 'chore: update config', |
| | | }, |
| | | customScopesAlign: !scopeComplete ? 'top' : 'bottom', |
| | | defaultScope: scopeComplete, |
| | | scopes: [...scopes, 'mock'], |
| | | allowEmptyIssuePrefixs: false, |
| | | allowCustomIssuePrefixs: false, |
| | | |
| | | // English |
| | | typesAppend: [ |
| | | { value: 'wip', name: 'wip: work in process' }, |
| | | { value: 'workflow', name: 'workflow: workflow improvements' }, |
| | | { value: 'types', name: 'types: type definition file changes' }, |
| | | ], |
| | | |
| | | // ä¸è±æå¯¹ç
§ç |
| | | // messages: { |
| | | // type: 'éæ©ä½ è¦æäº¤çç±»å :', |
| | | // scope: 'éæ©ä¸ä¸ªæäº¤èå´ (å¯é):', |
| | | // customScope: '请è¾å
¥èªå®ä¹çæäº¤èå´ :', |
| | | // subject: 'å¡«åç®çç²¾ç¼çåæ´æè¿° :\n', |
| | | // body: 'å¡«åæ´å 详ç»çåæ´æè¿° (å¯é)ãä½¿ç¨ "|" æ¢è¡ :\n', |
| | | // breaking: 'å举éå
¼å®¹æ§é大çåæ´ (å¯é)ãä½¿ç¨ "|" æ¢è¡ :\n', |
| | | // footerPrefixsSelect: 'éæ©å
³èissueåç¼ (å¯é):', |
| | | // customFooterPrefixs: 'è¾å
¥èªå®ä¹issueåç¼ :', |
| | | // footer: 'å举å
³èissue (å¯é) ä¾å¦: #31, #I3244 :\n', |
| | | // confirmCommit: 'æ¯å¦æäº¤æä¿®æ¹commit ?', |
| | | // }, |
| | | // types: [ |
| | | // { value: 'feat', name: 'feat: æ°å¢åè½' }, |
| | | // { value: 'fix', name: 'fix: ä¿®å¤ç¼ºé·' }, |
| | | // { value: 'docs', name: 'docs: ææ¡£åæ´' }, |
| | | // { value: 'style', name: 'style: ä»£ç æ ¼å¼' }, |
| | | // { value: 'refactor', name: 'refactor: 代ç éæ' }, |
| | | // { value: 'perf', name: 'perf: æ§è½ä¼å' }, |
| | | // { value: 'test', name: 'test: æ·»å çæ¼æµè¯æå·²ææµè¯æ¹å¨' }, |
| | | // { value: 'build', name: 'build: æå»ºæµç¨ãå¤é¨ä¾èµåæ´ (å¦å级 npm å
ãä¿®æ¹æå
é
ç½®ç)' }, |
| | | // { value: 'ci', name: 'ci: ä¿®æ¹ CI é
ç½®ãèæ¬' }, |
| | | // { value: 'revert', name: 'revert: åæ» commit' }, |
| | | // { value: 'chore', name: 'chore: 对æå»ºè¿ç¨æè¾
å©å·¥å
·ååºçæ´æ¹ (ä¸å½±åæºæä»¶ãæµè¯ç¨ä¾)' }, |
| | | // { value: 'wip', name: 'wip: æ£å¨å¼åä¸' }, |
| | | // { value: 'workflow', name: 'workflow: 工使µç¨æ¹è¿' }, |
| | | // { value: 'types', name: 'types: ç±»åå®ä¹æä»¶ä¿®æ¹' }, |
| | | // ], |
| | | // emptyScopesAlias: 'empty: ä¸å¡«å', |
| | | // customScopesAlias: 'custom: èªå®ä¹', |
| | | }, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | root = true |
| | | |
| | | [*] # è¡¨ç¤ºæææä»¶éç¨ |
| | | charset = utf-8 # 设置æä»¶å符é为 utf-8 |
| | | indent_style = space # 缩è¿é£æ ¼ï¼tab | spaceï¼ |
| | | indent_size = 2 # 缩è¿å¤§å° |
| | | end_of_line = lf # æ§å¶æ¢è¡ç±»å(lf | cr | crlf) |
| | | trim_trailing_whitespace = true # å»é¤è¡é¦çä»»æç©ºç½å符 |
| | | insert_final_newline = true # å§ç»å¨æä»¶æ«å°¾æå
¥ä¸ä¸ªæ°è¡ |
| | | |
| | | [*.md] # 表示ä»
md æä»¶éç¨ä»¥ä¸è§å |
| | | max_line_length = off # å
³éæå¤§è¡é¿åº¦éå¶ |
| | | trim_trailing_whitespace = false # å
³éæ«å°¾ç©ºæ ¼ä¿®åª |
¶Ô±ÈÐÂÎļþ |
| | |
| | | src/uni_modules/ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "globals": { |
| | | "Component": true, |
| | | "ComponentPublicInstance": true, |
| | | "ComputedRef": true, |
| | | "EffectScope": true, |
| | | "ExtractDefaultPropTypes": true, |
| | | "ExtractPropTypes": true, |
| | | "ExtractPublicPropTypes": true, |
| | | "InjectionKey": true, |
| | | "PropType": true, |
| | | "Ref": true, |
| | | "VNode": true, |
| | | "WritableComputedRef": true, |
| | | "computed": true, |
| | | "createApp": true, |
| | | "customRef": true, |
| | | "defineAsyncComponent": true, |
| | | "defineComponent": true, |
| | | "effectScope": true, |
| | | "getCurrentInstance": true, |
| | | "getCurrentScope": true, |
| | | "h": true, |
| | | "inject": true, |
| | | "isProxy": true, |
| | | "isReactive": true, |
| | | "isReadonly": true, |
| | | "isRef": true, |
| | | "markRaw": true, |
| | | "nextTick": true, |
| | | "onActivated": true, |
| | | "onAddToFavorites": true, |
| | | "onBackPress": true, |
| | | "onBeforeMount": true, |
| | | "onBeforeUnmount": true, |
| | | "onBeforeUpdate": true, |
| | | "onDeactivated": true, |
| | | "onError": true, |
| | | "onErrorCaptured": true, |
| | | "onHide": true, |
| | | "onLaunch": true, |
| | | "onLoad": true, |
| | | "onMounted": true, |
| | | "onNavigationBarButtonTap": true, |
| | | "onNavigationBarSearchInputChanged": true, |
| | | "onNavigationBarSearchInputClicked": true, |
| | | "onNavigationBarSearchInputConfirmed": true, |
| | | "onNavigationBarSearchInputFocusChanged": true, |
| | | "onPageNotFound": true, |
| | | "onPageScroll": true, |
| | | "onPullDownRefresh": true, |
| | | "onReachBottom": true, |
| | | "onReady": true, |
| | | "onRenderTracked": true, |
| | | "onRenderTriggered": true, |
| | | "onResize": true, |
| | | "onScopeDispose": true, |
| | | "onServerPrefetch": true, |
| | | "onShareAppMessage": true, |
| | | "onShareTimeline": true, |
| | | "onShow": true, |
| | | "onTabItemTap": true, |
| | | "onThemeChange": true, |
| | | "onUnhandledRejection": true, |
| | | "onUnload": true, |
| | | "onUnmounted": true, |
| | | "onUpdated": true, |
| | | "provide": true, |
| | | "reactive": true, |
| | | "readonly": true, |
| | | "ref": true, |
| | | "resolveComponent": true, |
| | | "shallowReactive": true, |
| | | "shallowReadonly": true, |
| | | "shallowRef": true, |
| | | "toRaw": true, |
| | | "toRef": true, |
| | | "toRefs": true, |
| | | "toValue": true, |
| | | "triggerRef": true, |
| | | "unref": true, |
| | | "useAttrs": true, |
| | | "useCssModule": true, |
| | | "useCssVars": true, |
| | | "useRequest": true, |
| | | "useSlots": true, |
| | | "useUpload": true, |
| | | "useUpload2": true, |
| | | "watch": true, |
| | | "watchEffect": true, |
| | | "watchPostEffect": true, |
| | | "watchSyncEffect": true, |
| | | "DirectiveBinding": true, |
| | | "MaybeRef": true, |
| | | "MaybeRefOrGetter": true, |
| | | "onWatcherCleanup": true, |
| | | "useId": true, |
| | | "useModel": true, |
| | | "useTemplateRef": true |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | module.exports = { |
| | | env: { |
| | | browser: true, |
| | | es2021: true, |
| | | node: true, |
| | | }, |
| | | extends: [ |
| | | 'eslint:recommended', |
| | | 'plugin:@typescript-eslint/recommended', |
| | | 'plugin:vue/vue3-essential', |
| | | // eslint-plugin-import æä»¶ï¼ @see https://www.npmjs.com/package/eslint-plugin-import |
| | | 'plugin:import/recommended', |
| | | // eslint-config-airbnb-base æä»¶ å·²ç»æ¹ç¨ eslint-config-standard æä»¶ |
| | | 'standard', |
| | | // 1. æ¥å
¥ prettier çè§å |
| | | 'prettier', |
| | | 'plugin:prettier/recommended', |
| | | './.eslintrc-auto-import.json', |
| | | ], |
| | | overrides: [ |
| | | { |
| | | env: { |
| | | node: true, |
| | | }, |
| | | files: ['.eslintrc.{js,cjs}'], |
| | | parserOptions: { |
| | | sourceType: 'script', |
| | | }, |
| | | }, |
| | | ], |
| | | parserOptions: { |
| | | ecmaVersion: 'latest', |
| | | parser: '@typescript-eslint/parser', |
| | | sourceType: 'module', |
| | | }, |
| | | plugins: [ |
| | | '@typescript-eslint', |
| | | 'vue', |
| | | // 2. å å
¥ prettier ç eslint æä»¶ |
| | | 'prettier', |
| | | // eslint-import-resolver-typescript æä»¶ï¼@see https://www.npmjs.com/package/eslint-import-resolver-typescript |
| | | 'import', |
| | | ], |
| | | rules: { |
| | | // 3. 注æè¦å ä¸è¿ä¸å¥ï¼å¼å¯ prettier èªå¨ä¿®å¤çåè½ |
| | | 'prettier/prettier': 'error', |
| | | // turn on errors for missing imports |
| | | 'import/no-unresolved': 'off', |
| | | // 对åç¼çæ£æµï¼å¦å import ä¸ä¸ªtsæä»¶ä¹ä¼æ¥éï¼éè¦æå¨æ·»å '.ts', å¢å äºä¸é¢çé
ç½®åå°±ä¸ç¨äº |
| | | 'import/extensions': [ |
| | | 'error', |
| | | 'ignorePackages', |
| | | { js: 'never', jsx: 'never', ts: 'never', tsx: 'never' }, |
| | | ], |
| | | // åªå
许1个é»è®¤å¯¼åºï¼å
³éï¼å¦åä¸è½éæexport xxx |
| | | 'import/prefer-default-export': ['off'], |
| | | 'no-console': ['off'], |
| | | // 'no-unused-vars': ['off'], |
| | | // '@typescript-eslint/no-unused-vars': ['off'], |
| | | // è§£å³vite.config.tsæ¥éé®é¢ |
| | | 'import/no-extraneous-dependencies': 'off', |
| | | 'no-plusplus': 'off', |
| | | 'no-shadow': 'off', |
| | | 'vue/multi-word-component-names': 'off', |
| | | 'vue/no-unused-vars': 'off', |
| | | '@typescript-eslint/no-explicit-any': 'off', |
| | | 'no-underscore-dangle': 'off', |
| | | 'no-use-before-define': 'off', |
| | | 'no-undef': 'off', |
| | | 'no-unused-vars': 'off', |
| | | 'no-param-reassign': 'off', |
| | | '@typescript-eslint/no-unused-vars': 'off', |
| | | // é¿å
`eslint` å¯¹äº `typescript` 彿°éè½½çè¯¯æ¥ |
| | | 'no-redeclare': 'off', |
| | | '@typescript-eslint/no-redeclare': 'error', |
| | | }, |
| | | // eslint-import-resolver-typescript æä»¶ï¼@see https://www.npmjs.com/package/eslint-import-resolver-typescript |
| | | settings: { |
| | | 'import/parsers': { |
| | | '@typescript-eslint/parser': ['.ts', '.tsx'], |
| | | }, |
| | | 'import/resolver': { |
| | | typescript: {}, |
| | | }, |
| | | }, |
| | | globals: { |
| | | $t: true, |
| | | uni: true, |
| | | UniApp: true, |
| | | wx: true, |
| | | WechatMiniprogram: true, |
| | | getCurrentPages: true, |
| | | UniHelper: true, |
| | | Page: true, |
| | | App: true, |
| | | NodeJS: true, |
| | | }, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # registry = https://registry.npmjs.org |
| | | registry = https://registry.npmmirror.com |
| | | |
| | | strict-peer-dependencies=false |
| | | auto-install-peers=true |
| | | shamefully-hoist=true |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # unplugin-auto-import çæçç±»åæä»¶ï¼æ¯æ¬¡æäº¤é½æ¹åï¼æä»¥å å
¥è¿éå§ï¼ä¸ .gitignore é
åä½¿ç¨ |
| | | auto-import.d.ts |
| | | |
| | | # vite-plugin-uni-pages çæçç±»åæä»¶ï¼æ¯æ¬¡åæ¢åæ¯é½ä¸å ä¸åçï¼æä»¥ç´æ¥ .gitignore |
| | | uni-pages.d.ts |
| | | |
| | | # æä»¶çæçæä»¶ |
| | | src/pages.json |
| | | src/manifest.json |
| | | |
| | | # 忽ç¥èªå¨çææä»¶ |
| | | src/service/app/** |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // @see https://prettier.io/docs/en/options |
| | | module.exports = { |
| | | singleQuote: true, |
| | | printWidth: 100, |
| | | tabWidth: 2, |
| | | useTabs: false, |
| | | semi: false, |
| | | trailingComma: 'all', |
| | | endOfLine: 'auto', |
| | | htmlWhitespaceSensitivity: 'ignore', |
| | | overrides: [ |
| | | { |
| | | files: '*.json', |
| | | options: { |
| | | trailingComma: 'none', |
| | | }, |
| | | }, |
| | | ], |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | src/uni_modules/ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // .stylelintrc.cjs |
| | | |
| | | module.exports = { |
| | | root: true, |
| | | extends: [ |
| | | // stylelint-config-standard æ¿æ¢æäºæ´å®½æ¾ç stylelint-config-recommended |
| | | 'stylelint-config-recommended', |
| | | // stylelint-config-standard-scss æ¿æ¢æäºæ´å®½æ¾ç stylelint-config-recommended-scss |
| | | 'stylelint-config-recommended-scss', |
| | | 'stylelint-config-recommended-vue/scss', |
| | | 'stylelint-config-html/vue', |
| | | 'stylelint-config-recess-order', |
| | | ], |
| | | plugins: ['stylelint-prettier'], |
| | | overrides: [ |
| | | // æ«æ .vue/html æä»¶ä¸ç<style>æ ç¾å
çæ ·å¼ |
| | | { |
| | | files: ['**/*.{vue,html}'], |
| | | customSyntax: 'postcss-html', |
| | | }, |
| | | { |
| | | files: ['**/*.{css,scss}'], |
| | | customSyntax: 'postcss-scss', |
| | | }, |
| | | ], |
| | | // èªå®ä¹è§å |
| | | rules: { |
| | | 'prettier/prettier': true, |
| | | // å
许 global ãexport ãv-deepç伪类 |
| | | 'selector-pseudo-class-no-unknown': [ |
| | | true, |
| | | { |
| | | ignorePseudoClasses: ['global', 'export', 'v-deep', 'deep'], |
| | | }, |
| | | ], |
| | | 'unit-no-unknown': [ |
| | | true, |
| | | { |
| | | ignoreUnits: ['rpx'], |
| | | }, |
| | | ], |
| | | // å¤çå°ç¨åºpageæ ç¾ä¸è®¤è¯çé®é¢ |
| | | 'selector-type-no-unknown': [ |
| | | true, |
| | | { |
| | | ignoreTypes: ['page'], |
| | | }, |
| | | ], |
| | | 'comment-empty-line-before': 'never', // never|always|always-multi-line|never-multi-line |
| | | 'custom-property-empty-line-before': 'never', |
| | | 'no-empty-source': null, |
| | | 'comment-no-empty': null, |
| | | 'no-duplicate-selectors': null, |
| | | 'scss/comment-no-empty': null, |
| | | 'selector-class-pattern': null, |
| | | 'font-family-no-missing-generic-family-keyword': null, |
| | | }, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | MIT License |
| | | |
| | | Copyright (c) 2024 è²é¸½ |
| | | |
| | | Permission is hereby granted, free of charge, to any person obtaining a copy |
| | | of this software and associated documentation files (the "Software"), to deal |
| | | in the Software without restriction, including without limitation the rights |
| | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| | | copies of the Software, and to permit persons to whom the Software is |
| | | furnished to do so, subject to the following conditions: |
| | | |
| | | The above copyright notice and this permission notice shall be included in all |
| | | copies or substantial portions of the Software. |
| | | |
| | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| | | SOFTWARE. |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <p align="center"> |
| | | <a href="https://github.com/feige996/unibest"> |
| | | <img width="160" src="./src/static/logo.svg"> |
| | | </a> |
| | | </p> |
| | | |
| | | <h1 align="center"> |
| | | <a href="https://github.com/feige996/unibest" target="_blank">unibest - æå¥½ç uniapp å¼åæ¡æ¶</a> |
| | | </h1> |
| | | |
| | | <div align="center"> |
| | | æ§ä»åº codercup è¿ä¸å»äºï¼star 乿¿ä¸åæ¥ï¼è¿éä¹å±ç¤ºä¸ä¸é£ä¸ªå°åç star. |
| | | |
| | | [](https://github.com/codercup/unibest) |
| | | [](https://github.com/codercup/unibest) |
| | | |
| | | </div> |
| | | |
| | | <div align="center"> |
| | | |
| | | [](https://github.com/feige996/unibest) |
| | | [](https://github.com/feige996/unibest) |
| | | [](https://gitee.com/feige996/unibest/stargazers) |
| | | [](https://gitee.com/feige996/unibest/members) |
| | |  |
| | |  |
| | |  |
| | |  |
| | | |
| | | </div> |
| | | |
| | | `unibest` ââ æå¥½ç `uniapp` å¼å模æ¿ï¼ç± `uniapp` + `Vue3` + `Ts` + `Vite5` + `UnoCss` + `wot-ui` + `z-paging` ææï¼ä½¿ç¨äºææ°çåç«¯ææ¯æ ï¼æ éä¾é `HBuilderX`ï¼éè¿å½ä»¤è¡æ¹å¼è¿è¡ `web`ã`å°ç¨åº` å `App`ï¼ç¼è¾å¨æ¨è `VSCode`ï¼å¯é `webstorm`ï¼ã |
| | | |
| | | `unibest` å
ç½®äº `约å®å¼è·¯ç±`ã`layoutå¸å±`ã`请æ±å°è£
`ã`è¯·æ±æ¦æª`ã`ç»å½æ¦æª`ã`UnoCSS`ã`i18nå¤è¯è¨` çåºç¡åè½ï¼æä¾äº `ä»£ç æç¤º`ã`èªå¨æ ¼å¼å`ã`ç»ä¸é
ç½®`ã`代ç çæ®µ` çè¾
å©åè½ï¼è®©ä½ ç¼å `uniapp` æ¥æ `best` ä½éª ï¼ `unibest çç±æ¥`ï¼ã |
| | | |
| | |  |
| | | |
| | | <p align="center"> |
| | | <a href="https://unibest.tech/" target="_blank">ð ææ¡£å°å(new)</a> |
| | | <span style="margin:0 10px;">|</span> |
| | | <a href="https://feige996.github.io/hello-unibest/" target="_blank">ð± DEMO å°å</a> |
| | | </p> |
| | | |
| | | --- |
| | | |
| | | æ³¨ææ§çå°å [codercup](https://github.com/codercup/unibest) æè¿ä¸å»äºï¼ä½¿ç¨æ°ç [feige996](https://github.com/feige996/unibest)ãPRå issue ä¹è¯·ä½¿ç¨æ°å°åï¼å¦åæ æ³åå¹¶ã |
| | | |
| | | ## å¹³å°å
¼å®¹æ§ |
| | | |
| | | | H5 | IOS | å®å | 微信å°ç¨åº | åèå°ç¨åº | å¿«æå°ç¨åº | æ¯ä»å®å°ç¨åº | ééå°ç¨åº | ç¾åº¦å°ç¨åº | |
| | | | --- | --- | ---- | ---------- | ---------- | ---------- | ------------ | ---------- | ---------- | |
| | | | â | â | â | â | â | â | â | â | â | |
| | | |
| | | æ³¨ææ¯ç§ `UIæ¡æ¶` æ¯æç平尿æä¸åï¼è¯¦æ
请çå `UIæ¡æ¶` çå®ç½ï¼ä¹å¯ä»¥ç `unibest` ææ¡£ã |
| | | |
| | | ## âï¸ ç¯å¢ |
| | | |
| | | - node>=18 |
| | | - pnpm>=7.30 |
| | | - Vue Official>=2.1.10 |
| | | - TypeScript>=5.0 |
| | | |
| | | ## 📂 å¿«éå¼å§ |
| | | |
| | | æ§è¡ `pnpm create unibest` åå»ºé¡¹ç® |
| | | |
| | | æ§è¡ `pnpm i` å®è£
ä¾èµ |
| | | |
| | | æ§è¡ `pnpm dev` è¿è¡ `H5` |
| | | |
| | | ## ð¦ è¿è¡ï¼æ¯æçæ´æ°ï¼ |
| | | |
| | | - webå¹³å°ï¼ `pnpm dev:h5`, ç¶åæå¼ [http://localhost:9000/](http://localhost:9000/)ã |
| | | - weixinå¹³å°ï¼`pnpm dev:mp-weixin` ç¶åæå¼å¾®ä¿¡å¼åè
å·¥å
·ï¼å¯¼å
¥æ¬å°æä»¶å¤¹ï¼éæ©æ¬é¡¹ç®ç`dist/dev/mp-weixin` æä»¶ã |
| | | - APPå¹³å°ï¼`pnpm dev:app`, ç¶åæå¼ `HBuilderX`ï¼å¯¼å
¥ååçæç`dist/dev/app` æä»¶å¤¹ï¼éæ©è¿è¡å°æ¨¡æå¨(å¼åæ¶ä¼å
使ç¨)ï¼æè
è¿è¡çå®å/iosåºåº§ã |
| | | |
| | | ## ð åå¸ |
| | | |
| | | - webå¹³å°ï¼ `pnpm build:h5`ï¼æå
åçæä»¶å¨ `dist/build/h5`ï¼å¯ä»¥æ¾å°webæå¡å¨ï¼å¦nginxè¿è¡ã妿æç»ä¸æ¯æ¾å¨æ ¹ç®å½ï¼å¯ä»¥å¨ `manifest.config.ts` æä»¶ç `h5.router.base` 屿§è¿è¡ä¿®æ¹ã |
| | | - weixinå¹³å°ï¼`pnpm build:mp-weixin`, æå
åçæä»¶å¨ `dist/build/mp-weixin`ï¼ç¶åéè¿å¾®ä¿¡å¼åè
å·¥å
·å¯¼å
¥ï¼å¹¶ç¹å»å³ä¸è§çâä¸ä¼ âæé®è¿è¡ä¸ä¼ ã |
| | | - APPå¹³å°ï¼`pnpm build:app`, ç¶åæå¼ `HBuilderX`ï¼å¯¼å
¥ååçæç`dist/build/app` æä»¶å¤¹ï¼éæ©åè¡ - APPäºæå
ã |
| | | |
| | | ## ð License |
| | | |
| | | [MIT](https://opensource.org/license/mit/) |
| | | |
| | | Copyright (c) 2025 è²é¸½ |
| | | |
| | | ## æèµ |
| | | |
| | | <p align='center'> |
| | | <img alt="special sponsor appwrite" src="./screenshots/pay-1.png" height="330" style="display:inline-block; height:330px;"> |
| | | <img alt="special sponsor appwrite" src="./screenshots/pay-2.png" height="330" style="display:inline-block; height:330px; margin-left:10px;"> |
| | | </p> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | VITE_APP_TITLE = 'å
°å®è®¾å¤ç®¡ç' |
| | | VITE_APP_PORT = 9000 |
| | | |
| | | VITE_UNI_APPID = 'H5F0B095D' |
| | | VITE_WX_APPID = '' |
| | | |
| | | # h5é¨ç½²ç½ç«çbaseï¼é
ç½®å° manifest.config.ts éç h5.router.base |
| | | VITE_APP_PUBLIC_BASE=/ |
| | | |
| | | VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run' |
| | | VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' |
| | | |
| | | # æäºåå¦å¯è½éè¦å¨å¾®ä¿¡å°ç¨åºé颿 ¹æ® developãtrialãrelease åå«è®¾ç½®ä¸ä¼ å°åï¼åè代ç å¦ä¸ã |
| | | # ä¸é¢çåéå¦ææ²¡æè®¾ç½®ï¼ä¼é»è®¤ä½¿ç¨ VITE_SERVER_BASEURL or VITE_UPLOAD_BASEURL |
| | | VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run' |
| | | VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run' |
| | | VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run' |
| | | |
| | | VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run/upload' |
| | | VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run/upload' |
| | | VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run/upload' |
| | | |
| | | # h5æ¯å¦éè¦é
置代ç |
| | | VITE_APP_PROXY=false |
| | | VITE_APP_PROXY_PREFIX = '/api' |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # åéå¿
须以 VITE_ 为åç¼æè½æ´é²ç»å¤é¨è¯»å |
| | | NODE_ENV = 'development' |
| | | # æ¯å¦å»é¤console å debugger |
| | | VITE_DELETE_CONSOLE = false |
| | | # æ¯å¦å¼å¯sourcemap |
| | | VITE_SHOW_SOURCEMAP = true |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # åéå¿
须以 VITE_ 为åç¼æè½æ´é²ç»å¤é¨è¯»å |
| | | NODE_ENV = 'development' |
| | | # æ¯å¦å»é¤console å debugger |
| | | VITE_DELETE_CONSOLE = true |
| | | # æ¯å¦å¼å¯sourcemap |
| | | VITE_SHOW_SOURCEMAP = false |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # åéå¿
须以 VITE_ 为åç¼æè½æ´é²ç»å¤é¨è¯»å |
| | | NODE_ENV = 'development' |
| | | # æ¯å¦å»é¤console å debugger |
| | | VITE_DELETE_CONSOLE = false |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <!doctype html> |
| | | <html build-time="%BUILD_TIME%"> |
| | | <head> |
| | | <meta charset="UTF-8" /> |
| | | <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> |
| | | <script> |
| | | var coverSupport = |
| | | 'CSS' in window && |
| | | typeof CSS.supports === 'function' && |
| | | (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) |
| | | document.write( |
| | | '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + |
| | | (coverSupport ? ', viewport-fit=cover' : '') + |
| | | '" />', |
| | | ) |
| | | </script> |
| | | <title>设å¤ç®¡çç³»ç»</title> |
| | | <!--preload-links--> |
| | | <!--app-context--> |
| | | </head> |
| | | |
| | | <body> |
| | | <div id="app"><!--app-html--></div> |
| | | <script type="module" src="/src/main.ts"></script> |
| | | </body> |
| | | </html> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // manifest.config.ts |
| | | import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest' |
| | | import path from 'node:path' |
| | | import { loadEnv } from 'vite' |
| | | |
| | | // è·åç¯å¢åéçèä¾ |
| | | const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env')) |
| | | const { |
| | | VITE_APP_TITLE, |
| | | VITE_UNI_APPID, |
| | | VITE_WX_APPID, |
| | | VITE_APP_PUBLIC_BASE, |
| | | VITE_FALLBACK_LOCALE, |
| | | } = env |
| | | |
| | | export default defineManifestConfig({ |
| | | name: VITE_APP_TITLE, |
| | | appid: VITE_UNI_APPID, |
| | | description: '', |
| | | versionName: '1.0.0', |
| | | versionCode: '100', |
| | | transformPx: false, |
| | | locale: VITE_FALLBACK_LOCALE, // 'zh-Hans' |
| | | h5: { |
| | | router: { |
| | | base: VITE_APP_PUBLIC_BASE, |
| | | }, |
| | | }, |
| | | /* 5+Appç¹æç¸å
³ */ |
| | | 'app-plus': { |
| | | usingComponents: true, |
| | | nvueStyleCompiler: 'uni-app', |
| | | compilerVersion: 3, |
| | | compatible: { |
| | | ignoreVersion: true, |
| | | }, |
| | | splashscreen: { |
| | | alwaysShowBeforeRender: true, |
| | | waiting: true, |
| | | autoclose: true, |
| | | delay: 0, |
| | | }, |
| | | /* 模åé
ç½® */ |
| | | modules: {}, |
| | | /* åºç¨åå¸ä¿¡æ¯ */ |
| | | distribute: { |
| | | /* androidæå
é
ç½® */ |
| | | android: { |
| | | minSdkVersion: 21, |
| | | targetSdkVersion: 30, |
| | | abiFilters: ['armeabi-v7a', 'arm64-v8a'], |
| | | permissions: [ |
| | | '<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>', |
| | | '<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>', |
| | | '<uses-permission android:name="android.permission.VIBRATE"/>', |
| | | '<uses-permission android:name="android.permission.READ_LOGS"/>', |
| | | '<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>', |
| | | '<uses-feature android:name="android.hardware.camera.autofocus"/>', |
| | | '<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>', |
| | | '<uses-permission android:name="android.permission.CAMERA"/>', |
| | | '<uses-permission android:name="android.permission.GET_ACCOUNTS"/>', |
| | | '<uses-permission android:name="android.permission.READ_PHONE_STATE"/>', |
| | | '<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>', |
| | | '<uses-permission android:name="android.permission.WAKE_LOCK"/>', |
| | | '<uses-permission android:name="android.permission.FLASHLIGHT"/>', |
| | | '<uses-feature android:name="android.hardware.camera"/>', |
| | | '<uses-permission android:name="android.permission.WRITE_SETTINGS"/>', |
| | | ], |
| | | }, |
| | | /* iosæå
é
ç½® */ |
| | | ios: {}, |
| | | /* SDKé
ç½® */ |
| | | sdkConfigs: {}, |
| | | /* 徿 é
ç½® */ |
| | | icons: { |
| | | android: { |
| | | hdpi: 'static/app/icons/72x72.png', |
| | | xhdpi: 'static/app/icons/96x96.png', |
| | | xxhdpi: 'static/app/icons/144x144.png', |
| | | xxxhdpi: 'static/app/icons/192x192.png', |
| | | }, |
| | | ios: { |
| | | appstore: 'static/app/icons/1024x1024.png', |
| | | ipad: { |
| | | app: 'static/app/icons/76x76.png', |
| | | 'app@2x': 'static/app/icons/152x152.png', |
| | | notification: 'static/app/icons/20x20.png', |
| | | 'notification@2x': 'static/app/icons/40x40.png', |
| | | 'proapp@2x': 'static/app/icons/167x167.png', |
| | | settings: 'static/app/icons/29x29.png', |
| | | 'settings@2x': 'static/app/icons/58x58.png', |
| | | spotlight: 'static/app/icons/40x40.png', |
| | | 'spotlight@2x': 'static/app/icons/80x80.png', |
| | | }, |
| | | iphone: { |
| | | 'app@2x': 'static/app/icons/120x120.png', |
| | | 'app@3x': 'static/app/icons/180x180.png', |
| | | 'notification@2x': 'static/app/icons/40x40.png', |
| | | 'notification@3x': 'static/app/icons/60x60.png', |
| | | 'settings@2x': 'static/app/icons/58x58.png', |
| | | 'settings@3x': 'static/app/icons/87x87.png', |
| | | 'spotlight@2x': 'static/app/icons/80x80.png', |
| | | 'spotlight@3x': 'static/app/icons/120x120.png', |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | /* å¿«åºç¨ç¹æç¸å
³ */ |
| | | quickapp: {}, |
| | | /* å°ç¨åºç¹æç¸å
³ */ |
| | | 'mp-weixin': { |
| | | appid: VITE_WX_APPID, |
| | | setting: { |
| | | urlCheck: false, |
| | | }, |
| | | usingComponents: true, |
| | | // __usePrivacyCheck__: true, |
| | | }, |
| | | 'mp-alipay': { |
| | | usingComponents: true, |
| | | styleIsolation: 'shared', |
| | | }, |
| | | 'mp-baidu': { |
| | | usingComponents: true, |
| | | }, |
| | | 'mp-toutiao': { |
| | | usingComponents: true, |
| | | }, |
| | | uniStatistics: { |
| | | enable: false, |
| | | }, |
| | | vueVersion: '3', |
| | | }) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import type { GenerateServiceProps } from 'openapi-ts-request' |
| | | |
| | | export default [ |
| | | { |
| | | schemaPath: 'http://petstore.swagger.io/v2/swagger.json', |
| | | serversPath: './src/service/app', |
| | | requestLibPath: `import request from '@/utils/request';\n import { CustomRequestOptions } from '@/interceptors/request';`, |
| | | requestOptionsType: 'CustomRequestOptions', |
| | | isGenReactQuery: true, |
| | | reactQueryMode: 'vue', |
| | | isGenJavaScript: false, |
| | | }, |
| | | ] as GenerateServiceProps[] |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "name": "eims-ui-mobile", |
| | | "type": "commonjs", |
| | | "version": "2.5.5", |
| | | "description": "å
°å®è®¾å¤ç®¡ç", |
| | | "author": { |
| | | "name": "feige996", |
| | | "zhName": "è²é¸½", |
| | | "email": "1020103647@qq.com", |
| | | "github": "https://github.com/feige996", |
| | | "gitee": "https://gitee.com/feige996" |
| | | }, |
| | | "license": "MIT", |
| | | "repository": "https://github.com/feige996/unibest", |
| | | "repository-gitee": "https://gitee.com/feige996/unibest", |
| | | "repository-deprecated": "https://github.com/codercup/unibest", |
| | | "bugs": { |
| | | "url": "https://github.com/feige996/unibest/issues" |
| | | }, |
| | | "homepage": "https://feige996.github.io/unibest/", |
| | | "engines": { |
| | | "node": ">=18", |
| | | "pnpm": ">=7.30" |
| | | }, |
| | | "scripts": { |
| | | "preinstall": "npx only-allow pnpm", |
| | | "uvm": "npx @dcloudio/uvm@latest", |
| | | "uvm-rm": "node ./scripts/postupgrade.js", |
| | | "postuvm": "echo upgrade uni-app success!", |
| | | "dev:app": "uni -p app", |
| | | "dev:app-android": "uni -p app-android", |
| | | "dev:app-ios": "uni -p app-ios", |
| | | "dev:custom": "uni -p", |
| | | "dev": "uni", |
| | | "dev:h5": "uni", |
| | | "dev:h5:ssr": "uni --ssr", |
| | | "dev:mp": "uni -p mp-weixin", |
| | | "dev:mp-alipay": "uni -p mp-alipay", |
| | | "dev:mp-baidu": "uni -p mp-baidu", |
| | | "dev:mp-jd": "uni -p mp-jd", |
| | | "dev:mp-kuaishou": "uni -p mp-kuaishou", |
| | | "dev:mp-lark": "uni -p mp-lark", |
| | | "dev:mp-qq": "uni -p mp-qq", |
| | | "dev:mp-toutiao": "uni -p mp-toutiao", |
| | | "dev:mp-weixin": "uni -p mp-weixin", |
| | | "dev:mp-xhs": "uni -p mp-xhs", |
| | | "dev:quickapp-webview": "uni -p quickapp-webview", |
| | | "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", |
| | | "dev:quickapp-webview-union": "uni -p quickapp-webview-union", |
| | | "build:app": "uni build -p app", |
| | | "build:app-android": "uni build -p app-android", |
| | | "build:app-ios": "uni build -p app-ios", |
| | | "build:custom": "uni build -p", |
| | | "build:h5": "uni build", |
| | | "build": "uni build", |
| | | "build:h5:ssr": "uni build --ssr", |
| | | "build:mp-alipay": "uni build -p mp-alipay", |
| | | "build:mp": "uni build -p mp-weixin", |
| | | "build:mp-baidu": "uni build -p mp-baidu", |
| | | "build:mp-jd": "uni build -p mp-jd", |
| | | "build:mp-kuaishou": "uni build -p mp-kuaishou", |
| | | "build:mp-lark": "uni build -p mp-lark", |
| | | "build:mp-qq": "uni build -p mp-qq", |
| | | "build:mp-toutiao": "uni build -p mp-toutiao", |
| | | "build:mp-weixin": "uni build -p mp-weixin", |
| | | "build:mp-xhs": "uni build -p mp-xhs", |
| | | "build:quickapp-webview": "uni build -p quickapp-webview", |
| | | "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", |
| | | "build:quickapp-webview-union": "uni build -p quickapp-webview-union", |
| | | "prepare": "git init && husky install", |
| | | "type-check": "vue-tsc --noEmit", |
| | | "cz": "czg", |
| | | "openapi-ts-request": "openapi-ts" |
| | | }, |
| | | "lint-staged": { |
| | | "**/*.{html,vue,ts,cjs,json,md}": [ |
| | | "prettier --write" |
| | | ], |
| | | "**/*.{vue,js,ts,jsx,tsx}": [ |
| | | "eslint --cache --fix" |
| | | ], |
| | | "**/*.{vue,css,scss,html}": [ |
| | | "stylelint --fix" |
| | | ] |
| | | }, |
| | | "resolutions": { |
| | | "bin-wrapper": "npm:bin-wrapper-china" |
| | | }, |
| | | "dependencies": { |
| | | "@dcloudio/uni-app": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-app-harmony": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-app-plus": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-components": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-h5": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-alipay": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-baidu": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-jd": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-kuaishou": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-lark": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-qq": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-toutiao": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-weixin": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-mp-xhs": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-quickapp-webview": "3.0.0-4050720250324001", |
| | | "@tanstack/vue-query": "^5.62.16", |
| | | "abortcontroller-polyfill": "^1.7.8", |
| | | "dayjs": "1.11.10", |
| | | "pinia": "2.0.36", |
| | | "pinia-plugin-persistedstate": "3.2.1", |
| | | "qs": "6.5.3", |
| | | "vue": "3.4.21", |
| | | "vue-i18n": "^9.1.9", |
| | | "wot-design-uni": "^1.4.0", |
| | | "z-paging": "^2.8.4" |
| | | }, |
| | | "devDependencies": { |
| | | "@commitlint/cli": "^18.6.1", |
| | | "@commitlint/config-conventional": "^18.6.3", |
| | | "@dcloudio/types": "^3.4.14", |
| | | "@dcloudio/uni-automator": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-cli-shared": "3.0.0-4050720250324001", |
| | | "@dcloudio/uni-stacktracey": "3.0.0-4050720250324001", |
| | | "@dcloudio/vite-plugin-uni": "3.0.0-4050720250324001", |
| | | "@esbuild/darwin-arm64": "0.20.2", |
| | | "@esbuild/darwin-x64": "0.20.2", |
| | | "@iconify-json/carbon": "^1.2.4", |
| | | "@rollup/rollup-darwin-x64": "^4.28.0", |
| | | "@types/node": "^20.17.9", |
| | | "@types/wechat-miniprogram": "^3.4.8", |
| | | "@typescript-eslint/eslint-plugin": "^6.21.0", |
| | | "@typescript-eslint/parser": "^6.21.0", |
| | | "@uni-helper/uni-types": "1.0.0-alpha.3", |
| | | "@uni-helper/vite-plugin-uni-layouts": "^0.1.10", |
| | | "@uni-helper/vite-plugin-uni-manifest": "^0.2.7", |
| | | "@uni-helper/vite-plugin-uni-pages": "0.2.20", |
| | | "@uni-helper/vite-plugin-uni-platform": "^0.0.4", |
| | | "@unocss/preset-legacy-compat": "^0.59.4", |
| | | "@vue/runtime-core": "^3.5.13", |
| | | "@vue/tsconfig": "^0.1.3", |
| | | "autoprefixer": "^10.4.20", |
| | | "commitlint": "^18.6.1", |
| | | "czg": "^1.9.4", |
| | | "eslint": "^8.57.1", |
| | | "eslint-config-prettier": "^9.1.0", |
| | | "eslint-config-standard": "^17.1.0", |
| | | "eslint-import-resolver-typescript": "^3.7.0", |
| | | "eslint-plugin-import": "^2.31.0", |
| | | "eslint-plugin-prettier": "^5.2.1", |
| | | "eslint-plugin-vue": "^9.32.0", |
| | | "husky": "^8.0.3", |
| | | "lint-staged": "^15.2.10", |
| | | "openapi-ts-request": "^1.1.2", |
| | | "postcss": "^8.4.49", |
| | | "postcss-html": "^1.7.0", |
| | | "postcss-scss": "^4.0.9", |
| | | "rollup-plugin-visualizer": "^5.12.0", |
| | | "sass": "1.77.8", |
| | | "stylelint": "^16.11.0", |
| | | "stylelint-config-html": "^1.1.0", |
| | | "stylelint-config-recess-order": "^4.6.0", |
| | | "stylelint-config-recommended": "^14.0.1", |
| | | "stylelint-config-recommended-scss": "^14.1.0", |
| | | "stylelint-config-recommended-vue": "^1.5.0", |
| | | "stylelint-prettier": "^5.0.2", |
| | | "terser": "^5.36.0", |
| | | "typescript": "^5.7.2", |
| | | "unocss": "^0.58.9", |
| | | "unocss-applet": "^0.7.8", |
| | | "unplugin-auto-import": "^0.17.8", |
| | | "vite": "5.2.8", |
| | | "vite-plugin-restart": "^0.4.2", |
| | | "vue-tsc": "^1.8.27" |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages' |
| | | |
| | | export default defineUniPages({ |
| | | globalStyle: { |
| | | navigationStyle: 'default', |
| | | navigationBarTitleText: 'å
°å®è®¾å¤ç®¡ç', |
| | | navigationBarBackgroundColor: '#f8f8f8', |
| | | navigationBarTextStyle: 'black', |
| | | backgroundColor: '#FFFFFF', |
| | | }, |
| | | easycom: { |
| | | autoscan: true, |
| | | custom: { |
| | | // '^fg-(.*)': '@/components/fg-$1.vue', |
| | | '^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue', |
| | | '^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)': |
| | | 'z-paging/components/z-paging$1/z-paging$1.vue', |
| | | }, |
| | | }, |
| | | tabBar: { |
| | | custom: true, |
| | | color: '#999999', |
| | | selectedColor: '#007aff', |
| | | borderStyle: 'black', |
| | | height: '50px', |
| | | fontSize: '10px', |
| | | iconWidth: '24px', |
| | | spacing: '3px', |
| | | list: [ |
| | | // 注ætabbarè·¯ç±éè¦ä½¿ç¨ layout:tabbar å¸å± |
| | | { |
| | | pagePath: 'pages/home/index', |
| | | text: 'é¦é¡µ', |
| | | icon: 'home', |
| | | iconType: 'wot', |
| | | }, |
| | | { |
| | | pagePath: 'pages/equ/index', |
| | | text: '设å¤', |
| | | icon: 'mobile', |
| | | iconType: 'wot', |
| | | }, |
| | | { |
| | | pagePath: 'pages/equ/index', |
| | | icon: 'scan', |
| | | iconType: 'wot', |
| | | }, |
| | | // { |
| | | // pagePath: 'pages/my/index', |
| | | // text: 'æç', |
| | | // icon: '/static/logo.svg', |
| | | // iconType: 'local', |
| | | // }, |
| | | { |
| | | pagePath: 'pages/spare/index', |
| | | text: 'å¤ä»¶', |
| | | icon: 'setting1', |
| | | iconType: 'wot', |
| | | }, |
| | | { |
| | | pagePath: 'pages/my/index', |
| | | text: 'æç', |
| | | icon: 'user', |
| | | iconType: 'wot', |
| | | }, |
| | | // { |
| | | // pagePath: 'pages/my/index', |
| | | // text: 'æç', |
| | | // icon: 'iconfont icon-my', |
| | | // iconType: 'iconfont', |
| | | // }, |
| | | ], |
| | | }, |
| | | }) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // # æ§è¡ `pnpm upgrade` åä¼å级 `uniapp` ç¸å
³ä¾èµ |
| | | // # å¨å级å®åï¼ä¼èªå¨æ·»å å¾å¤æ ç¨ä¾èµï¼è¿éè¦å é¤ä»¥åå°ä¾èµå
ä½ç§¯ |
| | | // # åªéè¦æ§è¡ä¸é¢çå½ä»¤å³å¯ |
| | | |
| | | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| | | const { exec } = require('child_process') |
| | | |
| | | // å®ä¹è¦æ§è¡çå½ä»¤ |
| | | const dependencies = [ |
| | | '@dcloudio/uni-app-harmony', |
| | | // TODO: 妿éè¦æä¸ªå¹³å°çå°ç¨åºï¼è¯·æå¨å é¤ææ³¨éæ |
| | | '@dcloudio/uni-mp-alipay', |
| | | '@dcloudio/uni-mp-baidu', |
| | | '@dcloudio/uni-mp-jd', |
| | | '@dcloudio/uni-mp-kuaishou', |
| | | '@dcloudio/uni-mp-lark', |
| | | '@dcloudio/uni-mp-qq', |
| | | '@dcloudio/uni-mp-toutiao', |
| | | '@dcloudio/uni-mp-xhs', |
| | | '@dcloudio/uni-quickapp-webview', |
| | | // i18n模æ¿è¦æ³¨éæä¸é¢ç |
| | | 'vue-i18n', |
| | | ] |
| | | |
| | | // 使ç¨execæ§è¡å½ä»¤ |
| | | exec(`pnpm un ${dependencies.join(' ')}`, (error, stdout, stderr) => { |
| | | if (error) { |
| | | // 妿æéè¯¯ï¼æå°éè¯¯ä¿¡æ¯ |
| | | console.error(`æ§è¡åºé: ${error}`) |
| | | return |
| | | } |
| | | // æå°æ£å¸¸è¾åº |
| | | console.log(`stdout: ${stdout}`) |
| | | // 妿æé误è¾åºï¼ä¹æå°åºæ¥ |
| | | console.error(`stderr: ${stderr}`) |
| | | }) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <script setup lang="ts"> |
| | | import { onLaunch, onShow, onHide } from '@dcloudio/uni-app' |
| | | import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only' |
| | | |
| | | onLaunch(() => { |
| | | console.log('App Launch') |
| | | }) |
| | | onShow(() => { |
| | | console.log('App Show') |
| | | }) |
| | | onHide(() => { |
| | | console.log('App Hide') |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | /* stylelint-disable selector-type-no-unknown */ |
| | | button::after { |
| | | border: none; |
| | | } |
| | | |
| | | swiper, |
| | | scroll-view { |
| | | flex: 1; |
| | | height: 100%; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | image { |
| | | width: 100%; |
| | | height: 100%; |
| | | vertical-align: middle; |
| | | } |
| | | |
| | | // åè¡çç¥ï¼ä¼å
ä½¿ç¨ unocss: text-ellipsis |
| | | .ellipsis { |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | } |
| | | |
| | | // 两è¡çç¥ |
| | | .ellipsis-2 { |
| | | display: -webkit-box; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; |
| | | } |
| | | |
| | | // ä¸è¡çç¥ |
| | | .ellipsis-3 { |
| | | display: -webkit-box; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | -webkit-line-clamp: 3; |
| | | -webkit-box-orient: vertical; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <wd-tabbar |
| | | fixed |
| | | v-model="tabbarStore.curIdx" |
| | | bordered |
| | | safeAreaInsetBottom |
| | | placeholder |
| | | @change="selectTabBar" |
| | | active-color="#007aff" |
| | | inactive-color="#7d7e80" |
| | | > |
| | | <block v-for="(item, idx) in tabbarList" :key="item.path"> |
| | | <wd-tabbar-item |
| | | v-if="idx !== 2 && item.iconType === 'wot'" |
| | | :title="item.text" |
| | | :icon="item.icon" |
| | | ></wd-tabbar-item> |
| | | <!--TODO æ«ç 徿 ç¹æ®å¤ç--> |
| | | <wd-tabbar-item |
| | | v-if="idx === 2 && item.iconType === 'wot'" |
| | | :title="item.text" |
| | | :icon="item.icon" |
| | | > |
| | | <template #icon> |
| | | <view class="scan-box"> |
| | | <wd-icon round name="scan" color="white" size="42rpx"></wd-icon> |
| | | </view> |
| | | </template> |
| | | </wd-tabbar-item> |
| | | <wd-tabbar-item |
| | | v-else-if="item.iconType === 'unocss' || item.iconType === 'iconfont'" |
| | | :title="item.text" |
| | | > |
| | | <template #icon> |
| | | <view |
| | | h-40rpx |
| | | w-40rpx |
| | | :class="[item.icon, idx === tabbarStore.curIdx ? 'is-active' : 'is-inactive']" |
| | | ></view> |
| | | </template> |
| | | </wd-tabbar-item> |
| | | <wd-tabbar-item v-else-if="item.iconType === 'local'" :title="item.text"> |
| | | <template #icon> |
| | | <image :src="item.icon" h-40rpx w-40rpx /> |
| | | </template> |
| | | </wd-tabbar-item> |
| | | </block> |
| | | </wd-tabbar> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | // unocss icon é»è®¤ä¸çæï¼éè¦å¨è¿éåä¸éæè½çæï¼æ³¨éæä¹æ¯çæçï¼ä½æ¯å¿
é¡»è¦æï¼ |
| | | // i-carbon-code |
| | | import { tabBar } from '@/pages.json' |
| | | import { tabbarStore } from './tabbar' |
| | | |
| | | /** tabbarList éé¢ç path ä» pages.config.ts å¾å° */ |
| | | const tabbarList = tabBar.list.map((item) => ({ ...item, path: `/${item.pagePath}` })) |
| | | |
| | | function selectTabBar({ value: index }: { value: number }) { |
| | | const url = tabbarList[index].path |
| | | // scanç¹æ®å¤ç |
| | | if (index === 2) { |
| | | tabbarStore.setCurIdx(tabbarStore.lastIdx) |
| | | // åªå
许éè¿ç¸æºæ«ç |
| | | uni.scanCode({ |
| | | onlyFromCamera: true, |
| | | success: function (res) { |
| | | console.log('æ¡ç ç±»åï¼' + res.scanType) |
| | | console.log('æ¡ç å
容ï¼' + res.result) |
| | | }, |
| | | }) |
| | | } else { |
| | | tabbarStore.setCurIdx(index) |
| | | tabbarStore.setLastIdx(index) |
| | | uni.switchTab({ url }) |
| | | } |
| | | } |
| | | |
| | | onLoad(() => { |
| | | // è§£å³åç tabBar æªéèå¯¼è´æ2个 tabBar çé®é¢ |
| | | // #ifdef APP-PLUS | H5 |
| | | uni.hideTabBar({ |
| | | fail(err) { |
| | | console.log('hideTabBar fail: ', err) |
| | | }, |
| | | success(res) { |
| | | console.log('hideTabBar success: ', res) |
| | | }, |
| | | }) |
| | | // #endif |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .main-color { |
| | | color: $uni-color-primary; |
| | | } |
| | | .scan-box { |
| | | width: 100rpx; |
| | | height: 100rpx; |
| | | background-color: $uni-color-primary; |
| | | border-radius: 50%; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | z-index: 9999; |
| | | margin-bottom: 30rpx; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /** |
| | | * tabbar ç¶æï¼å¢å storageSync ä¿è¯å·æ°æµè§å¨æ¶å¨æ£ç¡®ç tabbar é¡µé¢ |
| | | * 使ç¨reactiveç®åç¶æï¼è䏿¯ pinia å
¨å±ç¶æ |
| | | */ |
| | | export const tabbarStore = reactive({ |
| | | curIdx: uni.getStorageSync('app-tabbar-index') || 0, |
| | | lastIdx: uni.getStorageSync('app-tabbar-lastIdx-index') || 0, |
| | | setCurIdx(idx: number) { |
| | | this.curIdx = idx |
| | | uni.setStorageSync('app-tabbar-index', idx) |
| | | }, |
| | | setLastIdx(idx: number) { |
| | | this.lastIdx = idx |
| | | uni.setStorageSync('app-tabbar-lastIdx-index', idx) |
| | | }, |
| | | }) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /// <reference types="vite/client" /> |
| | | /// <reference types="vite-svg-loader" /> |
| | | |
| | | declare module '*.vue' { |
| | | import { DefineComponent } from 'vue' |
| | | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types |
| | | const component: DefineComponent<{}, {}, any> |
| | | export default component |
| | | } |
| | | |
| | | interface ImportMetaEnv { |
| | | /** ç½ç«æ é¢ï¼åºç¨åç§° */ |
| | | readonly VITE_APP_TITLE: string |
| | | /** æå¡ç«¯å£å· */ |
| | | readonly VITE_SERVER_PORT: string |
| | | /** åå°æ¥å£å°å */ |
| | | readonly VITE_SERVER_BASEURL: string |
| | | /** H5æ¯å¦éè¦ä»£ç */ |
| | | readonly VITE_APP_PROXY: 'true' | 'false' |
| | | /** H5æ¯å¦éè¦ä»£çï¼éè¦çè¯æä¸ªåç¼ */ |
| | | readonly VITE_APP_PROXY_PREFIX: string // ä¸è¬æ¯/api |
| | | /** ä¸ä¼ å¾çå°å */ |
| | | readonly VITE_UPLOAD_BASEURL: string |
| | | /** æ¯å¦æ¸
é¤console */ |
| | | readonly VITE_DELETE_CONSOLE: string |
| | | // æ´å¤ç¯å¢åé... |
| | | } |
| | | |
| | | interface ImportMeta { |
| | | readonly env: ImportMetaEnv |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { UnwrapRef } from 'vue' |
| | | |
| | | type IUseRequestOptions<T> = { |
| | | /** æ¯å¦ç«å³æ§è¡ */ |
| | | immediate?: boolean |
| | | /** åå§åæ°æ® */ |
| | | initialData?: T |
| | | } |
| | | |
| | | /** |
| | | * useRequestæ¯ä¸ä¸ªå®å¶åç请æ±é©åï¼ç¨äºå¤ç弿¥è¯·æ±åååºã |
| | | * @param func ä¸ä¸ªæ§è¡å¼æ¥è¯·æ±ç彿°ï¼è¿åä¸ä¸ªå
å«ååºæ°æ®çPromiseã |
| | | * @param options å
å«è¯·æ±é项ç对象 {immediate, initialData}ã |
| | | * @param options.immediate æ¯å¦ç«å³æ§è¡è¯·æ±ï¼é»è®¤ä¸ºfalseã |
| | | * @param options.initialData åå§åæ°æ®ï¼é»è®¤ä¸ºundefinedã |
| | | * @returns è¿åä¸ä¸ªå¯¹è±¡{loading, error, data, run}ï¼å
å«è¯·æ±çå è½½ç¶æãé误信æ¯ãååºæ°æ®åæå¨è§¦å请æ±ç彿°ã |
| | | */ |
| | | export default function useRequest<T>( |
| | | func: () => Promise<IResData<T>>, |
| | | options: IUseRequestOptions<T> = { immediate: false }, |
| | | ) { |
| | | const loading = ref(false) |
| | | const error = ref(false) |
| | | const data = ref<T>(options.initialData) |
| | | const run = async () => { |
| | | loading.value = true |
| | | return func() |
| | | .then((res) => { |
| | | data.value = res.data as UnwrapRef<T> |
| | | error.value = false |
| | | return data.value |
| | | }) |
| | | .catch((err) => { |
| | | error.value = err |
| | | throw err |
| | | }) |
| | | .finally(() => { |
| | | loading.value = false |
| | | }) |
| | | } |
| | | |
| | | options.immediate && run() |
| | | return { loading, error, data, run } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // TODO: å«å¿å æ´æ¹ç¯å¢åéç VITE_UPLOAD_BASEURL å°åã |
| | | import { getEnvBaseUploadUrl } from '@/utils' |
| | | |
| | | const VITE_UPLOAD_BASEURL = `${getEnvBaseUploadUrl()}` |
| | | |
| | | /** |
| | | * useUpload æ¯ä¸ä¸ªå®å¶åç请æ±é©åï¼ç¨äºå¤çä¸ä¼ å¾çã |
| | | * @param formData é¢å¤ä¼ éç»åå°çæ°æ®ï¼å¦{name: 'è²é¸½'}ã |
| | | * @returns è¿åä¸ä¸ªå¯¹è±¡{loading, error, data, run}ï¼å
å«è¯·æ±çå è½½ç¶æãé误信æ¯ãååºæ°æ®åæå¨è§¦å请æ±ç彿°ã |
| | | */ |
| | | export default function useUpload<T = string>(formData: Record<string, any> = {}) { |
| | | const loading = ref(false) |
| | | const error = ref(false) |
| | | const data = ref<T>() |
| | | const run = () => { |
| | | // #ifdef MP-WEIXIN |
| | | // 微信å°ç¨åºä»åºç¡åº 2.21.0 å¼å§ï¼ wx.chooseImage åæ¢ç»´æ¤ï¼è¯·ä½¿ç¨ uni.chooseMedia 代æ¿ã |
| | | // 微信å°ç¨åºå¨2023å¹´10æ17æ¥ä¹åï¼ä½¿ç¨æ¬APIéè¦é
ç½®éç§åè®® |
| | | uni.chooseMedia({ |
| | | count: 1, |
| | | mediaType: ['image'], |
| | | success: (res) => { |
| | | loading.value = true |
| | | const tempFilePath = res.tempFiles[0].tempFilePath |
| | | uploadFile<T>({ tempFilePath, formData, data, error, loading }) |
| | | }, |
| | | fail: (err) => { |
| | | console.error('uni.chooseMedia err->', err) |
| | | error.value = true |
| | | }, |
| | | }) |
| | | // #endif |
| | | // #ifndef MP-WEIXIN |
| | | uni.chooseImage({ |
| | | count: 1, |
| | | success: (res) => { |
| | | loading.value = true |
| | | const tempFilePath = res.tempFilePaths[0] |
| | | uploadFile<T>({ tempFilePath, formData, data, error, loading }) |
| | | }, |
| | | fail: (err) => { |
| | | console.error('uni.chooseImage err->', err) |
| | | error.value = true |
| | | }, |
| | | }) |
| | | // #endif |
| | | } |
| | | |
| | | return { loading, error, data, run } |
| | | } |
| | | |
| | | function uploadFile<T>({ tempFilePath, formData, data, error, loading }) { |
| | | uni.uploadFile({ |
| | | url: VITE_UPLOAD_BASEURL, |
| | | filePath: tempFilePath, |
| | | name: 'file', |
| | | formData, |
| | | success: (uploadFileRes) => { |
| | | data.value = uploadFileRes.data as T |
| | | }, |
| | | fail: (err) => { |
| | | console.error('uni.uploadFile err->', err) |
| | | error.value = true |
| | | }, |
| | | complete: () => { |
| | | loading.value = false |
| | | }, |
| | | }) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | export { routeInterceptor } from './route' |
| | | export { requestInterceptor } from './request' |
| | | export { prototypeInterceptor } from './prototype' |
¶Ô±ÈÐÂÎļþ |
| | |
| | | export const prototypeInterceptor = { |
| | | install() { |
| | | // è§£å³ä½çæ¬ææºä¸è¯å« array.at() 导è´è¿è¡æ¥éçé®é¢ |
| | | if (typeof Array.prototype.at !== 'function') { |
| | | // eslint-disable-next-line no-extend-native |
| | | Array.prototype.at = function (index: number) { |
| | | if (index < 0) return this[this.length + index] |
| | | if (index >= this.length) return undefined |
| | | return this[index] |
| | | } |
| | | } |
| | | }, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable no-param-reassign */ |
| | | import qs from 'qs' |
| | | import { useUserStore } from '@/store' |
| | | import { platform } from '@/utils/platform' |
| | | import { getEnvBaseUrl } from '@/utils' |
| | | |
| | | export type CustomRequestOptions = UniApp.RequestOptions & { |
| | | query?: Record<string, any> |
| | | /** åºéæ¶æ¯å¦éèé误æç¤º */ |
| | | hideErrorToast?: boolean |
| | | } & IUniUploadFileOptions // æ·»å uni.uploadFileåæ°ç±»å |
| | | |
| | | // 请æ±åºåå°å |
| | | const baseUrl = getEnvBaseUrl() |
| | | |
| | | // æ¦æªå¨é
ç½® |
| | | const httpInterceptor = { |
| | | // æ¦æªå触å |
| | | invoke(options: CustomRequestOptions) { |
| | | // æ¥å£è¯·æ±æ¯æéè¿ query åæ°é
ç½® queryString |
| | | if (options.query) { |
| | | const queryStr = qs.stringify(options.query) |
| | | if (options.url.includes('?')) { |
| | | options.url += `&${queryStr}` |
| | | } else { |
| | | options.url += `?${queryStr}` |
| | | } |
| | | } |
| | | // é http å¼å¤´éæ¼æ¥å°å |
| | | if (!options.url.startsWith('http')) { |
| | | // #ifdef H5 |
| | | // console.log(__VITE_APP_PROXY__) |
| | | if (JSON.parse(__VITE_APP_PROXY__)) { |
| | | // å¥é½ä¸éè¦å |
| | | } else { |
| | | options.url = baseUrl + options.url |
| | | } |
| | | // #endif |
| | | // éH5æ£å¸¸æ¼æ¥ |
| | | // #ifndef H5 |
| | | options.url = baseUrl + options.url |
| | | // #endif |
| | | // TIPS: 妿éè¦å¯¹æ¥å¤ä¸ªå端æå¡ï¼ä¹å¯ä»¥å¨è¿éå¤çï¼æ¼æ¥ææéè¦çå°å |
| | | } |
| | | // 1. 请æ±è¶
æ¶ |
| | | options.timeout = 10000 // 10s |
| | | // 2. ï¼å¯éï¼æ·»å å°ç¨åºç«¯è¯·æ±å¤´æ è¯ |
| | | options.header = { |
| | | platform, // å¯éï¼ä¸ uniapp å®ä¹çå¹³å°ä¸è´ï¼åè¯åå°æ¥æº |
| | | ...options.header, |
| | | } |
| | | // 3. æ·»å token 请æ±å¤´æ è¯ |
| | | const userStore = useUserStore() |
| | | const { token } = userStore.userInfo as unknown as IUserInfo |
| | | if (token) { |
| | | options.header.Authorization = `Bearer ${token}` |
| | | } |
| | | }, |
| | | } |
| | | |
| | | export const requestInterceptor = { |
| | | install() { |
| | | // æ¦æª request è¯·æ± |
| | | uni.addInterceptor('request', httpInterceptor) |
| | | // æ¦æª uploadFile æä»¶ä¸ä¼ |
| | | uni.addInterceptor('uploadFile', httpInterceptor) |
| | | }, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /** |
| | | * by è²é¸½ on 2024-03-06 |
| | | * è·¯ç±æ¦æªï¼é叏乿¯ç»å½æ¦æª |
| | | * å¯ä»¥è®¾ç½®è·¯ç±ç½ååï¼æè
é»ååï¼çä¸å¡éè¦éåªä¸ä¸ª |
| | | * æè¿éåºä¸ºå¤§é¨åé½å¯ä»¥é便è¿å
¥ï¼æä»¥ä½¿ç¨é»åå |
| | | */ |
| | | import { useUserStore } from '@/store' |
| | | import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils' |
| | | |
| | | // TODO Check |
| | | const loginRoute = '/pages/login/index' |
| | | |
| | | const isLogined = () => { |
| | | const userStore = useUserStore() |
| | | return userStore.isLogined |
| | | } |
| | | |
| | | const isDev = import.meta.env.DEV |
| | | |
| | | // é»ååç»å½æ¦æªå¨ - ï¼éç¨äºå¤§é¨å页é¢ä¸éè¦ç»å½ï¼å°é¨å页é¢éè¦ç»å½ï¼ |
| | | const navigateToInterceptor = { |
| | | // 注æï¼è¿éçurlæ¯ '/' å¼å¤´çï¼å¦ '/pages/index/index'ï¼è· 'pages.json' éé¢ç path ä¸å |
| | | invoke({ url }: { url: string }) { |
| | | // console.log(url) // /pages/route-interceptor/index?name=feige&age=30 |
| | | const path = url.split('?')[0] |
| | | let needLoginPages: string[] = [] |
| | | // 为äºé²æ¢å¼åæ¶åºç°BUGï¼è¿éæ¯æ¬¡é½è·åä¸ä¸ãç产ç¯å¢å¯ä»¥ç§»å°å½æ°å¤ï¼æ§è½æ´å¥½ |
| | | if (isDev) { |
| | | needLoginPages = getNeedLoginPages() |
| | | } else { |
| | | needLoginPages = _needLoginPages |
| | | } |
| | | const isNeedLogin = needLoginPages.includes(path) |
| | | if (!isNeedLogin) { |
| | | return true |
| | | } |
| | | const hasLogin = isLogined() |
| | | if (hasLogin) { |
| | | return true |
| | | } |
| | | const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}` |
| | | uni.navigateTo({ url: redirectRoute }) |
| | | return false |
| | | }, |
| | | } |
| | | |
| | | export const routeInterceptor = { |
| | | install() { |
| | | uni.addInterceptor('navigateTo', navigateToInterceptor) |
| | | uni.addInterceptor('reLaunch', navigateToInterceptor) |
| | | uni.addInterceptor('redirectTo', navigateToInterceptor) |
| | | uni.addInterceptor('switchTab', navigateToInterceptor) |
| | | }, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <wd-config-provider :themeVars="themeVars"> |
| | | <slot /> |
| | | <wd-toast /> |
| | | <wd-message-box /> |
| | | </wd-config-provider> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import type { ConfigProviderThemeVars } from 'wot-design-uni' |
| | | |
| | | const themeVars: ConfigProviderThemeVars = { |
| | | // colorTheme: 'red', |
| | | // buttonPrimaryBgColor: '#07c160', |
| | | // buttonPrimaryColor: '#07c160', |
| | | } |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <wd-config-provider :themeVars="themeVars"> |
| | | <slot /> |
| | | <wd-toast /> |
| | | <wd-message-box /> |
| | | </wd-config-provider> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import type { ConfigProviderThemeVars } from 'wot-design-uni' |
| | | |
| | | const themeVars: ConfigProviderThemeVars = { |
| | | // colorTheme: 'red', |
| | | // buttonPrimaryBgColor: '#07c160', |
| | | // buttonPrimaryColor: '#07c160', |
| | | } |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <wd-config-provider :themeVars="themeVars"> |
| | | <slot /> |
| | | <!-- 注æä¸é¢ï¼å¤äºä¸ä¸ªèªå®ä¹tabbar --> |
| | | <fg-tabbar /> |
| | | <wd-toast /> |
| | | <wd-message-box /> |
| | | </wd-config-provider> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import type { ConfigProviderThemeVars } from 'wot-design-uni' |
| | | |
| | | const themeVars: ConfigProviderThemeVars = { |
| | | // colorTheme: 'red', |
| | | // buttonPrimaryBgColor: '#07c160', |
| | | // buttonPrimaryColor: '#07c160', |
| | | } |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import '@/style/index.scss' |
| | | import { VueQueryPlugin } from '@tanstack/vue-query' |
| | | import 'virtual:uno.css' |
| | | import { createSSRApp } from 'vue' |
| | | |
| | | import App from './App.vue' |
| | | import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors' |
| | | import store from './store' |
| | | |
| | | export function createApp() { |
| | | const app = createSSRApp(App) |
| | | app.use(store) |
| | | app.use(routeInterceptor) |
| | | app.use(requestInterceptor) |
| | | app.use(prototypeInterceptor) |
| | | app.use(VueQueryPlugin) |
| | | |
| | | return { |
| | | app, |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "name": "å
°å®è®¾å¤ç®¡ç", |
| | | "appid": "H5F0B095D", |
| | | "description": "", |
| | | "versionName": "1.0.0", |
| | | "versionCode": "100", |
| | | "transformPx": false, |
| | | "app-plus": { |
| | | "usingComponents": true, |
| | | "nvueStyleCompiler": "uni-app", |
| | | "compilerVersion": 3, |
| | | "splashscreen": { |
| | | "alwaysShowBeforeRender": true, |
| | | "waiting": true, |
| | | "autoclose": true, |
| | | "delay": 0 |
| | | }, |
| | | "modules": {}, |
| | | "distribute": { |
| | | "android": { |
| | | "permissions": [ |
| | | "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", |
| | | "<uses-permission android:name=\"android.permission.VIBRATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", |
| | | "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", |
| | | "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CAMERA\"/>", |
| | | "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", |
| | | "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", |
| | | "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", |
| | | "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", |
| | | "<uses-feature android:name=\"android.hardware.camera\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" |
| | | ], |
| | | "minSdkVersion": 21, |
| | | "targetSdkVersion": 30, |
| | | "abiFilters": [ |
| | | "armeabi-v7a", |
| | | "arm64-v8a" |
| | | ] |
| | | }, |
| | | "ios": {}, |
| | | "sdkConfigs": {}, |
| | | "icons": { |
| | | "android": { |
| | | "hdpi": "static/app/icons/72x72.png", |
| | | "xhdpi": "static/app/icons/96x96.png", |
| | | "xxhdpi": "static/app/icons/144x144.png", |
| | | "xxxhdpi": "static/app/icons/192x192.png" |
| | | }, |
| | | "ios": { |
| | | "appstore": "static/app/icons/1024x1024.png", |
| | | "ipad": { |
| | | "app": "static/app/icons/76x76.png", |
| | | "app@2x": "static/app/icons/152x152.png", |
| | | "notification": "static/app/icons/20x20.png", |
| | | "notification@2x": "static/app/icons/40x40.png", |
| | | "proapp@2x": "static/app/icons/167x167.png", |
| | | "settings": "static/app/icons/29x29.png", |
| | | "settings@2x": "static/app/icons/58x58.png", |
| | | "spotlight": "static/app/icons/40x40.png", |
| | | "spotlight@2x": "static/app/icons/80x80.png" |
| | | }, |
| | | "iphone": { |
| | | "app@2x": "static/app/icons/120x120.png", |
| | | "app@3x": "static/app/icons/180x180.png", |
| | | "notification@2x": "static/app/icons/40x40.png", |
| | | "notification@3x": "static/app/icons/60x60.png", |
| | | "settings@2x": "static/app/icons/58x58.png", |
| | | "settings@3x": "static/app/icons/87x87.png", |
| | | "spotlight@2x": "static/app/icons/80x80.png", |
| | | "spotlight@3x": "static/app/icons/120x120.png" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "compatible": { |
| | | "ignoreVersion": true |
| | | } |
| | | }, |
| | | "quickapp": {}, |
| | | "mp-weixin": { |
| | | "appid": "", |
| | | "setting": { |
| | | "urlCheck": false |
| | | }, |
| | | "usingComponents": true |
| | | }, |
| | | "mp-alipay": { |
| | | "usingComponents": true, |
| | | "styleIsolation": "shared" |
| | | }, |
| | | "mp-baidu": { |
| | | "usingComponents": true |
| | | }, |
| | | "mp-toutiao": { |
| | | "usingComponents": true |
| | | }, |
| | | "uniStatistics": { |
| | | "enable": false |
| | | }, |
| | | "vueVersion": "3", |
| | | "h5": { |
| | | "router": { |
| | | "base": "/" |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5" type="page"> |
| | | { |
| | | style: { navigationBarTitleText: 'åå
é¡µé¢ æ é¢' }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <view class="text-center"> |
| | | <view class="m-8">http://localhost:9000/#/pages-sub/demo/index</view> |
| | | <view class="text-green-500">åå
页é¢demo</view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | // code here |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | // |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "globalStyle": { |
| | | "navigationStyle": "default", |
| | | "navigationBarTitleText": "å
°å®è®¾å¤ç®¡ç", |
| | | "navigationBarBackgroundColor": "#f8f8f8", |
| | | "navigationBarTextStyle": "black", |
| | | "backgroundColor": "#FFFFFF" |
| | | }, |
| | | "easycom": { |
| | | "autoscan": true, |
| | | "custom": { |
| | | "^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue", |
| | | "^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue" |
| | | } |
| | | }, |
| | | "tabBar": { |
| | | "custom": true, |
| | | "color": "#999999", |
| | | "selectedColor": "#007aff", |
| | | "borderStyle": "black", |
| | | "height": "50px", |
| | | "fontSize": "10px", |
| | | "iconWidth": "24px", |
| | | "spacing": "3px", |
| | | "list": [ |
| | | { |
| | | "pagePath": "pages/home/index", |
| | | "text": "é¦é¡µ", |
| | | "icon": "home", |
| | | "iconType": "wot" |
| | | }, |
| | | { |
| | | "pagePath": "pages/equ/index", |
| | | "text": "设å¤", |
| | | "icon": "mobile", |
| | | "iconType": "wot" |
| | | }, |
| | | { |
| | | "pagePath": "pages/equ/index", |
| | | "icon": "scan", |
| | | "iconType": "wot" |
| | | }, |
| | | { |
| | | "pagePath": "pages/spare/index", |
| | | "text": "å¤ä»¶", |
| | | "icon": "setting1", |
| | | "iconType": "wot" |
| | | }, |
| | | { |
| | | "pagePath": "pages/my/index", |
| | | "text": "æç", |
| | | "icon": "user", |
| | | "iconType": "wot" |
| | | } |
| | | ] |
| | | }, |
| | | "pages": [ |
| | | { |
| | | "path": "pages/home/index", |
| | | "type": "home", |
| | | "layout": "tabbar", |
| | | "style": { |
| | | "navigationStyle": "custom", |
| | | "navigationBarTitleText": "é¦é¡µ" |
| | | } |
| | | }, |
| | | { |
| | | "path": "pages/equ/index", |
| | | "type": "page", |
| | | "layout": "tabbar", |
| | | "style": { |
| | | "navigationBarTitleText": "å
³äº" |
| | | } |
| | | }, |
| | | { |
| | | "path": "pages/login/index", |
| | | "type": "page", |
| | | "layout": "default", |
| | | "style": { |
| | | "navigationStyle": "custom", |
| | | "navigationBarTitleText": "ç»å½" |
| | | } |
| | | }, |
| | | { |
| | | "path": "pages/my/index", |
| | | "type": "page", |
| | | "layout": "tabbar", |
| | | "style": { |
| | | "navigationBarTitleText": "æç" |
| | | } |
| | | }, |
| | | { |
| | | "path": "pages/spare/index", |
| | | "type": "page", |
| | | "layout": "tabbar", |
| | | "style": { |
| | | "navigationBarTitleText": "spare" |
| | | } |
| | | } |
| | | ], |
| | | "subPackages": [] |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5"> |
| | | { |
| | | layout: 'demo', |
| | | style: { |
| | | navigationBarTitleText: '请æ±', |
| | | }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <view class="p-6 text-center"> |
| | | <view class="my-2">使ç¨çæ¯ laf äºåå°</view> |
| | | <view class="text-green-400">æçæ¨èç ï¼å¯ä»¥è·å¾ä½£é</view> |
| | | |
| | | <!-- #ifdef H5 --> |
| | | <view class="my-2"> |
| | | <a class="my-2" :href="recommendUrl" target="_blank">{{ recommendUrl }}</a> |
| | | </view> |
| | | <!-- #endif --> |
| | | |
| | | <!-- #ifndef H5 --> |
| | | <view class="my-2 text-left text-sm">{{ recommendUrl }}</view> |
| | | <!-- #endif --> |
| | | |
| | | <!-- http://localhost:9000/#/pages/index/request --> |
| | | <wd-button @click="run" class="my-6">åé请æ±</wd-button> |
| | | <view class="h-16"> |
| | | <view v-if="loading">loading...</view> |
| | | <block v-else> |
| | | <view class="text-xl">è¯·æ±æ°æ®å¦ä¸</view> |
| | | <view class="text-green leading-8">{{ JSON.stringify(data) }}</view> |
| | | </block> |
| | | </view> |
| | | <wd-button type="error" @click="reset" class="my-6" :disabled="!data">éç½®æ°æ®</wd-button> |
| | | </view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { getFooAPI, postFooAPI, IFooItem } from '@/service/index/foo' |
| | | import { findPetsByStatusQueryOptions } from '@/service/app' |
| | | import { useQuery } from '@tanstack/vue-query' |
| | | |
| | | const recommendUrl = ref('http://laf.run/signup?code=ohaOgIX') |
| | | |
| | | // const initialData = { |
| | | // name: 'initialData', |
| | | // id: '1234', |
| | | // } |
| | | const initialData = undefined |
| | | // éåå°é¨åå
¨å±æ§çæ¥å£ââââå¤ä¸ªé¡µé¢é½éè¦çè¯·æ±æ¥å£ï¼é¢å¤ç¼åä¸ä¸ª Service å± |
| | | const { loading, error, data, run } = useRequest<IFooItem>(() => getFooAPI('è²é¸½'), { |
| | | immediate: true, |
| | | initialData, |
| | | }) |
| | | |
| | | // ä½¿ç¨ vue-query ç useQuery æ¥è¯·æ±æ°æ®ï¼åªååèï¼æ¯å¦ä½¿ç¨è¯·æ ¹æ®å®é
æ
åµèå® |
| | | const { |
| | | data: data2, |
| | | error: error2, |
| | | isLoading: isLoading2, |
| | | refetch, |
| | | } = useQuery(findPetsByStatusQueryOptions({ params: { status: ['available'] } })) |
| | | |
| | | const reset = () => { |
| | | data.value = initialData |
| | | } |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5" type="page"> |
| | | { |
| | | layout: 'default', |
| | | style: { |
| | | navigationBarTitleText: 'ä¸ä¼ -ç¶æä¸ä½å', |
| | | }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <view class="p-4 text-center"> |
| | | <wd-button @click="run">éæ©å¾çå¹¶ä¸ä¼ </wd-button> |
| | | <view v-if="loading" class="text-blue h-10">ä¸ä¼ ...</view> |
| | | <template v-else> |
| | | <view class="m-2">ä¸ä¼ åè¿åçæ¥å£æ°æ®ï¼</view> |
| | | <view class="m-2">{{ data }}</view> |
| | | <view class="h-80 w-full"> |
| | | <image v-if="data" :src="data || data" mode="scaleToFill" /> |
| | | </view> |
| | | </template> |
| | | </view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | const { loading, data, run } = useUpload({ user: 'è²é¸½' }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | // |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5"> |
| | | { |
| | | layout: 'tabbar', |
| | | style: { |
| | | navigationBarTitleText: 'å
³äº', |
| | | }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <view |
| | | class="bg-white overflow-hidden pt-2 px-4" |
| | | :style="{ marginTop: safeAreaInsets?.top + 'px' }" |
| | | > |
| | | <view class="text-center text-3xl mt-8"> |
| | | 鸽åä»¬å¥½ï¼ææ¯ |
| | | <text class="text-red-500">è²é¸½</text> |
| | | </view> |
| | | <RequestComp /> |
| | | <UploadComp /> |
| | | </view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import RequestComp from './components/request.vue' |
| | | import UploadComp from './components/upload.vue' |
| | | |
| | | // è·åå±å¹è¾¹çå°å®å
¨åºåè·ç¦» |
| | | const { safeAreaInsets } = uni.getSystemInfoSync() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .test-css { |
| | | // mt-4=>1rem=>16px; |
| | | margin-top: 16px; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- ä½¿ç¨ type="home" 屿§è®¾ç½®é¦é¡µï¼å
¶ä»é¡µé¢ä¸éè¦è®¾ç½®ï¼é»è®¤ä¸ºpageï¼æ¨è使ç¨json5ï¼æ´å¼ºå¤§ï¼ä¸å
许注é --> |
| | | <route lang="json5" type="home"> |
| | | { |
| | | layout: 'tabbar', |
| | | style: { |
| | | navigationStyle: 'custom', |
| | | navigationBarTitleText: 'é¦é¡µ', |
| | | }, |
| | | } |
| | | </route> |
| | | <template> |
| | | <view |
| | | class="bg-white overflow-hidden pt-2 px-4" |
| | | :style="{ marginTop: safeAreaInsets?.top + 'px' }" |
| | | > |
| | | <view class="mt-12"> |
| | | <image src="/static/logo.svg" alt="" class="w-28 h-28 block mx-auto" /> |
| | | </view> |
| | | <view class="text-center text-4xl main-title-color mt-4">unibest</view> |
| | | <view class="text-center text-2xl mt-2 mb-8">æå¥½ç¨ç uniapp å¼å模æ¿</view> |
| | | |
| | | <view class="text-justify max-w-100 m-auto text-4 indent mb-2">{{ description }}</view> |
| | | <view class="text-center mt-8"> |
| | | å½å平尿¯ï¼ |
| | | <text class="text-green-500">{{ PLATFORM.platform }}</text> |
| | | </view> |
| | | <view class="text-center mt-4"> |
| | | 模æ¿åæ¯æ¯ï¼ |
| | | <text class="text-green-500">tabbar</text> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { TestEnum } from '@/typings' |
| | | import PLATFORM from '@/utils/platform' |
| | | |
| | | defineOptions({ |
| | | name: 'Home', |
| | | }) |
| | | |
| | | // è·åå±å¹è¾¹çå°å®å
¨åºåè·ç¦» |
| | | const { safeAreaInsets } = uni.getSystemInfoSync() |
| | | const author = ref('è²é¸½') |
| | | const description = ref( |
| | | 'unibest æ¯ä¸ä¸ªéæäºå¤ç§å·¥å
·åææ¯ç uniapp å¼å模æ¿ï¼ç± uniapp + Vue3 + Ts + Vite4 + UnoCss + UniUI + VSCode æå»ºï¼æ¨¡æ¿å
·æä»£ç æç¤ºãèªå¨æ ¼å¼åãç»ä¸é
ç½®ã代ç çæ®µçåè½ï¼å¹¶å
ç½®äºè®¸å¤å¸¸ç¨çåºæ¬ç»ä»¶ååºæ¬åè½ï¼è®©ä½ ç¼å uniapp æ¥æ best ä½éªã', |
| | | ) |
| | | // æµè¯ uni API èªå¨å¼å
¥ |
| | | onLoad(() => { |
| | | console.log(author) |
| | | console.log(TestEnum.A) |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .main-title-color { |
| | | color: $uni-color-primary; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5"> |
| | | { |
| | | layout: 'default', |
| | | style: { |
| | | navigationStyle: 'custom', |
| | | navigationBarTitleText: 'ç»å½', |
| | | }, |
| | | } |
| | | </route> |
| | | <script setup lang="ts"> |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | |
| | | </template> |
| | | |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5" type="page"> |
| | | { |
| | | layout: 'tabbar', |
| | | style: { |
| | | navigationBarTitleText: 'æç', |
| | | }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <view class="pt-40 text-xl text-center text-green-500">æç页é¢</view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | // |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | // |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <route lang="json5" type="page"> |
| | | { |
| | | layout: 'tabbar', |
| | | style: { |
| | | navigationBarTitleText: 'spare', |
| | | }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <view class="pt-40 text-xl text-center text-green-500">å¤ä»¶</view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | // |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | // |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import * as API from './types'; |
| | | |
| | | export function displayStatusEnum(field: API.IStatusEnum) { |
| | | return { available: 'available', pending: 'pending', sold: 'sold' }[field]; |
| | | } |
| | | |
| | | export function displayStatusEnum2(field: API.IStatusEnum2) { |
| | | return { placed: 'placed', approved: 'approved', delivered: 'delivered' }[ |
| | | field |
| | | ]; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | export * from './types'; |
| | | export * from './displayEnumLabel'; |
| | | |
| | | export * from './pet'; |
| | | export * from './pet.vuequery'; |
| | | export * from './store'; |
| | | export * from './store.vuequery'; |
| | | export * from './user'; |
| | | export * from './user.vuequery'; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import request from '@/utils/request'; |
| | | import { CustomRequestOptions } from '@/interceptors/request'; |
| | | |
| | | import * as API from './types'; |
| | | |
| | | /** Update an existing pet PUT /pet */ |
| | | export async function updatePet({ |
| | | body, |
| | | options, |
| | | }: { |
| | | body: API.Pet; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<unknown>('/pet', { |
| | | method: 'PUT', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Add a new pet to the store POST /pet */ |
| | | export async function addPet({ |
| | | body, |
| | | options, |
| | | }: { |
| | | body: API.Pet; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<unknown>('/pet', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Find pet by ID Returns a single pet GET /pet/${param0} */ |
| | | export async function getPetById({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.getPetByIdParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { petId: param0, ...queryParams } = params; |
| | | |
| | | return request<API.Pet>(`/pet/${param0}`, { |
| | | method: 'GET', |
| | | params: { ...queryParams }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Updates a pet in the store with form data POST /pet/${param0} */ |
| | | export async function updatePetWithForm({ |
| | | params, |
| | | body, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.updatePetWithFormParams; |
| | | body: { |
| | | /** Updated name of the pet */ |
| | | name?: string; |
| | | /** Updated status of the pet */ |
| | | status?: string; |
| | | }; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { petId: param0, ...queryParams } = params; |
| | | |
| | | return request<unknown>(`/pet/${param0}`, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/x-www-form-urlencoded', |
| | | }, |
| | | params: { ...queryParams }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Deletes a pet DELETE /pet/${param0} */ |
| | | export async function deletePet({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.deletePetParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { petId: param0, ...queryParams } = params; |
| | | |
| | | return request<unknown>(`/pet/${param0}`, { |
| | | method: 'DELETE', |
| | | params: { ...queryParams }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** uploads an image POST /pet/${param0}/uploadImage */ |
| | | export async function uploadFile({ |
| | | params, |
| | | body, |
| | | file, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.uploadFileParams; |
| | | body: { |
| | | /** Additional data to pass to server */ |
| | | additionalMetadata?: string; |
| | | }; |
| | | file?: File; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { petId: param0, ...queryParams } = params; |
| | | const formData = new FormData(); |
| | | |
| | | if (file) { |
| | | formData.append('file', file); |
| | | } |
| | | |
| | | Object.keys(body).forEach((ele) => { |
| | | const item = (body as { [key: string]: any })[ele]; |
| | | |
| | | if (item !== undefined && item !== null) { |
| | | if (typeof item === 'object' && !(item instanceof File)) { |
| | | if (item instanceof Array) { |
| | | item.forEach((f) => formData.append(ele, f || '')); |
| | | } else { |
| | | formData.append(ele, JSON.stringify(item)); |
| | | } |
| | | } else { |
| | | formData.append(ele, item); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | return request<API.ApiResponse>(`/pet/${param0}/uploadImage`, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'multipart/form-data', |
| | | }, |
| | | params: { ...queryParams }, |
| | | data: formData, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */ |
| | | export async function findPetsByStatus({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.findPetsByStatusParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<API.Pet[]>('/pet/findByStatus', { |
| | | method: 'GET', |
| | | params: { |
| | | ...params, |
| | | }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */ |
| | | export async function findPetsByTags({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.findPetsByTagsParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<API.Pet[]>('/pet/findByTags', { |
| | | method: 'GET', |
| | | params: { |
| | | ...params, |
| | | }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import { queryOptions, useMutation } from '@tanstack/vue-query'; |
| | | import type { DefaultError } from '@tanstack/vue-query'; |
| | | import request from '@/utils/request'; |
| | | import { CustomRequestOptions } from '@/interceptors/request'; |
| | | |
| | | import * as apis from './pet'; |
| | | import * as API from './types'; |
| | | |
| | | /** Update an existing pet PUT /pet */ |
| | | export function useUpdatePetMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.updatePet, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Add a new pet to the store POST /pet */ |
| | | export function useAddPetMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.addPet, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Find pet by ID Returns a single pet GET /pet/${param0} */ |
| | | export function getPetByIdQueryOptions(options: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.getPetByIdParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.getPetById(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['getPetById', options], |
| | | }); |
| | | } |
| | | |
| | | /** Updates a pet in the store with form data POST /pet/${param0} */ |
| | | export function useUpdatePetWithFormMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.updatePetWithForm, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Deletes a pet DELETE /pet/${param0} */ |
| | | export function useDeletePetMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.deletePet, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** uploads an image POST /pet/${param0}/uploadImage */ |
| | | export function useUploadFileMutation(options?: { |
| | | onSuccess?: (value?: API.ApiResponse) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.uploadFile, |
| | | onSuccess(data: API.ApiResponse) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */ |
| | | export function findPetsByStatusQueryOptions(options: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.findPetsByStatusParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.findPetsByStatus(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['findPetsByStatus', options], |
| | | }); |
| | | } |
| | | |
| | | /** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */ |
| | | export function findPetsByTagsQueryOptions(options: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.findPetsByTagsParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.findPetsByTags(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['findPetsByTags', options], |
| | | }); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import request from '@/utils/request'; |
| | | import { CustomRequestOptions } from '@/interceptors/request'; |
| | | |
| | | import * as API from './types'; |
| | | |
| | | /** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */ |
| | | export async function getInventory({ |
| | | options, |
| | | }: { |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<Record<string, unknown>>('/store/inventory', { |
| | | method: 'GET', |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Place an order for a pet POST /store/order */ |
| | | export async function placeOrder({ |
| | | body, |
| | | options, |
| | | }: { |
| | | body: API.Order; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<API.Order>('/store/order', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */ |
| | | export async function getOrderById({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.getOrderByIdParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { orderId: param0, ...queryParams } = params; |
| | | |
| | | return request<API.Order>(`/store/order/${param0}`, { |
| | | method: 'GET', |
| | | params: { ...queryParams }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */ |
| | | export async function deleteOrder({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.deleteOrderParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { orderId: param0, ...queryParams } = params; |
| | | |
| | | return request<unknown>(`/store/order/${param0}`, { |
| | | method: 'DELETE', |
| | | params: { ...queryParams }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import { queryOptions, useMutation } from '@tanstack/vue-query'; |
| | | import type { DefaultError } from '@tanstack/vue-query'; |
| | | import request from '@/utils/request'; |
| | | import { CustomRequestOptions } from '@/interceptors/request'; |
| | | |
| | | import * as apis from './store'; |
| | | import * as API from './types'; |
| | | |
| | | /** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */ |
| | | export function getInventoryQueryOptions(options: { |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.getInventory(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['getInventory', options], |
| | | }); |
| | | } |
| | | |
| | | /** Place an order for a pet POST /store/order */ |
| | | export function usePlaceOrderMutation(options?: { |
| | | onSuccess?: (value?: API.Order) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.placeOrder, |
| | | onSuccess(data: API.Order) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */ |
| | | export function getOrderByIdQueryOptions(options: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.getOrderByIdParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.getOrderById(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['getOrderById', options], |
| | | }); |
| | | } |
| | | |
| | | /** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */ |
| | | export function useDeleteOrderMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.deleteOrder, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | |
| | | export type ApiResponse = { |
| | | code?: number; |
| | | type?: string; |
| | | message?: string; |
| | | }; |
| | | |
| | | export type Category = { |
| | | id?: number; |
| | | name?: string; |
| | | }; |
| | | |
| | | export type deleteOrderParams = { |
| | | /** ID of the order that needs to be deleted */ |
| | | orderId: number; |
| | | }; |
| | | |
| | | export type deletePetParams = { |
| | | /** Pet id to delete */ |
| | | petId: number; |
| | | }; |
| | | |
| | | export type deleteUserParams = { |
| | | /** The name that needs to be deleted */ |
| | | username: string; |
| | | }; |
| | | |
| | | export type findPetsByStatusParams = { |
| | | /** Status values that need to be considered for filter */ |
| | | status: ('available' | 'pending' | 'sold')[]; |
| | | }; |
| | | |
| | | export type findPetsByTagsParams = { |
| | | /** Tags to filter by */ |
| | | tags: string[]; |
| | | }; |
| | | |
| | | export type getOrderByIdParams = { |
| | | /** ID of pet that needs to be fetched */ |
| | | orderId: number; |
| | | }; |
| | | |
| | | export type getPetByIdParams = { |
| | | /** ID of pet to return */ |
| | | petId: number; |
| | | }; |
| | | |
| | | export type getUserByNameParams = { |
| | | /** The name that needs to be fetched. Use user1 for testing. */ |
| | | username: string; |
| | | }; |
| | | |
| | | export type loginUserParams = { |
| | | /** The user name for login */ |
| | | username: string; |
| | | /** The password for login in clear text */ |
| | | password: string; |
| | | }; |
| | | |
| | | export type Order = { |
| | | id?: number; |
| | | petId?: number; |
| | | quantity?: number; |
| | | shipDate?: string; |
| | | /** Order Status */ |
| | | status?: 'placed' | 'approved' | 'delivered'; |
| | | complete?: boolean; |
| | | }; |
| | | |
| | | export type Pet = { |
| | | id?: number; |
| | | category?: Category; |
| | | name: string; |
| | | photoUrls: string[]; |
| | | tags?: Tag[]; |
| | | /** pet status in the store */ |
| | | status?: 'available' | 'pending' | 'sold'; |
| | | }; |
| | | |
| | | export enum StatusEnum { |
| | | available = 'available', |
| | | pending = 'pending', |
| | | sold = 'sold', |
| | | } |
| | | |
| | | export type IStatusEnum = keyof typeof StatusEnum; |
| | | |
| | | export enum StatusEnum2 { |
| | | placed = 'placed', |
| | | approved = 'approved', |
| | | delivered = 'delivered', |
| | | } |
| | | |
| | | export type IStatusEnum2 = keyof typeof StatusEnum2; |
| | | |
| | | export type Tag = { |
| | | id?: number; |
| | | name?: string; |
| | | }; |
| | | |
| | | export type updatePetWithFormParams = { |
| | | /** ID of pet that needs to be updated */ |
| | | petId: number; |
| | | }; |
| | | |
| | | export type updateUserParams = { |
| | | /** name that need to be updated */ |
| | | username: string; |
| | | }; |
| | | |
| | | export type uploadFileParams = { |
| | | /** ID of pet to update */ |
| | | petId: number; |
| | | }; |
| | | |
| | | export type User = { |
| | | id?: number; |
| | | username?: string; |
| | | firstName?: string; |
| | | lastName?: string; |
| | | email?: string; |
| | | password?: string; |
| | | phone?: string; |
| | | /** User Status */ |
| | | userStatus?: number; |
| | | }; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import request from '@/utils/request'; |
| | | import { CustomRequestOptions } from '@/interceptors/request'; |
| | | |
| | | import * as API from './types'; |
| | | |
| | | /** Create user This can only be done by the logged in user. è¿åå¼: successful operation POST /user */ |
| | | export async function createUser({ |
| | | body, |
| | | options, |
| | | }: { |
| | | body: API.User; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<unknown>('/user', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Get user by user name GET /user/${param0} */ |
| | | export async function getUserByName({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.getUserByNameParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { username: param0, ...queryParams } = params; |
| | | |
| | | return request<API.User>(`/user/${param0}`, { |
| | | method: 'GET', |
| | | params: { ...queryParams }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Updated user This can only be done by the logged in user. PUT /user/${param0} */ |
| | | export async function updateUser({ |
| | | params, |
| | | body, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.updateUserParams; |
| | | body: API.User; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { username: param0, ...queryParams } = params; |
| | | |
| | | return request<unknown>(`/user/${param0}`, { |
| | | method: 'PUT', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | params: { ...queryParams }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Delete user This can only be done by the logged in user. DELETE /user/${param0} */ |
| | | export async function deleteUser({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.deleteUserParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | const { username: param0, ...queryParams } = params; |
| | | |
| | | return request<unknown>(`/user/${param0}`, { |
| | | method: 'DELETE', |
| | | params: { ...queryParams }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Creates list of users with given input array è¿åå¼: successful operation POST /user/createWithArray */ |
| | | export async function createUsersWithArrayInput({ |
| | | body, |
| | | options, |
| | | }: { |
| | | body: API.User[]; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<unknown>('/user/createWithArray', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Creates list of users with given input array è¿åå¼: successful operation POST /user/createWithList */ |
| | | export async function createUsersWithListInput({ |
| | | body, |
| | | options, |
| | | }: { |
| | | body: API.User[]; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<unknown>('/user/createWithList', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Logs user into the system GET /user/login */ |
| | | export async function loginUser({ |
| | | params, |
| | | options, |
| | | }: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.loginUserParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<string>('/user/login', { |
| | | method: 'GET', |
| | | params: { |
| | | ...params, |
| | | }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** Logs out current logged in user session è¿åå¼: successful operation GET /user/logout */ |
| | | export async function logoutUser({ |
| | | options, |
| | | }: { |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return request<unknown>('/user/logout', { |
| | | method: 'GET', |
| | | ...(options || {}), |
| | | }); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | // @ts-ignore |
| | | import { queryOptions, useMutation } from '@tanstack/vue-query'; |
| | | import type { DefaultError } from '@tanstack/vue-query'; |
| | | import request from '@/utils/request'; |
| | | import { CustomRequestOptions } from '@/interceptors/request'; |
| | | |
| | | import * as apis from './user'; |
| | | import * as API from './types'; |
| | | |
| | | /** Create user This can only be done by the logged in user. è¿åå¼: successful operation POST /user */ |
| | | export function useCreateUserMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.createUser, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Get user by user name GET /user/${param0} */ |
| | | export function getUserByNameQueryOptions(options: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.getUserByNameParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.getUserByName(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['getUserByName', options], |
| | | }); |
| | | } |
| | | |
| | | /** Updated user This can only be done by the logged in user. PUT /user/${param0} */ |
| | | export function useUpdateUserMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.updateUser, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Delete user This can only be done by the logged in user. DELETE /user/${param0} */ |
| | | export function useDeleteUserMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.deleteUser, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Creates list of users with given input array è¿åå¼: successful operation POST /user/createWithArray */ |
| | | export function useCreateUsersWithArrayInputMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.createUsersWithArrayInput, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Creates list of users with given input array è¿åå¼: successful operation POST /user/createWithList */ |
| | | export function useCreateUsersWithListInputMutation(options?: { |
| | | onSuccess?: (value?: unknown) => void; |
| | | onError?: (error?: DefaultError) => void; |
| | | }) { |
| | | const { onSuccess, onError } = options || {}; |
| | | |
| | | const response = useMutation({ |
| | | mutationFn: apis.createUsersWithListInput, |
| | | onSuccess(data: unknown) { |
| | | onSuccess?.(data); |
| | | }, |
| | | onError(error) { |
| | | onError?.(error); |
| | | }, |
| | | }); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /** Logs user into the system GET /user/login */ |
| | | export function loginUserQueryOptions(options: { |
| | | // å å çæçParamç±»å (ébodyåæ°openapié»è®¤æ²¡æçæå¯¹è±¡) |
| | | params: API.loginUserParams; |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.loginUser(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['loginUser', options], |
| | | }); |
| | | } |
| | | |
| | | /** Logs out current logged in user session è¿åå¼: successful operation GET /user/logout */ |
| | | export function logoutUserQueryOptions(options: { |
| | | options?: CustomRequestOptions; |
| | | }) { |
| | | return queryOptions({ |
| | | queryFn: async ({ queryKey }) => { |
| | | return apis.logoutUser(queryKey[1] as typeof options); |
| | | }, |
| | | queryKey: ['logoutUser', options], |
| | | }); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { http } from '@/utils/http' |
| | | export interface IFooItem { |
| | | id: string |
| | | name: string |
| | | } |
| | | |
| | | /** GET è¯·æ± */ |
| | | export const getFooAPI = (name: string) => { |
| | | return http.get<IFooItem>('/foo', { name }) |
| | | } |
| | | |
| | | /** POST è¯·æ± */ |
| | | export const postFooAPI = (name: string) => { |
| | | return http.post<IFooItem>('/foo', { name }, { name }) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1744441358272" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1641" width="128" height="128" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M327.33 160.57a1993.38 1993.38 0 0 1 369.34 0C777 168.94 855.11 247 863.48 327.3a2005.94 2005.94 0 0 1 0 369.37C855.11 777 777 855.13 696.67 863.5a2010.9 2010.9 0 0 1-369.34 0C247 855.13 168.89 777 160.51 696.67a2007.7 2007.7 0 0 1 0-369.37C168.89 247 247 168.94 327.33 160.57z" fill="#2A2AFB" p-id="1642"></path><path d="M696.67 863.5a2010.9 2010.9 0 0 1-369.34 0C247 855.13 168.89 777 160.51 696.67c-3.46-37.52-5.74-75.13-7.09-112.65 1.35-37.61 3.6-75.14 7.09-112.75C168.89 391 247 312.91 327.33 304.54a1993.38 1993.38 0 0 1 369.34 0C777 312.91 855.11 391 863.48 471.27c3.47 37.61 5.74 75.14 7.09 112.75-1.35 37.52-3.59 75.13-7.09 112.65C855.11 777 777 855.13 696.67 863.5z" fill="#4444FB" p-id="1643"></path><path d="M696.67 863.5a2010.9 2010.9 0 0 1-369.34 0C247 855.13 168.89 777 160.51 696.67c-1.25-13.49-2.3-27.08-3.28-40.67 1-13.59 2-27.17 3.28-40.76C168.89 535 247 456.88 327.33 448.51a1993.38 1993.38 0 0 1 369.34 0C777 456.88 855.11 535 863.48 615.24c1.25 13.59 2.32 27.17 3.29 40.76-1 13.59-2 27.18-3.29 40.67C855.11 777 777 855.13 696.67 863.5z" fill="#5D5DFD" p-id="1644"></path><path d="M696.67 863.5a2010.9 2010.9 0 0 1-369.34 0c-69.83-7.29-137.89-67.22-160-135.51 22.15-68.3 90.21-128.32 160-135.51a1993.38 1993.38 0 0 1 369.34 0c69.83 7.19 137.9 67.21 160 135.51-22.1 68.29-90.17 128.22-160 135.51z" fill="#7A7AFD" p-id="1645"></path><path d="M327.33 863.5c-45.09-4.68-89.47-31.32-121.21-68 31.74-36.71 76.12-63.35 121.21-68a1993.38 1993.38 0 0 1 369.34 0c45.09 4.67 89.46 31.31 121.2 68-31.74 36.71-76.11 63.35-121.2 68a2010.9 2010.9 0 0 1-369.34 0z" fill="#8E8FFE" p-id="1646"></path><path d="M690.06 415.76a81.08 81.08 0 0 1-11.52 36.84 70.73 70.73 0 0 1-52.74 32.66 139.71 139.71 0 0 1-17.12 0.09 15.64 15.64 0 0 0-11.57 4.71q-38 37.77-75.93 75.63a7290.78 7290.78 0 0 1-34.12 34 21.15 21.15 0 0 0-6.39 14.86A71.8 71.8 0 0 1 457 665.88a75 75 0 0 1-52.65 19.67c-3-0.45-8.77-1.43-14.6-2.32a5.48 5.48 0 0 1-4.94-4.8 5.63 5.63 0 0 1 3.3-5.61c9.53-6 19.05-12 28.59-18a17.8 17.8 0 0 0 7.68-24 18.37 18.37 0 0 0-1.8-2.81c-6.76-10.41-13.24-21-20-31.41a16.8 16.8 0 0 0-21.69-6 115.85 115.85 0 0 0-11.27 6.76c-8.72 5.51-17.42 11-26.1 16.64a5.71 5.71 0 0 1-9.38-6.14 82.6 82.6 0 0 1 9.93-33.73 70.65 70.65 0 0 1 53.77-35.32c5.76-0.71 11.61-0.71 17.42-0.89a15.55 15.55 0 0 0 10.17-4.63q30.46-28.95 60.95-57.74c17.53-16.64 35-33.37 52.5-50a15.23 15.23 0 0 0 4.64-11.92 70.28 70.28 0 0 1 15.84-47 71.14 71.14 0 0 1 59.92-27.85 133 133 0 0 1 15.53 2 5.14 5.14 0 0 1 4.56 4.81 5.54 5.54 0 0 1-3.07 5.43c-9.61 6.05-19.21 12.19-28.81 18.24a17.71 17.71 0 0 0-7.72 23.81 18.07 18.07 0 0 0 1.78 2.79c6.61 10.32 13.11 20.82 19.83 31.14a17.31 17.31 0 0 0 23.81 5.69l0.54-0.35q17.58-11.07 35.06-22.33a6.06 6.06 0 0 1 6.92-0.8 5.88 5.88 0 0 1 2.35 6.55z m-259.23 75.46a17.57 17.57 0 0 0-15.12-5.61A72.46 72.46 0 0 1 337 420v-0.4c-0.23-1.69-0.36-3.38-0.53-5.16a5.27 5.27 0 0 1 2.59-5.34 5.55 5.55 0 0 1 6.15 0.45c11.08 7.11 22.24 14.14 33.32 21.26a20 20 0 0 0 15.05 4.09 17.65 17.65 0 0 0 12-8.09c6.84-10.86 13.75-21.63 20.47-32.48a17.24 17.24 0 0 0-5-23.87c-0.27-0.18-0.55-0.35-0.83-0.51-9.94-6.32-19.84-12.55-29.79-18.86a5.44 5.44 0 0 1 1.53-10.24 70.58 70.58 0 0 1 57.84 9.7 72.14 72.14 0 0 1 33.52 62.38A18.44 18.44 0 0 0 490 427.7c4.19 3.56 8.14 7.47 12.45 11.48q-31.85 30.24-63.06 60c-3-2.85-5.91-5.16-8.45-7.92z m191.08 59.08A60.53 60.53 0 0 0 644 563.11a61 61 0 0 1 42.93 49.83 62.57 62.57 0 0 1-121.78 27.67A61.23 61.23 0 0 0 549 614c-8.73-8.9-17.26-17.89-25.86-26.87a5.63 5.63 0 0 1-0.57-0.72c22.13-22.15 44.18-44.31 66.43-66.64 11.08 10.32 22 20.46 32.9 30.52z m-28.29 78.48a4.66 4.66 0 0 1 3.73 5.45 4.71 4.71 0 0 1-1.06 2.2 4.57 4.57 0 0 0-0.64 3.56 6.46 6.46 0 0 0 3.12 1.69c4.19-0.89 6.09 1.42 5.48 5.52a4.52 4.52 0 0 0 1 3.47 4.18 4.18 0 0 0 3.19-0.36 4.7 4.7 0 0 1 6.58 0.92 4.63 4.63 0 0 1 0.89 2.1 5.09 5.09 0 0 0 2.38 3 4.26 4.26 0 0 0 2.79-1.69 4.62 4.62 0 0 1 6.28-1.79 4.53 4.53 0 0 1 1.79 1.79 4.38 4.38 0 0 0 2.87 1.69 4.06 4.06 0 0 0 2.31-2.76 4.63 4.63 0 0 1 7.48-3.29 4.3 4.3 0 0 0 3.22 0.36 4.49 4.49 0 0 0 1-3.39 4.7 4.7 0 0 1 5.48-6.22 3.93 3.93 0 0 0 3.06-1.07 4.52 4.52 0 0 0-0.61-3.56 4.7 4.7 0 0 1 2.67-7.65 3.78 3.78 0 0 0 2.42-2.23 4.07 4.07 0 0 0-1.9-2.93 4.65 4.65 0 0 1-0.75-8.19 3.82 3.82 0 0 0 1.33-2.94 4.51 4.51 0 0 0-3-2 4.6 4.6 0 0 1-4-7.12 3.83 3.83 0 0 0-0.14-3.29 4 4 0 0 0-3.49-0.54 4.68 4.68 0 0 1-6.61-4.62 4.15 4.15 0 0 0-1.44-3.21 4.06 4.06 0 0 0-3.43 1 4.64 4.64 0 0 1-8-2 2.58 2.58 0 0 0-5.08 0 4.67 4.67 0 0 1-8 1.87 4.29 4.29 0 0 0-3.4-0.89 4.47 4.47 0 0 0-1.44 3.29 4.54 4.54 0 0 1-4.12 4.93 4.47 4.47 0 0 1-2.28-0.39 4.65 4.65 0 0 0-3.56 0.36 4.23 4.23 0 0 0-0.21 3.56 4.62 4.62 0 0 1-3.9 7 4.25 4.25 0 0 0-3 1.87 4.1 4.1 0 0 0 1.34 3.2 4.59 4.59 0 0 1 1.13 6.39 4.71 4.71 0 0 1-2 1.62 4.47 4.47 0 0 0-1.91 3 3.7 3.7 0 0 0 2.4 2.23z" fill="#FFFFFF" p-id="1647"></path></svg> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { createPinia } from 'pinia' |
| | | import { createPersistedState } from 'pinia-plugin-persistedstate' // æ°æ®æä¹
å |
| | | |
| | | const store = createPinia() |
| | | store.use( |
| | | createPersistedState({ |
| | | storage: { |
| | | getItem: uni.getStorageSync, |
| | | setItem: uni.setStorageSync, |
| | | }, |
| | | }), |
| | | ) |
| | | |
| | | export default store |
| | | |
| | | // 模åç»ä¸å¯¼åº |
| | | export * from './user' |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | |
| | | const initState = { nickname: '', avatar: '' } |
| | | |
| | | export const useUserStore = defineStore( |
| | | 'user', |
| | | () => { |
| | | const userInfo = ref<IUserInfo>({ ...initState }) |
| | | |
| | | const setUserInfo = (val: IUserInfo) => { |
| | | userInfo.value = val |
| | | } |
| | | |
| | | const clearUserInfo = () => { |
| | | userInfo.value = { ...initState } |
| | | } |
| | | // ä¸è¬æ²¡æresetéæ±ï¼ä¸éè¦çå¯ä»¥å é¤ |
| | | const reset = () => { |
| | | userInfo.value = { ...initState } |
| | | } |
| | | const isLogined = computed(() => !!userInfo.value.token) |
| | | |
| | | return { |
| | | userInfo, |
| | | setUserInfo, |
| | | clearUserInfo, |
| | | isLogined, |
| | | reset, |
| | | } |
| | | }, |
| | | { |
| | | persist: true, |
| | | }, |
| | | ) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | @font-face { |
| | | font-family: 'iconfont'; /* Project id 4543091 */ |
| | | src: |
| | | url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAOwAAsAAAAAB9AAAANjAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACDHAqDBIJqATYCJAMQCwoABCAFhGcHPRvnBsgusG3kMyE15/44PsBX09waBHv0REDt97oHAQDFrOIyPirRiULQ+TJcXV0hCYTuVFcBC915/2vX/32Q80hkZ5PZGZ9snvwruVLloidKqYN6iKC53bOtbKwVLSIi3W6zCWZbs3VbER3j9JpGX3ySYcc94IQRTK5s4epS/jSqIgvg37qlY2/jwQN7D9ADpfRCmIknQByTscVZPTBr+hnnCKg2o4bjakvXEPjuY65DJGeJNtBUhn1JxOBuB2UZmUpBOXdsFp4oxOv4GHgs3h/+wRDcicqSZJG1q9kK1z/Af9NpqxjpC2QaAdpHlCFh4spcYXs5sMWpSk5wUj31G2dLQKVKkZ/w7f/8/i/A3JVUSZK9f7xIKJeU14IFpBI/Qfkkz46GT/CuaGREfCtKJUougWeQWHvVC5Lcz2BGS+SePR99vj3yjJx7h574tp7uWcOh4yfaTjS/245TT/vkQrN+a7RLkK8+Vd+bz+FSGh+9srDQKPeJ2s29z7ah4+efdoxefRbbGwfy7ht+SuIWukzsu1b6ePP+6kN1aamb47qsPim1Ia3xdEpDcl1dckPKGYnneI23+57r2W1Mmkqs6ajrChRCs5qyQ66rTVWhgZaG7toOeHm5cxn0sSQuNDEgcUTdNTSupKI1JRZih/JssAUKezPeOJJzbNozF6zWJuuVavVU5Tgtkop/SDzHa7ytvnCTq0PhkEfi4xLLtb0PuwyOAYqmrYQApFJyoJjTnfz+ve94vvv2f/yWgxl8Jd8Di2DRDPuob59mU/+VfDCROQyR8xSnmP9fXm7liagmN39OlmbvjqG0sMsJKrU0EFXogaRSH5bNY1CmxhyUq7QC1cY1T67RwuQk5CoM2RUQNLoEUb03kDS6h2XzcyjT7iOUa/QXqq1Hn6/GUBAaGcGcWJFlGUmCoVOp8kLvABHnVczGYiOE2SVEUH5OXj/TSnTCDjHAviAWcE4RZYaGWszNiKoayGSGTASeY+PcrMjNpVMvyREMDRoxBMYRVojFMkQiMOhohubdzxtAiOapMMbERpKMnQT9SL4ceQysVdJZVa9kEbsFogIcRyEUE2kN0mL7CDVIGhBzupWMEHA5bDvipgq5hKJcKef8ivbx1kC15KgcYkghhzLxYNntxoKCReJ82jAHAAA=') |
| | | format('woff2'), |
| | | url('//at.alicdn.com/t/c/font_4543091_njpo5b95nl.woff?t=1715485842402') format('woff'), |
| | | url('//at.alicdn.com/t/c/font_4543091_njpo5b95nl.ttf?t=1715485842402') format('truetype'); |
| | | } |
| | | |
| | | .iconfont { |
| | | font-family: 'iconfont' !important; |
| | | font-size: 16px; |
| | | font-style: normal; |
| | | -webkit-font-smoothing: antialiased; |
| | | -moz-osx-font-smoothing: grayscale; |
| | | } |
| | | |
| | | .icon-my:before { |
| | | content: '\e78c'; |
| | | } |
| | | |
| | | .icon-package:before { |
| | | content: '\e9c2'; |
| | | } |
| | | |
| | | .icon-chat:before { |
| | | content: '\e600'; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | @import './iconfont.css'; |
| | | |
| | | .test { |
| | | // å¯ä»¥éè¿ @apply å¤ä¸ªæ ·å¼å°è£
æ´ä½æ ·å¼ |
| | | @apply mt-4 ml-4; |
| | | |
| | | padding-top: 4px; |
| | | color: red; |
| | | } |
| | | |
| | | :root, |
| | | page { |
| | | // ä¿®æ¹æä¸»é¢è² |
| | | // --wot-color-theme: #37c2bc; |
| | | |
| | | // ä¿®æ¹æé®èæ¯è² |
| | | // --wot-button-primary-bg-color: green; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | /* prettier-ignore */ |
| | | // @ts-nocheck |
| | | // noinspection JSUnusedGlobalSymbols |
| | | // Generated by unplugin-auto-import |
| | | export {} |
| | | declare global { |
| | | const EffectScope: typeof import('vue')['EffectScope'] |
| | | const computed: typeof import('vue')['computed'] |
| | | const createApp: typeof import('vue')['createApp'] |
| | | const customRef: typeof import('vue')['customRef'] |
| | | const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] |
| | | const defineComponent: typeof import('vue')['defineComponent'] |
| | | const effectScope: typeof import('vue')['effectScope'] |
| | | const getCurrentInstance: typeof import('vue')['getCurrentInstance'] |
| | | const getCurrentScope: typeof import('vue')['getCurrentScope'] |
| | | const h: typeof import('vue')['h'] |
| | | const inject: typeof import('vue')['inject'] |
| | | const isProxy: typeof import('vue')['isProxy'] |
| | | const isReactive: typeof import('vue')['isReactive'] |
| | | const isReadonly: typeof import('vue')['isReadonly'] |
| | | const isRef: typeof import('vue')['isRef'] |
| | | const markRaw: typeof import('vue')['markRaw'] |
| | | const nextTick: typeof import('vue')['nextTick'] |
| | | const onActivated: typeof import('vue')['onActivated'] |
| | | const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites'] |
| | | const onBackPress: typeof import('@dcloudio/uni-app')['onBackPress'] |
| | | const onBeforeMount: typeof import('vue')['onBeforeMount'] |
| | | const onBeforeUnmount: typeof import('vue')['onBeforeUnmount'] |
| | | const onBeforeUpdate: typeof import('vue')['onBeforeUpdate'] |
| | | const onDeactivated: typeof import('vue')['onDeactivated'] |
| | | const onError: typeof import('@dcloudio/uni-app')['onError'] |
| | | const onErrorCaptured: typeof import('vue')['onErrorCaptured'] |
| | | const onHide: typeof import('@dcloudio/uni-app')['onHide'] |
| | | const onLaunch: typeof import('@dcloudio/uni-app')['onLaunch'] |
| | | const onLoad: typeof import('@dcloudio/uni-app')['onLoad'] |
| | | const onMounted: typeof import('vue')['onMounted'] |
| | | const onNavigationBarButtonTap: typeof import('@dcloudio/uni-app')['onNavigationBarButtonTap'] |
| | | const onNavigationBarSearchInputChanged: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputChanged'] |
| | | const onNavigationBarSearchInputClicked: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputClicked'] |
| | | const onNavigationBarSearchInputConfirmed: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputConfirmed'] |
| | | const onNavigationBarSearchInputFocusChanged: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputFocusChanged'] |
| | | const onPageNotFound: typeof import('@dcloudio/uni-app')['onPageNotFound'] |
| | | const onPageScroll: typeof import('@dcloudio/uni-app')['onPageScroll'] |
| | | const onPullDownRefresh: typeof import('@dcloudio/uni-app')['onPullDownRefresh'] |
| | | const onReachBottom: typeof import('@dcloudio/uni-app')['onReachBottom'] |
| | | const onReady: typeof import('@dcloudio/uni-app')['onReady'] |
| | | const onRenderTracked: typeof import('vue')['onRenderTracked'] |
| | | const onRenderTriggered: typeof import('vue')['onRenderTriggered'] |
| | | const onResize: typeof import('@dcloudio/uni-app')['onResize'] |
| | | const onScopeDispose: typeof import('vue')['onScopeDispose'] |
| | | const onServerPrefetch: typeof import('vue')['onServerPrefetch'] |
| | | const onShareAppMessage: typeof import('@dcloudio/uni-app')['onShareAppMessage'] |
| | | const onShareTimeline: typeof import('@dcloudio/uni-app')['onShareTimeline'] |
| | | const onShow: typeof import('@dcloudio/uni-app')['onShow'] |
| | | const onTabItemTap: typeof import('@dcloudio/uni-app')['onTabItemTap'] |
| | | const onThemeChange: typeof import('@dcloudio/uni-app')['onThemeChange'] |
| | | const onUnhandledRejection: typeof import('@dcloudio/uni-app')['onUnhandledRejection'] |
| | | const onUnload: typeof import('@dcloudio/uni-app')['onUnload'] |
| | | const onUnmounted: typeof import('vue')['onUnmounted'] |
| | | const onUpdated: typeof import('vue')['onUpdated'] |
| | | const onWatcherCleanup: typeof import('vue')['onWatcherCleanup'] |
| | | const provide: typeof import('vue')['provide'] |
| | | const reactive: typeof import('vue')['reactive'] |
| | | const readonly: typeof import('vue')['readonly'] |
| | | const ref: typeof import('vue')['ref'] |
| | | const resolveComponent: typeof import('vue')['resolveComponent'] |
| | | const shallowReactive: typeof import('vue')['shallowReactive'] |
| | | const shallowReadonly: typeof import('vue')['shallowReadonly'] |
| | | const shallowRef: typeof import('vue')['shallowRef'] |
| | | const toRaw: typeof import('vue')['toRaw'] |
| | | const toRef: typeof import('vue')['toRef'] |
| | | const toRefs: typeof import('vue')['toRefs'] |
| | | const toValue: typeof import('vue')['toValue'] |
| | | const triggerRef: typeof import('vue')['triggerRef'] |
| | | const unref: typeof import('vue')['unref'] |
| | | const useAttrs: typeof import('vue')['useAttrs'] |
| | | const useCssModule: typeof import('vue')['useCssModule'] |
| | | const useCssVars: typeof import('vue')['useCssVars'] |
| | | const useId: typeof import('vue')['useId'] |
| | | const useModel: typeof import('vue')['useModel'] |
| | | const useNavbarWeixin: (typeof import('../hooks/useNavbarWeixin'))['default'] |
| | | const useRequest: typeof import('../hooks/useRequest')['default'] |
| | | const useSlots: typeof import('vue')['useSlots'] |
| | | const useTemplateRef: typeof import('vue')['useTemplateRef'] |
| | | const useUpload: typeof import('../hooks/useUpload')['default'] |
| | | const useUpload2: typeof import('../hooks/useUpload2')['default'] |
| | | const watch: typeof import('vue')['watch'] |
| | | const watchEffect: typeof import('vue')['watchEffect'] |
| | | const watchPostEffect: typeof import('vue')['watchPostEffect'] |
| | | const watchSyncEffect: typeof import('vue')['watchSyncEffect'] |
| | | } |
| | | // for type re-export |
| | | declare global { |
| | | // @ts-ignore |
| | | export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' |
| | | import('vue') |
| | | } |
| | | // for vue template auto import |
| | | import { UnwrapRef } from 'vue' |
| | | declare module 'vue' { |
| | | interface GlobalComponents {} |
| | | interface ComponentCustomProperties { |
| | | readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']> |
| | | readonly computed: UnwrapRef<typeof import('vue')['computed']> |
| | | readonly createApp: UnwrapRef<typeof import('vue')['createApp']> |
| | | readonly customRef: UnwrapRef<typeof import('vue')['customRef']> |
| | | readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']> |
| | | readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']> |
| | | readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']> |
| | | readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']> |
| | | readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']> |
| | | readonly h: UnwrapRef<typeof import('vue')['h']> |
| | | readonly inject: UnwrapRef<typeof import('vue')['inject']> |
| | | readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']> |
| | | readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']> |
| | | readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']> |
| | | readonly isRef: UnwrapRef<typeof import('vue')['isRef']> |
| | | readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']> |
| | | readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']> |
| | | readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']> |
| | | readonly onAddToFavorites: UnwrapRef<typeof import('@dcloudio/uni-app')['onAddToFavorites']> |
| | | readonly onBackPress: UnwrapRef<typeof import('@dcloudio/uni-app')['onBackPress']> |
| | | readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']> |
| | | readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']> |
| | | readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']> |
| | | readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']> |
| | | readonly onError: UnwrapRef<typeof import('@dcloudio/uni-app')['onError']> |
| | | readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']> |
| | | readonly onHide: UnwrapRef<typeof import('@dcloudio/uni-app')['onHide']> |
| | | readonly onLaunch: UnwrapRef<typeof import('@dcloudio/uni-app')['onLaunch']> |
| | | readonly onLoad: UnwrapRef<typeof import('@dcloudio/uni-app')['onLoad']> |
| | | readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']> |
| | | readonly onNavigationBarButtonTap: UnwrapRef<typeof import('@dcloudio/uni-app')['onNavigationBarButtonTap']> |
| | | readonly onNavigationBarSearchInputChanged: UnwrapRef<typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputChanged']> |
| | | readonly onNavigationBarSearchInputClicked: UnwrapRef<typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputClicked']> |
| | | readonly onNavigationBarSearchInputConfirmed: UnwrapRef<typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputConfirmed']> |
| | | readonly onNavigationBarSearchInputFocusChanged: UnwrapRef<typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputFocusChanged']> |
| | | readonly onPageNotFound: UnwrapRef<typeof import('@dcloudio/uni-app')['onPageNotFound']> |
| | | readonly onPageScroll: UnwrapRef<typeof import('@dcloudio/uni-app')['onPageScroll']> |
| | | readonly onPullDownRefresh: UnwrapRef<typeof import('@dcloudio/uni-app')['onPullDownRefresh']> |
| | | readonly onReachBottom: UnwrapRef<typeof import('@dcloudio/uni-app')['onReachBottom']> |
| | | readonly onReady: UnwrapRef<typeof import('@dcloudio/uni-app')['onReady']> |
| | | readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']> |
| | | readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']> |
| | | readonly onResize: UnwrapRef<typeof import('@dcloudio/uni-app')['onResize']> |
| | | readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']> |
| | | readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']> |
| | | readonly onShareAppMessage: UnwrapRef<typeof import('@dcloudio/uni-app')['onShareAppMessage']> |
| | | readonly onShareTimeline: UnwrapRef<typeof import('@dcloudio/uni-app')['onShareTimeline']> |
| | | readonly onShow: UnwrapRef<typeof import('@dcloudio/uni-app')['onShow']> |
| | | readonly onTabItemTap: UnwrapRef<typeof import('@dcloudio/uni-app')['onTabItemTap']> |
| | | readonly onThemeChange: UnwrapRef<typeof import('@dcloudio/uni-app')['onThemeChange']> |
| | | readonly onUnhandledRejection: UnwrapRef<typeof import('@dcloudio/uni-app')['onUnhandledRejection']> |
| | | readonly onUnload: UnwrapRef<typeof import('@dcloudio/uni-app')['onUnload']> |
| | | readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']> |
| | | readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']> |
| | | readonly onWatcherCleanup: UnwrapRef<typeof import('vue')['onWatcherCleanup']> |
| | | readonly provide: UnwrapRef<typeof import('vue')['provide']> |
| | | readonly reactive: UnwrapRef<typeof import('vue')['reactive']> |
| | | readonly readonly: UnwrapRef<typeof import('vue')['readonly']> |
| | | readonly ref: UnwrapRef<typeof import('vue')['ref']> |
| | | readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']> |
| | | readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']> |
| | | readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']> |
| | | readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']> |
| | | readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']> |
| | | readonly toRef: UnwrapRef<typeof import('vue')['toRef']> |
| | | readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']> |
| | | readonly toValue: UnwrapRef<typeof import('vue')['toValue']> |
| | | readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']> |
| | | readonly unref: UnwrapRef<typeof import('vue')['unref']> |
| | | readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']> |
| | | readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']> |
| | | readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']> |
| | | readonly useId: UnwrapRef<typeof import('vue')['useId']> |
| | | readonly useModel: UnwrapRef<typeof import('vue')['useModel']> |
| | | readonly useRequest: UnwrapRef<typeof import('../hooks/useRequest')['default']> |
| | | readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']> |
| | | readonly useTemplateRef: UnwrapRef<typeof import('vue')['useTemplateRef']> |
| | | readonly useUpload: UnwrapRef<typeof import('../hooks/useUpload')['default']> |
| | | readonly watch: UnwrapRef<typeof import('vue')['watch']> |
| | | readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']> |
| | | readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']> |
| | | readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']> |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | declare const __UNI_PLATFORM__: |
| | | | 'h5' |
| | | | 'app' |
| | | | 'mp-alipay' |
| | | | 'mp-baidu' |
| | | | 'mp-jd' |
| | | | 'mp-kuaishou' |
| | | | 'mp-lark' |
| | | | 'mp-qq' |
| | | | 'mp-toutiao' |
| | | | 'mp-weixin' |
| | | | 'quickapp-webview' |
| | | | 'quickapp-webview-huawei' |
| | | | 'quickapp-webview-union' |
| | | |
| | | declare const __VITE_APP_PROXY__: 'true' | 'false' |
| | | |
| | | declare namespace JSX { |
| | | interface IntrinsicElements { |
| | | template: any |
| | | block: any |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /// <reference types='@dcloudio/types' /> |
| | | import 'vue' |
| | | |
| | | declare module '@vue/runtime-core' { |
| | | type Hooks = App.AppInstance & Page.PageInstance |
| | | |
| | | interface ComponentCustomOptions extends Hooks {} |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* eslint-disable */ |
| | | /* prettier-ignore */ |
| | | // @ts-nocheck |
| | | // Generated by vite-plugin-uni-pages |
| | | |
| | | interface NavigateToOptions { |
| | | url: "/pages/home/index" | |
| | | "/pages/equ/index" | |
| | | "/pages/login/index" | |
| | | "/pages/my/index" | |
| | | "/pages/spare/index"; |
| | | } |
| | | interface RedirectToOptions extends NavigateToOptions {} |
| | | |
| | | interface SwitchTabOptions { |
| | | url: "/pages/home/index" | "/pages/equ/index" | "/pages/equ/index" | "/pages/spare/index" | "/pages/my/index" |
| | | } |
| | | |
| | | type ReLaunchOptions = NavigateToOptions | SwitchTabOptions; |
| | | |
| | | declare interface Uni { |
| | | navigateTo(options: UniNamespace.NavigateToOptions & NavigateToOptions): void; |
| | | redirectTo(options: UniNamespace.RedirectToOptions & RedirectToOptions): void; |
| | | switchTab(options: UniNamespace.SwitchTabOptions & SwitchTabOptions): void; |
| | | reLaunch(options: UniNamespace.ReLaunchOptions & ReLaunchOptions): void; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // å
¨å±è¦ç¨çç±»åæ¾å°è¿é |
| | | |
| | | declare global { |
| | | type IResData<T> = { |
| | | code: number |
| | | msg: string |
| | | data: T |
| | | } |
| | | |
| | | // uni.uploadFileæä»¶ä¸ä¼ åæ° |
| | | type IUniUploadFileOptions = { |
| | | file?: File |
| | | files?: UniApp.UploadFileOptionFiles[] |
| | | filePath?: string |
| | | name?: string |
| | | formData?: any |
| | | } |
| | | |
| | | type IUserInfo = { |
| | | nickname?: string |
| | | avatar?: string |
| | | /** 微信ç openidï¼é微信没æè¿ä¸ªå段 */ |
| | | openid?: string |
| | | token?: string |
| | | } |
| | | } |
| | | |
| | | export {} // 鲿¢æ¨¡å污æ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // æä¸¾å®ä¹ |
| | | |
| | | export enum TestEnum { |
| | | A = '1', |
| | | B = '2', |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* stylelint-disable comment-empty-line-before */ |
| | | /** |
| | | * è¿éæ¯uni-appå
ç½®çå¸¸ç¨æ ·å¼åé |
| | | * |
| | | * uni-app 宿¹æ©å±æä»¶åæä»¶å¸åºï¼https://ext.dcloud.net.cnï¼ä¸å¾å¤ä¸æ¹æä»¶å使ç¨äºè¿äºæ ·å¼åé |
| | | * å¦æä½ æ¯æä»¶å¼åè
ï¼å»ºè®®ä½ 使ç¨scssé¢å¤çï¼å¹¶å¨æä»¶ä»£ç ä¸ç´æ¥ä½¿ç¨è¿äºåéï¼æ é import è¿ä¸ªæä»¶ï¼ï¼æ¹ä¾¿ç¨æ·éè¿æç§¯æ¨çæ¹å¼å¼åæ´ä½é£æ ¼ä¸è´çApp |
| | | * |
| | | */ |
| | | |
| | | /** |
| | | * å¦æä½ æ¯Appå¼åè
ï¼æä»¶ä½¿ç¨è
ï¼ï¼ä½ å¯ä»¥éè¿ä¿®æ¹è¿äºå鿥å®å¶èªå·±çæä»¶ä¸»é¢ï¼å®ç°èªå®ä¹ä¸»é¢åè½ |
| | | * |
| | | * å¦æä½ ç项ç®åæ ·ä½¿ç¨äºscssé¢å¤çï¼ä½ ä¹å¯ä»¥ç´æ¥å¨ä½ ç scss 代ç ä¸ä½¿ç¨å¦ä¸åéï¼åæ¶æ é import è¿ä¸ªæä»¶ |
| | | */ |
| | | |
| | | /* é¢è²åé */ |
| | | |
| | | /* è¡ä¸ºç¸å
³é¢è² */ |
| | | $uni-color-primary: #007aff; |
| | | $uni-color-success: #4cd964; |
| | | $uni-color-warning: #f0ad4e; |
| | | $uni-color-error: #dd524d; |
| | | |
| | | /* æååºæ¬é¢è² */ |
| | | $uni-text-color: #333; // åºæ¬è² |
| | | $uni-text-color-inverse: #fff; // åè² |
| | | $uni-text-color-grey: #999; // è¾
å©ç°è²ï¼å¦å è½½æ´å¤çæç¤ºä¿¡æ¯ |
| | | $uni-text-color-placeholder: #808080; |
| | | $uni-text-color-disable: #c0c0c0; |
| | | |
| | | /* èæ¯é¢è² */ |
| | | $uni-bg-color: #fff; |
| | | $uni-bg-color-grey: #f8f8f8; |
| | | $uni-bg-color-hover: #f1f1f1; // ç¹å»ç¶æé¢è² |
| | | $uni-bg-color-mask: rgb(0 0 0 / 40%); // é®ç½©é¢è² |
| | | |
| | | /* è¾¹æ¡é¢è² */ |
| | | $uni-border-color: #c8c7cc; |
| | | |
| | | /* 尺寸åé */ |
| | | |
| | | /* æå尺寸 */ |
| | | $uni-font-size-sm: 12px; |
| | | $uni-font-size-base: 14px; |
| | | $uni-font-size-lg: 16; |
| | | |
| | | /* å¾ç尺寸 */ |
| | | $uni-img-size-sm: 20px; |
| | | $uni-img-size-base: 26px; |
| | | $uni-img-size-lg: 40px; |
| | | |
| | | /* Border Radius */ |
| | | $uni-border-radius-sm: 2px; |
| | | $uni-border-radius-base: 3px; |
| | | $uni-border-radius-lg: 6px; |
| | | $uni-border-radius-circle: 50%; |
| | | |
| | | /* æ°´å¹³é´è· */ |
| | | $uni-spacing-row-sm: 5px; |
| | | $uni-spacing-row-base: 10px; |
| | | $uni-spacing-row-lg: 15px; |
| | | |
| | | /* åç´é´è· */ |
| | | $uni-spacing-col-sm: 4px; |
| | | $uni-spacing-col-base: 8px; |
| | | $uni-spacing-col-lg: 12px; |
| | | |
| | | /* éæåº¦ */ |
| | | $uni-opacity-disabled: 0.3; // ç»ä»¶ç¦ç¨æçéæåº¦ |
| | | |
| | | /* æç« åºæ¯ç¸å
³ */ |
| | | $uni-color-title: #2c405a; // æç« æ é¢é¢è² |
| | | $uni-font-size-title: 20px; |
| | | $uni-color-subtitle: #555; // äºçº§æ é¢é¢è² |
| | | $uni-font-size-subtitle: 18px; |
| | | $uni-color-paragraph: #3f536e; // æç« 段è½é¢è² |
| | | $uni-font-size-paragraph: 15px; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { CustomRequestOptions } from '@/interceptors/request' |
| | | |
| | | export const http = <T>(options: CustomRequestOptions) => { |
| | | // 1. è¿å Promise 对象 |
| | | return new Promise<IResData<T>>((resolve, reject) => { |
| | | uni.request({ |
| | | ...options, |
| | | dataType: 'json', |
| | | // #ifndef MP-WEIXIN |
| | | responseType: 'json', |
| | | // #endif |
| | | // ååºæå |
| | | success(res) { |
| | | // ç¶æç 2xxï¼åè axios ç设计 |
| | | if (res.statusCode >= 200 && res.statusCode < 300) { |
| | | // 2.1 æåæ ¸å¿æ°æ® res.data |
| | | resolve(res.data as IResData<T>) |
| | | } else if (res.statusCode === 401) { |
| | | // 401é误 -> æ¸
çç¨æ·ä¿¡æ¯ï¼è·³è½¬å°ç»å½é¡µ |
| | | // userStore.clearUserInfo() |
| | | // uni.navigateTo({ url: '/pages/login/login' }) |
| | | reject(res) |
| | | } else { |
| | | // å
¶ä»é误 -> æ ¹æ®å端é误信æ¯è½»æç¤º |
| | | !options.hideErrorToast && |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: (res.data as IResData<T>).msg || '请æ±é误', |
| | | }) |
| | | reject(res) |
| | | } |
| | | }, |
| | | // ååºå¤±è´¥ |
| | | fail(err) { |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: 'ç½ç»éè¯¯ï¼æ¢ä¸ªç½ç»è¯è¯', |
| | | }) |
| | | reject(err) |
| | | }, |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * GET è¯·æ± |
| | | * @param url åå°å°å |
| | | * @param query 请æ±queryåæ° |
| | | * @returns |
| | | */ |
| | | export const httpGet = <T>(url: string, query?: Record<string, any>) => { |
| | | return http<T>({ |
| | | url, |
| | | query, |
| | | method: 'GET', |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * POST è¯·æ± |
| | | * @param url åå°å°å |
| | | * @param data 请æ±bodyåæ° |
| | | * @param query 请æ±queryåæ°ï¼post请æ±ä¹æ¯æqueryï¼å¾å¤å¾®ä¿¡æ¥å£é½éè¦ |
| | | * @returns |
| | | */ |
| | | export const httpPost = <T>( |
| | | url: string, |
| | | data?: Record<string, any>, |
| | | query?: Record<string, any>, |
| | | ) => { |
| | | return http<T>({ |
| | | url, |
| | | query, |
| | | data, |
| | | method: 'POST', |
| | | }) |
| | | } |
| | | |
| | | http.get = httpGet |
| | | http.post = httpPost |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { pages, subPackages, tabBar } from '@/pages.json' |
| | | import { isMpWeixin } from './platform' |
| | | |
| | | const getLastPage = () => { |
| | | // getCurrentPages() è³å°æ1个å
ç´ ï¼æä»¥ä¸åé¢å¤å¤æ |
| | | // const lastPage = getCurrentPages().at(-1) |
| | | // ä¸é¢é£ä¸ªå¨ä½çæ¬å®å䏿å
伿¥éï¼æä»¥æ¹ç¨ä¸é¢è¿ä¸ªãè½ç¶æå äº src/interceptions/prototype.tsï¼ä½ä¾ç¶æ¥éã |
| | | const pages = getCurrentPages() |
| | | return pages[pages.length - 1] |
| | | } |
| | | |
| | | /** 夿å½å页颿¯å¦æ¯ tabbar 页 */ |
| | | export const getIsTabbar = () => { |
| | | if (!tabBar) { |
| | | return false |
| | | } |
| | | if (!tabBar.list.length) { |
| | | // é常æ tabBar çè¯ï¼list ä¸è½æç©ºï¼ä¸è³å°æ2个å
ç´ ï¼è¿éå
¶å®ä¸ç¨å¤ç |
| | | return false |
| | | } |
| | | const lastPage = getLastPage() |
| | | const currPath = lastPage.route |
| | | return !!tabBar.list.find((e) => e.pagePath === currPath) |
| | | } |
| | | |
| | | /** |
| | | * è·åå½å页é¢è·¯ç±ç path è·¯å¾å redirectPath è·¯å¾ |
| | | * path å¦ '/pages/login/index' |
| | | * redirectPath å¦ '/pages/demo/base/route-interceptor' |
| | | */ |
| | | export const currRoute = () => { |
| | | const lastPage = getLastPage() |
| | | const currRoute = (lastPage as any).$page |
| | | // console.log('lastPage.$page:', currRoute) |
| | | // console.log('lastPage.$page.fullpath:', currRoute.fullPath) |
| | | // console.log('lastPage.$page.options:', currRoute.options) |
| | | // console.log('lastPage.options:', (lastPage as any).options) |
| | | // ç»è¿å¤ç«¯æµè¯ï¼åªæ fullPath é è°±ï¼å
¶ä»é½ä¸é è°± |
| | | const { fullPath } = currRoute as { fullPath: string } |
| | | // console.log(fullPath) |
| | | // eg: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor (å°ç¨åº) |
| | | // eg: /pages/login/index?redirect=%2Fpages%2Froute-interceptor%2Findex%3Fname%3Dfeige%26age%3D30(h5) |
| | | return getUrlObj(fullPath) |
| | | } |
| | | |
| | | const ensureDecodeURIComponent = (url: string) => { |
| | | if (url.startsWith('%')) { |
| | | return ensureDecodeURIComponent(decodeURIComponent(url)) |
| | | } |
| | | return url |
| | | } |
| | | /** |
| | | * è§£æ url å¾å° path å query |
| | | * æ¯å¦è¾å
¥url: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor |
| | | * è¾åº: {path: /pages/login/index, query: {redirect: /pages/demo/base/route-interceptor}} |
| | | */ |
| | | export const getUrlObj = (url: string) => { |
| | | const [path, queryStr] = url.split('?') |
| | | // console.log(path, queryStr) |
| | | |
| | | if (!queryStr) { |
| | | return { |
| | | path, |
| | | query: {}, |
| | | } |
| | | } |
| | | const query: Record<string, string> = {} |
| | | queryStr.split('&').forEach((item) => { |
| | | const [key, value] = item.split('=') |
| | | // console.log(key, value) |
| | | query[key] = ensureDecodeURIComponent(value) // è¿ééè¦ç»ä¸ decodeURIComponent ä¸ä¸ï¼å¯ä»¥å
¼å®¹h5å微信y |
| | | }) |
| | | return { path, query } |
| | | } |
| | | /** |
| | | * å¾å°ææçéè¦ç»å½ç pagesï¼å
æ¬ä¸»å
ååå
ç |
| | | * è¿é设计å¾éç¨ä¸ç¹ï¼å¯ä»¥ä¼ é key ä½ä¸ºå¤æä¾æ®ï¼é»è®¤æ¯ needLogin, ä¸ route-block é
å¯¹ä½¿ç¨ |
| | | * å¦ææ²¡æä¼ keyï¼å表示ææç pagesï¼å¦æä¼ éäº key, å表示éè¿ key è¿æ»¤ |
| | | */ |
| | | export const getAllPages = (key = 'needLogin') => { |
| | | // è¿éå¤ç主å
|
| | | const mainPages = [ |
| | | ...pages |
| | | .filter((page) => !key || page[key]) |
| | | .map((page) => ({ |
| | | ...page, |
| | | path: `/${page.path}`, |
| | | })), |
| | | ] |
| | | // è¿éå¤çåå
|
| | | const subPages: any[] = [] |
| | | subPackages.forEach((subPageObj) => { |
| | | // console.log(subPageObj) |
| | | const { root } = subPageObj |
| | | |
| | | subPageObj.pages |
| | | .filter((page) => !key || page[key]) |
| | | .forEach((page: { path: string } & Record<string, any>) => { |
| | | subPages.push({ |
| | | ...page, |
| | | path: `/${root}/${page.path}`, |
| | | }) |
| | | }) |
| | | }) |
| | | const result = [...mainPages, ...subPages] |
| | | // console.log(`getAllPages by ${key} result: `, result) |
| | | return result |
| | | } |
| | | |
| | | /** |
| | | * å¾å°ææçéè¦ç»å½ç pagesï¼å
æ¬ä¸»å
ååå
ç |
| | | * åªå¾å° path æ°ç» |
| | | */ |
| | | export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map((page) => page.path) |
| | | |
| | | /** |
| | | * å¾å°ææçéè¦ç»å½ç pagesï¼å
æ¬ä¸»å
ååå
ç |
| | | * åªå¾å° path æ°ç» |
| | | */ |
| | | export const needLoginPages: string[] = getAllPages('needLogin').map((page) => page.path) |
| | | |
| | | /** |
| | | * æ ¹æ®å¾®ä¿¡å°ç¨åºå½åç¯å¢ï¼å¤æåºè¯¥è·åç baseUrl |
| | | */ |
| | | export const getEnvBaseUrl = () => { |
| | | // 请æ±åºåå°å |
| | | let baseUrl = import.meta.env.VITE_SERVER_BASEURL |
| | | |
| | | // 微信å°ç¨åºç«¯ç¯å¢åºå |
| | | if (isMpWeixin) { |
| | | const { |
| | | miniProgram: { envVersion }, |
| | | } = uni.getAccountInfoSync() |
| | | |
| | | switch (envVersion) { |
| | | case 'develop': |
| | | baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_DEVELOP || baseUrl |
| | | break |
| | | case 'trial': |
| | | baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_TRIAL || baseUrl |
| | | break |
| | | case 'release': |
| | | baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_RELEASE || baseUrl |
| | | break |
| | | } |
| | | } |
| | | |
| | | return baseUrl |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å¾®ä¿¡å°ç¨åºå½åç¯å¢ï¼å¤æåºè¯¥è·åç UPLOAD_BASEURL |
| | | */ |
| | | export const getEnvBaseUploadUrl = () => { |
| | | // 请æ±åºåå°å |
| | | let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL |
| | | |
| | | // 微信å°ç¨åºç«¯ç¯å¢åºå |
| | | if (isMpWeixin) { |
| | | const { |
| | | miniProgram: { envVersion }, |
| | | } = uni.getAccountInfoSync() |
| | | |
| | | switch (envVersion) { |
| | | case 'develop': |
| | | baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP || baseUploadUrl |
| | | break |
| | | case 'trial': |
| | | baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_TRIAL || baseUploadUrl |
| | | break |
| | | case 'release': |
| | | baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_RELEASE || baseUploadUrl |
| | | break |
| | | } |
| | | } |
| | | |
| | | return baseUploadUrl |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * @Author: è²é¸½ |
| | | * @Date: 2024-03-28 19:13:55 |
| | | * @Last Modified by: è²é¸½ |
| | | * @Last Modified time: 2024-03-28 19:24:55 |
| | | */ |
| | | export const platform = __UNI_PLATFORM__ |
| | | export const isH5 = __UNI_PLATFORM__ === 'h5' |
| | | export const isApp = __UNI_PLATFORM__ === 'app' |
| | | export const isMp = __UNI_PLATFORM__.startsWith('mp-') |
| | | export const isMpWeixin = __UNI_PLATFORM__.startsWith('mp-weixin') |
| | | export const isMpAplipay = __UNI_PLATFORM__.startsWith('mp-alipay') |
| | | export const isMpToutiao = __UNI_PLATFORM__.startsWith('mp-toutiao') |
| | | |
| | | const PLATFORM = { |
| | | platform, |
| | | isH5, |
| | | isApp, |
| | | isMp, |
| | | isMpWeixin, |
| | | isMpAplipay, |
| | | isMpToutiao, |
| | | } |
| | | export default PLATFORM |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { CustomRequestOptions } from '@/interceptors/request' |
| | | |
| | | /** |
| | | * è¯·æ±æ¹æ³: ä¸»è¦æ¯å¯¹ uni.request çå°è£
ï¼å»éé
openapi-ts-request ç request æ¹æ³ |
| | | * @param options 请æ±åæ° |
| | | * @returns è¿å Promise 对象 |
| | | */ |
| | | const http = <T>(options: CustomRequestOptions) => { |
| | | // 1. è¿å Promise 对象 |
| | | return new Promise<T>((resolve, reject) => { |
| | | uni.request({ |
| | | ...options, |
| | | dataType: 'json', |
| | | // #ifndef MP-WEIXIN |
| | | responseType: 'json', |
| | | // #endif |
| | | // ååºæå |
| | | success(res) { |
| | | // ç¶æç 2xxï¼åè axios ç设计 |
| | | if (res.statusCode >= 200 && res.statusCode < 300) { |
| | | // 2.1 æåæ ¸å¿æ°æ® res.data |
| | | resolve(res.data as T) |
| | | } else if (res.statusCode === 401) { |
| | | // 401é误 -> æ¸
çç¨æ·ä¿¡æ¯ï¼è·³è½¬å°ç»å½é¡µ |
| | | // userStore.clearUserInfo() |
| | | // uni.navigateTo({ url: '/pages/login/login' }) |
| | | reject(res) |
| | | } else { |
| | | // å
¶ä»é误 -> æ ¹æ®å端é误信æ¯è½»æç¤º |
| | | !options.hideErrorToast && |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: (res.data as T & { msg?: string })?.msg || '请æ±é误', |
| | | }) |
| | | reject(res) |
| | | } |
| | | }, |
| | | // ååºå¤±è´¥ |
| | | fail(err) { |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: 'ç½ç»éè¯¯ï¼æ¢ä¸ªç½ç»è¯è¯', |
| | | }) |
| | | reject(err) |
| | | }, |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /* |
| | | * openapi-ts-request å·¥å
·ç request 跨客æ·ç«¯éé
æ¹æ³ |
| | | */ |
| | | export default function request<T = unknown>( |
| | | url: string, |
| | | options: Omit<CustomRequestOptions, 'url'> & { |
| | | params?: Record<string, unknown> |
| | | headers?: Record<string, unknown> |
| | | }, |
| | | ) { |
| | | const requestOptions = { |
| | | url, |
| | | ...options, |
| | | } |
| | | |
| | | if (options.params) { |
| | | requestOptions.query = requestOptions.params |
| | | delete requestOptions.params |
| | | } |
| | | |
| | | if (options.headers) { |
| | | requestOptions.header = options.headers |
| | | delete requestOptions.headers |
| | | } |
| | | |
| | | return http<T>(requestOptions) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "compilerOptions": { |
| | | "composite": true, |
| | | "skipLibCheck": true, |
| | | "module": "ESNext", |
| | | "moduleResolution": "Node", |
| | | "resolveJsonModule": true, |
| | | "noImplicitThis": true, |
| | | "allowSyntheticDefaultImports": true, |
| | | "allowJs": true, |
| | | "sourceMap": true, |
| | | "baseUrl": ".", |
| | | "paths": { |
| | | "@/*": ["./src/*"] |
| | | }, |
| | | "outDir": "dist", |
| | | "lib": ["esnext", "dom"], |
| | | "types": [ |
| | | "@dcloudio/types", |
| | | "@uni-helper/uni-types", |
| | | "@types/wechat-miniprogram", |
| | | "wot-design-uni/global.d.ts", |
| | | "z-paging/types", |
| | | "./src/typings.d.ts" |
| | | ] |
| | | }, |
| | | "vueCompilerOptions": { |
| | | "plugins": ["@uni-helper/uni-types/volar-plugin"] |
| | | }, |
| | | "exclude": ["node_modules"], |
| | | "include": [ |
| | | "src/**/*.ts", |
| | | "src/**/*.js", |
| | | "src/**/*.d.ts", |
| | | "src/**/*.tsx", |
| | | "src/**/*.jsx", |
| | | "src/**/*.vue", |
| | | "src/**/*.json" |
| | | ] |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // uno.config.ts |
| | | import { |
| | | type Preset, |
| | | defineConfig, |
| | | presetUno, |
| | | presetAttributify, |
| | | presetIcons, |
| | | transformerDirectives, |
| | | transformerVariantGroup, |
| | | } from 'unocss' |
| | | |
| | | import { presetApplet, presetRemRpx, transformerAttributify } from 'unocss-applet' |
| | | |
| | | // @see https://unocss.dev/presets/legacy-compat |
| | | // import { presetLegacyCompat } from '@unocss/preset-legacy-compat' |
| | | |
| | | const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false |
| | | |
| | | const presets: Preset[] = [] |
| | | if (isMp) { |
| | | // 使ç¨å°ç¨åºé¢è®¾ |
| | | presets.push(presetApplet(), presetRemRpx()) |
| | | } else { |
| | | presets.push( |
| | | // éå°ç¨åºç¨å®æ¹é¢è®¾ |
| | | presetUno(), |
| | | // æ¯æcss class屿§å |
| | | presetAttributify(), |
| | | ) |
| | | } |
| | | export default defineConfig({ |
| | | presets: [ |
| | | ...presets, |
| | | // æ¯æå¾æ ï¼éè¦æé
徿 åºï¼eg: @iconify-json/carbon, ä½¿ç¨ `<button class="i-carbon-sun dark:i-carbon-moon" />` |
| | | presetIcons({ |
| | | scale: 1.2, |
| | | warn: true, |
| | | extraProperties: { |
| | | display: 'inline-block', |
| | | 'vertical-align': 'middle', |
| | | }, |
| | | }), |
| | | // å°é¢è²å½æ° (rgb()åhsl()) ä»ç©ºæ ¼åé转æ¢ä¸ºéå·åéï¼æ´å¥½çå
¼å®¹æ§app端ï¼exampleï¼ |
| | | // `rgb(255 0 0)` -> `rgb(255, 0, 0)` |
| | | // `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)` |
| | | // ä¸ç¾¤åçæ£å¸¸åæ³å²çªï¼å
廿ï¼ï¼2024-05-25ï¼ |
| | | // presetLegacyCompat({ |
| | | // commaStyleColorFunction: true, |
| | | // }) as Preset, |
| | | ], |
| | | /** |
| | | * èªå®ä¹å¿«æ·è¯å¥ |
| | | * @see https://github.com/unocss/unocss#shortcuts |
| | | */ |
| | | shortcuts: [['center', 'flex justify-center items-center']], |
| | | transformers: [ |
| | | // å¯ç¨ @apply åè½ |
| | | transformerDirectives(), |
| | | // å¯ç¨ () åç»åè½ |
| | | // æ¯æcss classç»åï¼eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">æµè¯ unocss</div>` |
| | | transformerVariantGroup(), |
| | | // Don't change the following order |
| | | transformerAttributify({ |
| | | // è§£å³ä¸ç¬¬ä¸æ¹æ¡æ¶æ ·å¼å²çªé®é¢ |
| | | prefixedOnly: true, |
| | | prefix: 'fg', |
| | | }), |
| | | ], |
| | | rules: [ |
| | | [ |
| | | 'p-safe', |
| | | { |
| | | padding: |
| | | 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)', |
| | | }, |
| | | ], |
| | | ['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }], |
| | | ['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }], |
| | | ], |
| | | }) |
| | | |
| | | /** |
| | | * æç»è¿ä¸å¥ç»å䏿¥ä¼å¾å°ï¼ |
| | | * mp éé¢ï¼mt-4 => margin-top: 32rpx == 16px |
| | | * h5 éé¢ï¼mt-4 => margin-top: 1rem == 16px |
| | | * |
| | | * 妿æ¯ä¼ ç»æ¹å¼åæ ·å¼ï¼åæ¨è设计稿设置为 750ï¼è¿æ ·è®¾è®¡ç¨¿1pxï¼ä»£ç å1rpxã |
| | | * rpxæ¯ååºå¼çï¼å¯ä»¥è®©ä¸å设å¤çå±å¹æ¾ç¤ºææä¿æä¸è´ã |
| | | */ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import fs from 'fs-extra' |
| | | import path from 'path' |
| | | |
| | | export function copyNativeRes() { |
| | | const waitPath = path.resolve(__dirname, '../src/nativeResources') |
| | | const buildPath = path.resolve( |
| | | __dirname, |
| | | '../dist', |
| | | process.env.NODE_ENV === 'production' ? 'build' : 'dev', |
| | | process.env.UNI_PLATFORM!, |
| | | 'nativeResources', |
| | | ) |
| | | |
| | | return { |
| | | enforce: 'post', |
| | | async writeBundle() { |
| | | try { |
| | | // æ£æ¥æºç®å½æ¯å¦åå¨ |
| | | const sourceExists = await fs.pathExists(waitPath) |
| | | if (!sourceExists) { |
| | | console.warn(`[copyNativeRes] è¦åï¼æºç®å½ "${waitPath}" ä¸åå¨ï¼è·³è¿å¤å¶æä½ã`) |
| | | return |
| | | } |
| | | |
| | | // ç¡®ä¿ç®æ ç®å½åä¸é´ç®å½åå¨ |
| | | await fs.ensureDir(buildPath) |
| | | console.log(`[copyNativeRes] ç¡®ä¿ç®æ ç®å½åå¨ï¼${buildPath}`) |
| | | |
| | | // æ§è¡æä»¶å¤¹å¤å¶ |
| | | await fs.copy(waitPath, buildPath) |
| | | console.log( |
| | | `[copyNativeRes] æåå° nativeResources ç®å½ä¸çèµæºç§»å¨å°æå»ºç®å½ï¼${buildPath}`, |
| | | ) |
| | | } catch (error) { |
| | | console.error(`[copyNativeRes] å¤å¶èµæºå¤±è´¥ï¼`, error) |
| | | } |
| | | }, |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import Uni from '@dcloudio/vite-plugin-uni' |
| | | import dayjs from 'dayjs' |
| | | import path from 'node:path' |
| | | import { defineConfig, loadEnv } from 'vite' |
| | | // @see https://uni-helper.js.org/vite-plugin-uni-pages |
| | | import UniPages from '@uni-helper/vite-plugin-uni-pages' |
| | | // @see https://uni-helper.js.org/vite-plugin-uni-layouts |
| | | import UniLayouts from '@uni-helper/vite-plugin-uni-layouts' |
| | | // @see https://github.com/uni-helper/vite-plugin-uni-platform |
| | | // éè¦ä¸ @uni-helper/vite-plugin-uni-pages æä»¶ä¸èµ·ä½¿ç¨ |
| | | import UniPlatform from '@uni-helper/vite-plugin-uni-platform' |
| | | // @see https://github.com/uni-helper/vite-plugin-uni-manifest |
| | | import UniManifest from '@uni-helper/vite-plugin-uni-manifest' |
| | | // @see https://unocss.dev/ |
| | | import { visualizer } from 'rollup-plugin-visualizer' |
| | | import UnoCSS from 'unocss/vite' |
| | | import AutoImport from 'unplugin-auto-import/vite' |
| | | import ViteRestart from 'vite-plugin-restart' |
| | | import { copyNativeRes } from './vite-plugins/copyNativeRes' |
| | | |
| | | // https://vitejs.dev/config/ |
| | | export default ({ command, mode }) => { |
| | | // console.log(mode === process.env.NODE_ENV) // true |
| | | |
| | | // mode: åºåç产ç¯å¢è¿æ¯å¼åç¯å¢ |
| | | console.log('command, mode -> ', command, mode) |
| | | // pnpm dev:h5 æ¶å¾å° => serve development |
| | | // pnpm build:h5 æ¶å¾å° => build production |
| | | // pnpm dev:mp-weixin æ¶å¾å° => build development (注æåºå«ï¼command为build) |
| | | // pnpm build:mp-weixin æ¶å¾å° => build production |
| | | // pnpm dev:app æ¶å¾å° => build development (注æåºå«ï¼command为build) |
| | | // pnpm build:app æ¶å¾å° => build production |
| | | // dev å build å½ä»¤å¯ä»¥åå«ä½¿ç¨ .env.development å .env.production çç¯å¢åé |
| | | |
| | | const { UNI_PLATFORM } = process.env |
| | | console.log('UNI_PLATFORM -> ', UNI_PLATFORM) // å¾å° mp-weixin, h5, app ç |
| | | |
| | | const env = loadEnv(mode, path.resolve(process.cwd(), 'env')) |
| | | const { |
| | | VITE_APP_PORT, |
| | | VITE_SERVER_BASEURL, |
| | | VITE_DELETE_CONSOLE, |
| | | VITE_SHOW_SOURCEMAP, |
| | | VITE_APP_PROXY, |
| | | VITE_APP_PROXY_PREFIX, |
| | | } = env |
| | | console.log('ç¯å¢åé env -> ', env) |
| | | |
| | | return defineConfig({ |
| | | envDir: './env', // èªå®ä¹envç®å½ |
| | | |
| | | plugins: [ |
| | | UniPages({ |
| | | exclude: ['**/components/**/**.*'], |
| | | routeBlockLang: 'json5', // è½ç¶è®¾äºé»è®¤å¼ï¼ä½æ¯vueæä»¶è¿æ¯è¦å ä¸ lang="json5", è¿æ ·æè½å¾å¥½å°æ ¼å¼å |
| | | // homePage éè¿ vue æä»¶ç route-block çtype="home"æ¥è®¾å® |
| | | // pages ç®å½ä¸º src/pagesï¼åå
ç®å½ä¸è½é
ç½®å¨pagesç®å½ä¸ |
| | | // subPackages: ['src/pages-sub'], // æ¯ä¸ªæ°ç»ï¼å¯ä»¥é
ç½®å¤ä¸ªï¼ä½æ¯ä¸è½ä¸ºpageséé¢çç®å½ |
| | | dts: 'src/types/uni-pages.d.ts', |
| | | }), |
| | | UniLayouts(), |
| | | UniPlatform(), |
| | | UniManifest(), |
| | | // UniXXX éè¦å¨ Uni ä¹åå¼å
¥ |
| | | Uni(), |
| | | { |
| | | // 临æ¶è§£å³ dcloudio 宿¹ç @dcloudio/uni-mp-compiler åºç°çç¼è¯ BUG |
| | | // åè github issue: https://github.com/dcloudio/uni-app/issues/4952 |
| | | // èªå®ä¹æä»¶ç¦ç¨ vite:vue æä»¶ç devToolsEnabledï¼å¼ºå¶ç¼è¯ vue æ¨¡æ¿æ¶ inline 为 true |
| | | name: 'fix-vite-plugin-vue', |
| | | configResolved(config) { |
| | | const plugin = config.plugins.find((p) => p.name === 'vite:vue') |
| | | if (plugin && plugin.api && plugin.api.options) { |
| | | plugin.api.options.devToolsEnabled = false |
| | | } |
| | | }, |
| | | }, |
| | | UnoCSS(), |
| | | AutoImport({ |
| | | imports: ['vue', 'uni-app'], |
| | | dts: 'src/types/auto-import.d.ts', |
| | | dirs: ['src/hooks'], // èªå¨å¯¼å
¥ hooks |
| | | eslintrc: { enabled: true }, |
| | | vueTemplate: true, // default false |
| | | }), |
| | | |
| | | ViteRestart({ |
| | | // éè¿è¿ä¸ªæä»¶ï¼å¨ä¿®æ¹vite.config.jsæä»¶åä¸éè¦éæ°è¿è¡ä¹çæé
ç½® |
| | | restart: ['vite.config.js'], |
| | | }), |
| | | // h5ç¯å¢å¢å BUILD_TIME å BUILD_BRANCH |
| | | UNI_PLATFORM === 'h5' && { |
| | | name: 'html-transform', |
| | | transformIndexHtml(html) { |
| | | return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss')) |
| | | }, |
| | | }, |
| | | // æå
åææä»¶ï¼h5 + ç产ç¯å¢æå¼¹åº |
| | | UNI_PLATFORM === 'h5' && |
| | | mode === 'production' && |
| | | visualizer({ |
| | | filename: './node_modules/.cache/visualizer/stats.html', |
| | | open: true, |
| | | gzipSize: true, |
| | | brotliSize: true, |
| | | }), |
| | | // åªæå¨ app 平尿¶æå¯ç¨ copyNativeRes æä»¶ |
| | | UNI_PLATFORM === 'app' && copyNativeRes(), |
| | | ], |
| | | define: { |
| | | __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM), |
| | | __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY), |
| | | }, |
| | | css: { |
| | | postcss: { |
| | | plugins: [ |
| | | // autoprefixer({ |
| | | // // æå®ç®æ æµè§å¨ |
| | | // overrideBrowserslist: ['> 1%', 'last 2 versions'], |
| | | // }), |
| | | ], |
| | | }, |
| | | }, |
| | | |
| | | resolve: { |
| | | alias: { |
| | | '@': path.join(process.cwd(), './src'), |
| | | '@img': path.join(process.cwd(), './src/static/images'), |
| | | }, |
| | | }, |
| | | server: { |
| | | host: '0.0.0.0', |
| | | hmr: true, |
| | | port: Number.parseInt(VITE_APP_PORT, 10), |
| | | // ä»
H5 端çæï¼å
¶ä»ç«¯ä¸çæï¼å
¶ä»ç«¯èµ°buildï¼ä¸èµ°devServer) |
| | | proxy: JSON.parse(VITE_APP_PROXY) |
| | | ? { |
| | | [VITE_APP_PROXY_PREFIX]: { |
| | | target: VITE_SERVER_BASEURL, |
| | | changeOrigin: true, |
| | | rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''), |
| | | }, |
| | | } |
| | | : undefined, |
| | | }, |
| | | build: { |
| | | // æ¹ä¾¿éh5端è°è¯ |
| | | sourcemap: VITE_SHOW_SOURCEMAP === 'true', // é»è®¤æ¯false |
| | | target: 'es6', |
| | | // å¼åç¯å¢ä¸ç¨å缩 |
| | | minify: mode === 'development' ? false : 'terser', |
| | | terserOptions: { |
| | | compress: { |
| | | drop_console: VITE_DELETE_CONSOLE === 'true', |
| | | drop_debugger: true, |
| | | }, |
| | | }, |
| | | }, |
| | | }) |
| | | } |
| | |
| | | VITE_GLOB_API_URL=/prod-api |
| | | |
| | | # å
¨å±å å¯å¼å
³(å³å¼å¯äºå è§£å¯åè½æä¼çæ 䏿¯å
¨é¨æ¥å£å å¯ éè¦åå端对åº) |
| | | VITE_GLOB_ENABLE_ENCRYPT=true |
| | | VITE_GLOB_ENABLE_ENCRYPT=false |
| | | # RSAå
¬é¥ 请æ±å å¯ä½¿ç¨ 注æè¿ä¸¤ä¸ªæ¯ä¸¤å¯¹RSAå
¬ç§é¥ 请æ±å å¯-åç«¯è§£å¯æ¯ä¸å¯¹ ååºè§£å¯-å端å 坿¯ä¸å¯¹ |
| | | VITE_GLOB_RSA_PUBLIC_KEY=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ== |
| | | # RSAç§é¥ ååºè§£å¯ä½¿ç¨ 注æè¿ä¸¤ä¸ªæ¯ä¸¤å¯¹RSAå
¬ç§é¥ 请æ±å å¯-åç«¯è§£å¯æ¯ä¸å¯¹ ååºè§£å¯-å端å 坿¯ä¸å¯¹ |
| | |
| | | VITE_GLOB_APP_CLIENT_ID=e5cd7e4891bf95d1d19206ce24a7b32e |
| | | |
| | | # å¼å¯SSE |
| | | VITE_GLOB_SSE_ENABLE=true |
| | | VITE_GLOB_SSE_ENABLE=false |
| | | |
| | |
| | | chargeUser: number; |
| | | |
| | | /** |
| | | * ç»åé¨é¨ |
| | | */ |
| | | chargeDept: number; |
| | | |
| | | /** |
| | | * å·¥åç±»åï¼1-å
¥åºå 2-åºåºåï¼ åå
¸ |
| | | */ |
| | | type: string; |
| | |
| | | * 夿³¨ |
| | | */ |
| | | remark: string; |
| | | /** |
| | | * åºå
¥åºéæ©çå¤ä»¶å表 |
| | | */ |
| | | spareList: any; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import type { IDS, PageQuery, PageResult } from '#/api/common'; |
| | | import type { SpareInoutdtVO } from '#/api/eims/spare-inoutdt/model'; |
| | | |
| | | import { commonExport } from '#/api/helper'; |
| | | import { requestClient } from '#/api/request'; |
| | | |
| | | enum Api { |
| | | root = '/eims/spareInoutdt', |
| | | spareInoutdtExport = '/eims/spareInoutdt/export', |
| | | spareInoutdtList = '/eims/spareInoutdt/list' |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ãå¤ä»¶åºå
¥åºæç»ãå表 |
| | | * @param query |
| | | * @returns {*} |
| | | */ |
| | | |
| | | export function listSpareInoutdt(params?: PageQuery) { |
| | | return requestClient.get<PageResult<SpareInoutdtVO>>(Api.spareInoutdtList, { params }); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ãå¤ä»¶åºå
¥åºæç»ãè¯¦ç» |
| | | * @param spareInoutdtId |
| | | */ |
| | | export function getSpareInoutdt(spareInoutdtId: any) { |
| | | return requestClient.get<SpareInoutdtVO>(`${Api.root}/${spareInoutdtId}`); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ãå¤ä»¶åºå
¥åºæç»ã |
| | | * @param data |
| | | */ |
| | | export function addSpareInoutdt(data: any) { |
| | | return requestClient.postWithMsg<void>(Api.root, data); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ãå¤ä»¶åºå
¥åºæç»ã |
| | | * @param data |
| | | */ |
| | | export function updateSpareInoutdt(data: any) { |
| | | return requestClient.putWithMsg<void>(Api.root, data); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ãå¤ä»¶åºå
¥åºæç»ã |
| | | * @param spareInoutdtIds |
| | | */ |
| | | export function delSpareInoutdt(spareInoutdtIds: IDS) { |
| | | return requestClient.deleteWithMsg<void>(`${Api.root}/${spareInoutdtIds}`); |
| | | } |
| | | |
| | | /** |
| | | * 导åºãå¤ä»¶åºå
¥åºæç»ã |
| | | * @param data |
| | | */ |
| | | export function spareInoutdtExport(data: any) { |
| | | return commonExport(Api.spareInoutdtExport, data); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | export interface SpareInoutdtVO { |
| | | /** |
| | | * |
| | | */ |
| | | id: number | string; |
| | | |
| | | /** |
| | | * åºåºåæå
¥åºåid |
| | | */ |
| | | inoutId: number | string; |
| | | |
| | | /** |
| | | * å¤ä»¶id |
| | | */ |
| | | spareId: number | string; |
| | | |
| | | /** |
| | | * ä¹ååºå |
| | | */ |
| | | beforeStock: number; |
| | | |
| | | /** |
| | | * å®é
åºå |
| | | */ |
| | | actualStock: number; |
| | | |
| | | /** |
| | | * æ°é |
| | | */ |
| | | quantity: number; |
| | | |
| | | /** |
| | | * åä»· |
| | | */ |
| | | unitPrice: number; |
| | | |
| | | /** |
| | | * éé¢ |
| | | */ |
| | | amount: number; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | remark: string; |
| | | } |
| | |
| | | import { requestClient } from '#/api/request'; |
| | | |
| | | enum Api { |
| | | inoutList = '/eims/spare/listInout', |
| | | root = '/eims/spare', |
| | | spareExport = '/eims/spare/export', |
| | | spareList = '/eims/spare/list' |
| | |
| | | return requestClient.get<PageResult<SpareVO>>(Api.spareList, { params }); |
| | | } |
| | | |
| | | export function listInout(params?: PageQuery) { |
| | | return requestClient.get<PageResult<any>>(Api.inoutList, { params }); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ãå¤ä»¶å°è´¦ãè¯¦ç» |
| | | * @param spareId |
| | |
| | | const columns = props?.columns?.filter((i) => i.field !== 'action'); |
| | | |
| | | const gridOptions: VxeGridProps = { |
| | | size: 'mini', |
| | | checkboxConfig: { |
| | | // é«äº® |
| | | highlight: true, |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <script setup lang="ts"> |
| | | import type { VxeGridProps } from '#/adapter/vxe-table'; |
| | | |
| | | import { ref } from 'vue'; |
| | | |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | | import { DictEnum } from '@vben/constants'; |
| | | |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | import { renderDict } from '#/utils/render'; |
| | | import InnerView from '#/views/eims/spare/index.vue'; |
| | | |
| | | const emit = defineEmits<{ updateSelect: [any] }>(); |
| | | |
| | | const [BasicModal, modalApi] = useVbenModal({ |
| | | fullscreenButton: false, |
| | | draggable: true, |
| | | onCancel: handleCancel, |
| | | onConfirm: handleConfirm |
| | | }); |
| | | const innerView = ref(); |
| | | |
| | | async function handleConfirm() { |
| | | try { |
| | | modalApi.modalLoading(true); |
| | | const tableSelect = innerView.value.tableSelect(); |
| | | const eList = tableSelect.filter((item: any) => !item.actualStock && item.actualStock <= 0); |
| | | // æ£æµéæ©çå¤ä»¶åºåæ¯å¦æ£å¸¸ |
| | | if (eList.length > 0) { |
| | | message.error('åå¨åºåä¸è¶³å¤ä»¶ï¼è¯·éæ°éæ©'); |
| | | return false; |
| | | } |
| | | emit('updateSelect', tableSelect); |
| | | await handleCancel(); |
| | | } catch (error) { |
| | | console.error(error); |
| | | } finally { |
| | | modalApi.modalLoading(false); |
| | | } |
| | | } |
| | | |
| | | async function handleCancel() { |
| | | modalApi.close(); |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <BasicModal :fullscreen-button="true" class="w-[800px]"> |
| | | <InnerView ref="innerView" /> |
| | | </BasicModal> |
| | | </template> |
| | | |
| | | <style scoped></style> |
| | |
| | | label: 'ä¾åºå' |
| | | }, |
| | | { |
| | | component: 'Input', |
| | | fieldName: 'openSpare', |
| | | label: 'éæ©å¤ä»¶', |
| | | formItemClass: 'col-span-1 w-[80px]' |
| | | }, |
| | | { |
| | | component: 'Input', |
| | | fieldName: 'outSpareList', |
| | | label: '' |
| | | }, |
| | | { |
| | | component: 'TreeSelect', |
| | | // å¨draweréæ´æ° è¿éä¸éè¦é»è®¤çcomponentProps |
| | | defaultValue: undefined, |
| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { onMounted } from 'vue'; |
| | | import { onMounted, ref } from 'vue'; |
| | | |
| | | import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | |
| | | |
| | | import { columns, querySchema } from './data'; |
| | | import drawer from './spare-in-drawer.vue'; |
| | | import { columns as inoutCol } from '#/views/eims/spare-inoutdt/data'; |
| | | import { listSpareInoutdt } from '#/api/eims/spare-inoutdt'; |
| | | import BasisSubTable from '#/views/eims/components/basis-sub-table.vue'; |
| | | |
| | | const formOptions: VbenFormProps = { |
| | | commonConfig: { |
| | |
| | | }, |
| | | id: 'spre-inout-index' |
| | | }; |
| | | |
| | | const inoutId = ref<string>(); |
| | | const [BasicTable, tableApi] = useVbenVxeGrid({ |
| | | formOptions, |
| | | gridOptions, |
| | | gridEvents: { |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams), |
| | | cellClick: (e: any) => { |
| | | const { row } = e; |
| | | inoutId.value = row.id; |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | <template> |
| | | <Page :auto-content-height="true"> |
| | | <div class="flex h-full gap-[8px]"> |
| | | <BasicTable class="flex-1 overflow-hidden" table-title="å¤ä»¶å
¥åºåå表"> |
| | | <div class="flex h-full gap-[8px] flex-col"> |
| | | <BasicTable class="h-2/3" table-title="å¤ä»¶å
¥åºåå表"> |
| | | <template #toolbar-tools> |
| | | <Space> |
| | | <a-button v-access:code="['eims:spareInout:export']" @click="handleDownloadExcel"> |
| | |
| | | </Space> |
| | | </template> |
| | | </BasicTable> |
| | | <BasisSubTable |
| | | :columns="inoutCol" |
| | | :list-api="listSpareInoutdt" |
| | | :req-value="inoutId" |
| | | class="h-1/3" |
| | | req-key="inoutId" |
| | | title="å
¥åºæç»" |
| | | /> |
| | | </div> |
| | | <Drawer @reload="tableApi.query()" /> |
| | | </Page> |
| | |
| | | <script setup lang="ts"> |
| | | import { computed, ref } from 'vue'; |
| | | |
| | | import { useVbenDrawer } from '@vben/common-ui'; |
| | | import { useVbenDrawer, useVbenModal } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | | import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils'; |
| | | |
| | |
| | | |
| | | import { drawerSchema } from './data'; |
| | | import CodeInput from '#/views/eims/components/code-input.vue'; |
| | | import spareModal from '#/views/eims/components/spare-modal.vue'; |
| | | import SelectSpareTable from '#/views/eims/spare-out/select-spare-table.vue'; |
| | | import { message } from 'ant-design-vue'; |
| | | import type { VxeGridProps } from '#/adapter/vxe-table'; |
| | | import { renderDict } from '#/utils/render'; |
| | | import { DictEnum } from '@vben/constants'; |
| | | /** |
| | | * åºåºåéæ©çå¤ä»¶æ°æ® |
| | | */ |
| | | const outSpareList = ref([]); |
| | | const selectSpareTable = ref(); |
| | | const outCol: VxeGridProps['columns'] = [ |
| | | { |
| | | field: 'action', |
| | | slots: { default: 'action' }, |
| | | title: 'å é¤', |
| | | width: 60 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶åç§°', |
| | | field: 'name', |
| | | width: 180 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶ç¼ç ', |
| | | field: 'code', |
| | | width: 120 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶åå·', |
| | | field: 'modelNo', |
| | | width: 100 |
| | | }, |
| | | { |
| | | title: '计éåä½', |
| | | field: 'unit', |
| | | slots: { |
| | | default: ({ row }) => { |
| | | if (!row.unit || row.unit === '') { |
| | | return ''; |
| | | } |
| | | return renderDict(row.unit, DictEnum.EIMS_SPARE_UNIT); |
| | | } |
| | | }, |
| | | width: 80 |
| | | }, |
| | | |
| | | { |
| | | title: 'å®é
åºå', |
| | | field: 'actualStock', |
| | | width: 100 |
| | | }, |
| | | { |
| | | title: 'æ°é', |
| | | field: 'quantity', |
| | | editRender: { |
| | | name: 'input' |
| | | }, |
| | | width: 80 |
| | | }, |
| | | { |
| | | title: 'åèä»·', |
| | | field: 'referPrice', |
| | | width: 90 |
| | | } |
| | | ]; |
| | | const emit = defineEmits<{ reload: [] }>(); |
| | | |
| | | const isUpdate = ref(false); |
| | |
| | | if (!isOpen) { |
| | | return null; |
| | | } |
| | | outSpareList.value = []; |
| | | drawerApi.drawerLoading(true); |
| | | const { id } = drawerApi.getData() as { id?: number | string }; |
| | | isUpdate.value = !!id; |
| | |
| | | if (isUpdate.value && id) { |
| | | const record = await getSpareInout(id); |
| | | await formApi.setValues(record); |
| | | outSpareList.value = record?.spareList; |
| | | if (isUpdate.value && record.chargeDept) { |
| | | await setupUserOptions(record.chargeDept); |
| | | } |
| | | } |
| | | |
| | | drawerApi.drawerLoading(false); |
| | |
| | | if (!valid) { |
| | | return; |
| | | } |
| | | const selectSpareList = selectSpareTable.value.tableData(); |
| | | // æ£æµæ¯å¦è¾å
¥åºåºæ°é |
| | | const eList = selectSpareList.filter((item: any) => !item.quantity || item.quantity <= 0); |
| | | if (selectSpareList.length<= 0 || eList.length > 0) { |
| | | message.error('å
¥åºæ°é为空ï¼è¯·æ£æ¥ï¼'); |
| | | return false; |
| | | } |
| | | const data = cloneDeep(await formApi.getValues()); |
| | | data.spareList = selectSpareList; |
| | | await (isUpdate.value ? updateSpareInout(data) : addSpareInout(data)); |
| | | emit('reload'); |
| | | await handleCancel(); |
| | |
| | | drawerApi.close(); |
| | | await formApi.resetForm(); |
| | | } |
| | | |
| | | // å¤ä»¶modal |
| | | const [SpareModal, spareModalApi] = useVbenModal({ |
| | | connectedComponent: spareModal, |
| | | draggable: true, |
| | | title: 'éæ©å¤ä»¶' |
| | | }); |
| | | |
| | | function handleSpareModal() { |
| | | spareModalApi.setData({}); |
| | | spareModalApi.open(); |
| | | } |
| | | |
| | | /** |
| | | * éæ©çå¤ä»¶ |
| | | * @param spareList |
| | | */ |
| | | function selectSpare(spareList: any) { |
| | | outSpareList.value = spareList; |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[600px]"> |
| | | <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[1000px]"> |
| | | <BasicForm> |
| | | <template #orderCode="slotProps"> |
| | | <CodeInput v-bind="slotProps" :disabled="isUpdate" prefix="RK" /> |
| | | </template> |
| | | <template #openSpare="slotProps"> |
| | | <a-button type="primary" v-bind="slotProps" :disabled="isUpdate" @click.stop="handleSpareModal">æ·»å å¤ä»¶</a-button> |
| | | </template> |
| | | <template #outSpareList> |
| | | <SelectSpareTable ref="selectSpareTable" :columns="outCol" :data="outSpareList" :is-update="isUpdate" /> |
| | | </template> |
| | | </BasicForm> |
| | | |
| | | <SpareModal class="w-[1200px]" @update-select="selectSpare" /> |
| | | </BasicDrawer> |
| | | </template> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import type { VxeGridProps } from '#/adapter/vxe-table'; |
| | | |
| | | import { type FormSchemaGetter } from '#/adapter/form'; |
| | | import { renderDict } from '#/utils/render'; |
| | | import { DictEnum } from '@vben/constants'; |
| | | export const querySchema: FormSchemaGetter = () => []; |
| | | |
| | | export const columns: VxeGridProps['columns'] = [ |
| | | { type: 'checkbox', width: 60, fixed: 'left' }, |
| | | { |
| | | title: 'å¤ä»¶åç§°', |
| | | field: 'spareName', |
| | | minWidth: 120 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶ç¼å·', |
| | | field: 'spareCode', |
| | | minWidth: 120 |
| | | }, |
| | | { |
| | | title: 'è§æ ¼åå·', |
| | | field: 'modelNo', |
| | | minWidth: 100 |
| | | }, |
| | | { |
| | | title: '计éåä½', |
| | | field: 'unit', |
| | | sortable: true, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | if (!row.unit || row.unit === '') { |
| | | return ''; |
| | | } |
| | | return renderDict(row.unit, DictEnum.EIMS_SPARE_UNIT); |
| | | } |
| | | }, |
| | | width: 100 |
| | | }, |
| | | { |
| | | title: 'ä¹ååºå', |
| | | field: 'beforeStock', |
| | | minWidth: 100 |
| | | }, |
| | | { |
| | | title: 'å½ååºå', |
| | | field: 'actualStock', |
| | | minWidth: 100 |
| | | }, |
| | | { |
| | | title: 'æ°é', |
| | | field: 'quantity', |
| | | minWidth: 80 |
| | | }, |
| | | { |
| | | title: 'åä»·', |
| | | field: 'unitPrice', |
| | | minWidth: 80 |
| | | }, |
| | | { |
| | | title: 'éé¢', |
| | | field: 'amount', |
| | | minWidth: 80 |
| | | } |
| | | ]; |
| | | export const drawerSchema: FormSchemaGetter = () => []; |
| | |
| | | } |
| | | ]; |
| | | |
| | | |
| | | |
| | | export const drawerSchema: FormSchemaGetter = () => [ |
| | | { |
| | | component: 'Input', |
| | |
| | | label: '客æ·' |
| | | }, |
| | | { |
| | | component: 'Input', |
| | | fieldName: 'openSpare', |
| | | label: 'éæ©å¤ä»¶', |
| | | formItemClass: 'col-span-1 w-[80px]' |
| | | }, |
| | | { |
| | | component: 'Input', |
| | | fieldName: 'outSpareList', |
| | | label: '' |
| | | }, |
| | | { |
| | | component: 'TreeSelect', |
| | | // å¨draweréæ´æ° è¿éä¸éè¦é»è®¤çcomponentProps |
| | | defaultValue: undefined, |
| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { onMounted } from 'vue'; |
| | | import { onMounted, ref } from 'vue'; |
| | | |
| | | import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | |
| | | |
| | | import { columns, querySchema } from './data'; |
| | | import drawer from './spare-out-drawer.vue'; |
| | | import { columns as inoutCol } from '#/views/eims/spare-inoutdt/data'; |
| | | import { listSpareInoutdt } from '#/api/eims/spare-inoutdt'; |
| | | import BasisSubTable from '#/views/eims/components/basis-sub-table.vue'; |
| | | |
| | | const formOptions: VbenFormProps = { |
| | | commonConfig: { |
| | |
| | | }, |
| | | id: 'spre-inout-index' |
| | | }; |
| | | |
| | | const inoutId = ref<string>(); |
| | | const [BasicTable, tableApi] = useVbenVxeGrid({ |
| | | formOptions, |
| | | gridOptions, |
| | | gridEvents: { |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams), |
| | | cellClick: (e: any) => { |
| | | const { row } = e; |
| | | inoutId.value = row.id; |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | <template> |
| | | <Page :auto-content-height="true"> |
| | | <div class="flex h-full gap-[8px]"> |
| | | <BasicTable class="flex-1 overflow-hidden" table-title="å¤ä»¶åºåºåå表"> |
| | | <div class="flex h-full gap-[8px] flex-col"> |
| | | <BasicTable class="h-2/3" table-title="å¤ä»¶åºåºåå表"> |
| | | <template #toolbar-tools> |
| | | <Space> |
| | | <a-button v-access:code="['eims:spareInout:export']" @click="handleDownloadExcel"> |
| | |
| | | </Space> |
| | | </template> |
| | | </BasicTable> |
| | | <BasisSubTable |
| | | :columns="inoutCol" |
| | | :list-api="listSpareInoutdt" |
| | | :req-value="inoutId" |
| | | class="h-1/3" |
| | | req-key="inoutId" |
| | | title="åºåºæç»" |
| | | /> |
| | | </div> |
| | | <Drawer @reload="tableApi.query()" /> |
| | | </Page> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { reactive, ref, watch } from 'vue'; |
| | | |
| | | import { $t } from '@vben/locales'; |
| | | import { getVxePopupContainer } from '@vben/utils'; |
| | | |
| | | import { Popconfirm, Space } from 'ant-design-vue'; |
| | | |
| | | import { useVbenVxeGrid, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; |
| | | |
| | | |
| | | interface Props { |
| | | title?: string; |
| | | columns?: VxeGridProps['columns']; |
| | | data: any; |
| | | isUpdate?: boolean; |
| | | } |
| | | const props = defineProps<Props>(); |
| | | |
| | | const responsiveData = reactive(props.data); |
| | | defineExpose({ |
| | | tableData |
| | | }); |
| | | |
| | | watch( |
| | | () => props.data, |
| | | (data) => { |
| | | responsiveData.splice(0, responsiveData.length, ...data); |
| | | } |
| | | ); |
| | | |
| | | const gridOptions: VxeGridProps = { |
| | | checkboxConfig: { |
| | | // é«äº® |
| | | highlight: true, |
| | | // 翻页æ¶ä¿çéä¸ç¶æ |
| | | reserve: true |
| | | // ç¹å»è¡éä¸ |
| | | // trigger: 'row' |
| | | }, |
| | | columns: props.columns, |
| | | height: 'auto', |
| | | keepSource: true, |
| | | data: responsiveData, |
| | | pagerConfig: { |
| | | enabled: false |
| | | }, |
| | | toolbarConfig: { |
| | | enabled: false |
| | | }, |
| | | rowConfig: { |
| | | isHover: true, |
| | | keyField: 'id' |
| | | }, |
| | | sortConfig: { |
| | | // è¿ç¨æåº |
| | | remote: true, |
| | | // æ¯æå¤å段æåº é»è®¤å
³é |
| | | multiple: true |
| | | }, |
| | | editConfig: { |
| | | mode: 'cell', |
| | | trigger: 'click' |
| | | }, |
| | | id: 'local-table' |
| | | }; |
| | | |
| | | const [BasicTable, tableApi] = useVbenVxeGrid({ |
| | | gridOptions, |
| | | gridEvents: { |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) |
| | | } |
| | | }); |
| | | |
| | | function handleDelete(row: Recordable<any>) { |
| | | const index = responsiveData.findIndex((item: any) => item.id === row.id); |
| | | if (index !== -1) { |
| | | responsiveData.splice(index, 1); |
| | | } |
| | | } |
| | | // é䏿°æ® |
| | | function tableData() { |
| | | return tableApi.grid.getData(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * TODO åç»æ©å±ç¹å»äºä»¶ |
| | | */ |
| | | const slotName = ref<string>('equName'); |
| | | </script> |
| | | |
| | | <template> |
| | | <div class="w-full h-min"> |
| | | <BasicTable :table-title="title" size="small"> |
| | | <template #[slotName]="{ row }"> |
| | | <Space> |
| | | <span>{{ row[slotName] }}</span> |
| | | </Space> |
| | | </template> |
| | | |
| | | <template #action="{ row }"> |
| | | <Space> |
| | | <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="确认å é¤ï¼" @confirm="handleDelete(row)"> |
| | | <ghost-button :disabled="isUpdate" danger @click.stop=""> |
| | | {{ $t('pages.common.delete') }} |
| | | </ghost-button> |
| | | </Popconfirm> |
| | | </Space> |
| | | </template> |
| | | </BasicTable> |
| | | </div> |
| | | </template> |
| | | |
| | | <style lang="scss" scoped> |
| | | :deep(.p-2) { |
| | | padding: 0; |
| | | } |
| | | </style> |
| | |
| | | <script setup lang="ts"> |
| | | import type { VxeGridProps } from '#/adapter/vxe-table'; |
| | | |
| | | import { computed, ref } from 'vue'; |
| | | |
| | | import { useVbenDrawer } from '@vben/common-ui'; |
| | | import { useVbenDrawer, useVbenModal } from '@vben/common-ui'; |
| | | import { DictEnum } from '@vben/constants'; |
| | | import { $t } from '@vben/locales'; |
| | | import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils'; |
| | | |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | import { useVbenForm } from '#/adapter/form'; |
| | | import { addSpareInout, getSpareInout, updateSpareInout } from '#/api/eims/spare-inout'; |
| | | import { getDeptTree, userList } from '#/api/system/user'; |
| | | import { renderDict } from '#/utils/render'; |
| | | import CodeInput from '#/views/eims/components/code-input.vue'; |
| | | import spareModal from '#/views/eims/components/spare-modal.vue'; |
| | | |
| | | import { drawerSchema } from './data'; |
| | | import CodeInput from '#/views/eims/components/code-input.vue'; |
| | | import SelectSpareTable from './select-spare-table.vue'; |
| | | |
| | | const emit = defineEmits<{ reload: [] }>(); |
| | | |
| | | /** |
| | | * åºåºåéæ©çå¤ä»¶æ°æ® |
| | | */ |
| | | const outSpareList = ref([]); |
| | | const selectSpareTable = ref(); |
| | | |
| | | const outCol: VxeGridProps['columns'] = [ |
| | | { |
| | | field: 'action', |
| | | slots: { default: 'action' }, |
| | | title: 'å é¤', |
| | | width: 60 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶åç§°', |
| | | field: 'name', |
| | | width: 180 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶ç¼ç ', |
| | | field: 'code', |
| | | width: 120 |
| | | }, |
| | | { |
| | | title: 'å¤ä»¶åå·', |
| | | field: 'modelNo', |
| | | width: 100 |
| | | }, |
| | | { |
| | | title: '计éåä½', |
| | | field: 'unit', |
| | | slots: { |
| | | default: ({ row }) => { |
| | | if (!row.unit || row.unit === '') { |
| | | return ''; |
| | | } |
| | | return renderDict(row.unit, DictEnum.EIMS_SPARE_UNIT); |
| | | } |
| | | }, |
| | | width: 80 |
| | | }, |
| | | |
| | | { |
| | | title: 'å®é
åºå', |
| | | field: 'actualStock', |
| | | width: 100 |
| | | }, |
| | | { |
| | | title: 'æ°é', |
| | | field: 'quantity', |
| | | editRender: { |
| | | name: 'input' |
| | | }, |
| | | width: 80 |
| | | }, |
| | | { |
| | | title: 'åèä»·', |
| | | field: 'referPrice', |
| | | width: 90 |
| | | } |
| | | ]; |
| | | |
| | | const isUpdate = ref(false); |
| | | const title = computed(() => { |
| | |
| | | drawerApi.drawerLoading(true); |
| | | const { id } = drawerApi.getData() as { id?: number | string }; |
| | | isUpdate.value = !!id; |
| | | outSpareList.value = []; |
| | | // åå§å |
| | | await setupDeptSelect(); |
| | | // æ´æ° && èµå¼ |
| | | if (isUpdate.value && id) { |
| | | const record = await getSpareInout(id); |
| | | await formApi.setValues(record); |
| | | // æ´æ°åºåºåçå¤ä»¶æç» |
| | | outSpareList.value = record?.spareList; |
| | | if (isUpdate.value && record.chargeDept) { |
| | | await setupUserOptions(record.chargeDept); |
| | | } |
| | | } |
| | | |
| | | drawerApi.drawerLoading(false); |
| | |
| | | /** æ ¹æ®é¨é¨IDå è½½ç¨æ· */ |
| | | await setupUserOptions(deptId); |
| | | /** åååéè¦éæ°éæ©ç¨æ· */ |
| | | formModel.operatorId = undefined; |
| | | formModel.chargeUser = undefined; |
| | | }, |
| | | placeholder: 'è¯·éæ©', |
| | | showSearch: true, |
| | |
| | | } |
| | | ]); |
| | | } |
| | | |
| | | async function handleConfirm() { |
| | | try { |
| | | drawerApi.drawerLoading(true); |
| | |
| | | if (!valid) { |
| | | return; |
| | | } |
| | | const selectSpareList = selectSpareTable.value.tableData(); |
| | | // æ£æµæ¯å¦è¾å
¥åºåºæ°é |
| | | const eList = selectSpareList.filter((item: any) => !item.quantity || item.quantity <= 0 || item.quantity > item.actualStock); |
| | | if (selectSpareList.length<= 0 ||eList.length > 0) { |
| | | message.error('åºåºæ°é为空æå¤§äºåºåï¼è¯·æ£æ¥ï¼'); |
| | | return false; |
| | | } |
| | | const data = cloneDeep(await formApi.getValues()); |
| | | data.spareList = selectSpareList; |
| | | await (isUpdate.value ? updateSpareInout(data) : addSpareInout(data)); |
| | | emit('reload'); |
| | | await handleCancel(); |
| | |
| | | drawerApi.close(); |
| | | await formApi.resetForm(); |
| | | } |
| | | |
| | | // å¤ä»¶modal |
| | | const [SpareModal, spareModalApi] = useVbenModal({ |
| | | connectedComponent: spareModal, |
| | | draggable: true, |
| | | title: 'éæ©å¤ä»¶' |
| | | }); |
| | | |
| | | function handleSpareModal() { |
| | | spareModalApi.setData({}); |
| | | spareModalApi.open(); |
| | | } |
| | | |
| | | /** |
| | | * éæ©çå¤ä»¶ |
| | | * @param spareList |
| | | */ |
| | | function selectSpare(spareList: any) { |
| | | outSpareList.value = spareList; |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[600px]"> |
| | | <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[1000px]"> |
| | | <BasicForm> |
| | | <template #orderCode="slotProps"> |
| | | <CodeInput v-bind="slotProps" :disabled="isUpdate" prefix="CK" /> |
| | | </template> |
| | | |
| | | <template #openSpare="slotProps"> |
| | | <a-button type="primary" v-bind="slotProps" :disabled="isUpdate" @click.stop="handleSpareModal">æ·»å å¤ä»¶</a-button> |
| | | </template> |
| | | |
| | | <template #outSpareList> |
| | | <SelectSpareTable ref="selectSpareTable" :columns="outCol" :data="outSpareList" :is-update="isUpdate" /> |
| | | </template> |
| | | </BasicForm> |
| | | <SpareModal class="w-[1200px]" @update-select="selectSpare" /> |
| | | </BasicDrawer> |
| | | </template> |
| | |
| | | import type { VxeGridProps } from '#/adapter/vxe-table'; |
| | | |
| | | import { DictEnum } from '@vben/constants'; |
| | | import { getPopupContainer } from '@vben/utils'; |
| | | |
| | | import { Tag } from 'ant-design-vue'; |
| | | |
| | | import { type FormSchemaGetter } from '#/adapter/form'; |
| | | import { getDictOptions } from '#/utils/dict'; |
| | | import { renderDict } from '#/utils/render'; |
| | | import { getPopupContainer } from '@vben/utils'; |
| | | |
| | | export const querySchema: FormSchemaGetter = () => [ |
| | | { |
| | |
| | | sortable: true, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | if (row.unit === null || row.unit === '') { |
| | | if (!row.unit || row.unit === '') { |
| | | return ''; |
| | | } |
| | | return renderDict(row.unit, DictEnum.EIMS_SPARE_UNIT); |
| | |
| | | } |
| | | ]; |
| | | |
| | | export const inoutCol: VxeGridProps['columns'] = [ |
| | | { |
| | | title: 'åºå
¥åºåå·', |
| | | field: 'orderCode', |
| | | width: 180 |
| | | }, |
| | | { |
| | | title: 'æ¥æ', |
| | | field: 'orderTime', |
| | | width: 180 |
| | | }, |
| | | { |
| | | title: 'æ¹å', |
| | | field: 'type1', |
| | | width: 80, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | const type = row.type; |
| | | switch (type) { |
| | | case '1': { |
| | | return <Tag color="green"> å
¥åº </Tag>; |
| | | } |
| | | case '2': { |
| | | return <Tag color="blue"> åºåº </Tag>; |
| | | } |
| | | // No default |
| | | } |
| | | return ''; |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | title: 'ç±»å', |
| | | field: 'type', |
| | | width: 100, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | if (!row.type || row.type === '') { |
| | | return ''; |
| | | } |
| | | return renderDict(row.type, DictEnum.SPARE_INOUT_TYPE); |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | title: 'å
¥åº', |
| | | field: 'inQuantity', |
| | | width: 120, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | return row.type && row.type === '1' ? row.quantity : ''; |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | title: 'åºåº', |
| | | field: 'outQuantity', |
| | | width: 120, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | return row.type && row.type === '2' ? row.quantity : ''; |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | title: 'åºå', |
| | | field: 'actualStock', |
| | | width: 80 |
| | | }, |
| | | { |
| | | title: 'åä»·', |
| | | field: 'unitPrice', |
| | | width: 80 |
| | | }, |
| | | { |
| | | title: 'éé¢', |
| | | field: 'amount', |
| | | width: 80 |
| | | } |
| | | ]; |
| | | |
| | | export const drawerSchema: FormSchemaGetter = () => [ |
| | | { |
| | | component: 'Input', |
| | |
| | | show: () => false, |
| | | triggerFields: ['imgUrl'] |
| | | }, |
| | | label: 'å¤ä»¶é¢è§', |
| | | label: 'å¤ä»¶é¢è§' |
| | | }, |
| | | { |
| | | component: 'Input', |
| | |
| | | import { Image, Modal, Popconfirm, Space } from 'ant-design-vue'; |
| | | |
| | | import { useVbenVxeGrid, vxeCheckboxChecked, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; |
| | | import { delSpare, listSpare, spareExport } from '#/api/eims/spare'; |
| | | import { delSpare, listInout, listSpare, spareExport } from '#/api/eims/spare'; |
| | | import { configInfoByKey } from '#/api/system/config'; |
| | | import { commonDownloadExcel } from '#/utils/file/download'; |
| | | import BasisSubTable from '#/views/eims/components/basis-sub-table.vue'; |
| | | |
| | | import { columns, querySchema } from './data'; |
| | | import { columns, inoutCol, querySchema } from './data'; |
| | | import spareDrawer from './spare-drawer.vue'; |
| | | import SpareTypeTree from './spare-type-tree.vue'; |
| | | |
| | |
| | | height: 'auto', |
| | | keepSource: true, |
| | | pagerConfig: { |
| | | enabled: false, |
| | | enabled: false |
| | | }, |
| | | proxyConfig: { |
| | | enabled: true, |
| | |
| | | keyField: 'id' |
| | | }, |
| | | columnConfig: { |
| | | resizable: true, |
| | | resizable: true |
| | | }, |
| | | sortConfig: { |
| | | // è¿ç¨æåº |
| | |
| | | }, |
| | | id: 'eims-spare-index' |
| | | }; |
| | | |
| | | const id = ref<string>(); |
| | | const [BasicTable, tableApi] = useVbenVxeGrid({ |
| | | formOptions, |
| | | gridOptions, |
| | | gridEvents: { |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams), |
| | | cellClick: (e: any) => { |
| | | const { row } = e; |
| | | id.value = row.id; |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | <Page :auto-content-height="true"> |
| | | <div class="flex h-full gap-[8px]"> |
| | | <SpareTypeTree v-model:select-type-id="selectTypeId" class="w-[260px]" @reload="() => tableApi.reload()" @select="() => tableApi.reload()" /> |
| | | <BasicTable class="flex-1 overflow-hidden" table-title="å¤ä»¶å°è´¦"> |
| | | <div class="flex-1 overflow-hidden"> |
| | | <div class="flex h-full gap-[8px] flex-col"> |
| | | <BasicTable class="h-2/3" table-title="å¤ä»¶å°è´¦"> |
| | | <template #toolbar-tools> |
| | | <Space> |
| | | <a-button v-access:code="['eims:spare:export']" @click="handleDownloadExcel"> |
| | |
| | | </Space> |
| | | </template> |
| | | </BasicTable> |
| | | <BasisSubTable :columns="inoutCol" :list-api="listInout" :req-value="id" class="h-1/3" req-key="id" title="åºå
¥åºæç»" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <SpareDrawer @reload="tableApi.query()" /> |
| | | </Page> |
| | | </template> |
| | | |
| | | <style> |
| | | <style lang="scss" scoped> |
| | | /* ç»ä¸ææåçè¾¹æ¡åè¡é« */ |
| | | .vxe-table--body .vxe-body--row .vxe-body--column { |
| | | height: 56px !important; |
| | |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | # jdbc ææåæ°é
ç½®åè https://lionli.blog.csdn.net/article/details/122018562 |
| | | # rewriteBatchedStatements=true æ¹å¤çä¼å 大å¹
æåæ¹éæå
¥æ´æ°å 餿§è½(å¯¹æ°æ®åºææ§è½æè ä½¿ç¨æ¹éæä½åºèèæ§è½é®é¢) |
| | | url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true |
| | | url: jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true |
| | | username: root |
| | | password: root |
| | | password: 123456 |
| | | # ä»åºæ°æ®æº |
| | | slave: |
| | | lazy: true |
| | |
| | | # æ°æ®åºç´¢å¼ |
| | | database: 0 |
| | | # redis å¯ç å¿
é¡»é
ç½® |
| | | password: ruoyi123 |
| | | #password: ruoyi123 |
| | | # è¿æ¥è¶
æ¶æ¶é´ |
| | | timeout: 10s |
| | | # æ¯å¦å¼å¯ssl |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | *å¤ä»¶åºå
¥åºç±»å |
| | | */ |
| | | String SPARE_INOUT_TYPE = "spare_inout_type"; |
| | | interface SPARE_INOUT_TYPE_DETAIL { |
| | | String RK = "1";// éè´å
¥åº |
| | | String CK = "2"; // é¢ç¨åºåº |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.*; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | |
| | | return eimsSpareService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | @SaCheckPermission("eims:spare:list") |
| | | @GetMapping("/listInout") |
| | | public TableDataInfo<EimsSpareInoutdtVo> listInout(EimsSpareBo bo, PageQuery pageQuery) { |
| | | return eimsSpareService.querySpareInoutList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导åºå¤ä»¶å°è´¦å表 |
| | | */ |
| | |
| | | return eimsSpareInoutService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导åºå¤ä»¶åºå
¥åºå表 |
| | | */ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.*; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.eims.domain.bo.EimsSpareInoutdtBo; |
| | | import org.dromara.eims.service.IEimsSpareInoutdtService; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/eims/spareInoutdt") |
| | | public class EimsSpareInoutdtController extends BaseController { |
| | | |
| | | private final IEimsSpareInoutdtService eimsSpareInoutdtService; |
| | | |
| | | /** |
| | | * æ¥è¯¢å¤ä»¶åºå
¥åºæç»å表 |
| | | */ |
| | | @SaCheckPermission("eims:spareInoutdt:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<EimsSpareInoutdtVo> list(EimsSpareInoutdtBo bo, PageQuery pageQuery) { |
| | | return eimsSpareInoutdtService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导åºå¤ä»¶åºå
¥åºæç»å表 |
| | | */ |
| | | @SaCheckPermission("eims:spareInoutdt:export") |
| | | @Log(title = "å¤ä»¶åºå
¥åºæç»", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(EimsSpareInoutdtBo bo, HttpServletResponse response) { |
| | | List<EimsSpareInoutdtVo> list = eimsSpareInoutdtService.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "å¤ä»¶åºå
¥åºæç»", EimsSpareInoutdtVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * è·åå¤ä»¶åºå
¥åºæç»è¯¦ç»ä¿¡æ¯ |
| | | * |
| | | * @param id ä¸»é® |
| | | */ |
| | | @SaCheckPermission("eims:spareInoutdt:query") |
| | | @GetMapping("/{id}") |
| | | public R<EimsSpareInoutdtVo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long id) { |
| | | return R.ok(eimsSpareInoutdtService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢å¤ä»¶åºå
¥åºæç» |
| | | */ |
| | | @SaCheckPermission("eims:spareInoutdt:add") |
| | | @Log(title = "å¤ä»¶åºå
¥åºæç»", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody EimsSpareInoutdtBo bo) { |
| | | return toAjax(eimsSpareInoutdtService.insertByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹å¤ä»¶åºå
¥åºæç» |
| | | */ |
| | | @SaCheckPermission("eims:spareInoutdt:edit") |
| | | @Log(title = "å¤ä»¶åºå
¥åºæç»", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody EimsSpareInoutdtBo bo) { |
| | | return toAjax(eimsSpareInoutdtService.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param ids 主é®ä¸² |
| | | */ |
| | | @SaCheckPermission("eims:spareInoutdt:remove") |
| | | @Log(title = "å¤ä»¶åºå
¥åºæç»", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(eimsSpareInoutdtService.deleteWithValidByIds(List.of(ids), true)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.domain; |
| | | |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serial; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç»å¯¹è±¡ eims_spare_inoutdt |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("eims_spare_inoutdt") |
| | | public class EimsSpareInoutdt extends BaseEntity { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(value = "id") |
| | | private Long id; |
| | | |
| | | /** |
| | | * åºåºåæå
¥åºåid |
| | | */ |
| | | private Long inoutId; |
| | | |
| | | /** |
| | | * å¤ä»¶id |
| | | */ |
| | | private Long spareId; |
| | | |
| | | /** |
| | | * ä¹ååºå |
| | | */ |
| | | private Long beforeStock; |
| | | |
| | | /** |
| | | * å®é
åºå |
| | | */ |
| | | private Long actualStock; |
| | | |
| | | /** |
| | | * æ°é |
| | | */ |
| | | private Long quantity; |
| | | |
| | | /** |
| | | * åä»· |
| | | */ |
| | | private BigDecimal unitPrice; |
| | | |
| | | /** |
| | | * éé¢ |
| | | */ |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
| | |
| | | private String remark; |
| | | |
| | | |
| | | |
| | | /** |
| | | * åºåºå
¥åºæ°é |
| | | */ |
| | | private Long quantity; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | import jakarta.validation.constraints.*; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.dromara.eims.domain.vo.EimsSpareVo; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºä¸å¡å¯¹è±¡ eims_spare_inout |
| | |
| | | */ |
| | | private String remark; |
| | | |
| | | //åºå
¥åºéæ©çå¤ä»¶æç» |
| | | private List<EimsSpareBo> spareList; |
| | | |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.domain.bo; |
| | | |
| | | import org.dromara.eims.domain.EimsSpareInoutdt; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import jakarta.validation.constraints.*; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç»ä¸å¡å¯¹è±¡ eims_spare_inoutdt |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = EimsSpareInoutdt.class, reverseConvertGenerate = false) |
| | | public class EimsSpareInoutdtBo extends BaseEntity { |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @NotNull(message = "ä¸è½ä¸ºç©º", groups = { EditGroup.class }) |
| | | private Long id; |
| | | |
| | | /** |
| | | * åºåºåæå
¥åºåid |
| | | */ |
| | | @NotNull(message = "åºåºåæå
¥åºåidä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long inoutId; |
| | | |
| | | /** |
| | | * å¤ä»¶id |
| | | */ |
| | | @NotNull(message = "å¤ä»¶idä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long spareId; |
| | | |
| | | /** |
| | | * ä¹ååºå |
| | | */ |
| | | @NotNull(message = "ä¹ååºåä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long beforeStock; |
| | | |
| | | /** |
| | | * å®é
åºå |
| | | */ |
| | | @NotNull(message = "å®é
åºåä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long actualStock; |
| | | |
| | | /** |
| | | * æ°é |
| | | */ |
| | | @NotNull(message = "æ°éä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long quantity; |
| | | |
| | | /** |
| | | * åä»· |
| | | */ |
| | | @NotNull(message = "åä»·ä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long unitPrice; |
| | | |
| | | /** |
| | | * éé¢ |
| | | */ |
| | | @NotNull(message = "éé¢ä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long amount; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
| | |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.eims.domain.bo.EimsSpareBo; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | @ExcelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | |
| | | //åºå
¥åºéæ©çå¤ä»¶æç» |
| | | private List<EimsSpareVo> spareList; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.domain.vo; |
| | | |
| | | import org.dromara.eims.domain.EimsSpareInoutdt; |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç»è§å¾å¯¹è±¡ eims_spare_inoutdt |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = EimsSpareInoutdt.class) |
| | | public class EimsSpareInoutdtVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @ExcelProperty(value = "") |
| | | private Long id; |
| | | |
| | | /** |
| | | * åºåºåæå
¥åºåid |
| | | */ |
| | | @ExcelProperty(value = "åºåºåæå
¥åºåid") |
| | | private Long inoutId; |
| | | |
| | | /** |
| | | * å¤ä»¶id |
| | | */ |
| | | @ExcelProperty(value = "å¤ä»¶id") |
| | | private Long spareId; |
| | | |
| | | /** |
| | | * ä¹ååºå |
| | | */ |
| | | @ExcelProperty(value = "ä¹ååºå") |
| | | private Long beforeStock; |
| | | |
| | | /** |
| | | * å®é
åºå |
| | | */ |
| | | @ExcelProperty(value = "å®é
åºå") |
| | | private Long actualStock; |
| | | |
| | | /** |
| | | * æ°é |
| | | */ |
| | | @ExcelProperty(value = "æ°é") |
| | | private Long quantity; |
| | | |
| | | /** |
| | | * åä»· |
| | | */ |
| | | @ExcelProperty(value = "åä»·") |
| | | private BigDecimal unitPrice; |
| | | |
| | | /** |
| | | * éé¢ |
| | | */ |
| | | @ExcelProperty(value = "éé¢") |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ExcelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | //å¤ä»¶ |
| | | private String spareName; |
| | | private String spareCode; |
| | | private String modelNo; |
| | | //åºå
¥åºå |
| | | private String orderCode; |
| | | private Date orderTime; |
| | | private String type; |
| | | private String unit; |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | @ExcelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * åºåºå
¥åºæ°é |
| | | */ |
| | | private Long quantity; |
| | | |
| | | } |
| | |
| | | package org.dromara.eims.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.eims.domain.EimsSpareInout; |
| | | import org.dromara.eims.domain.EimsSpareInoutdt; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutVo; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºMapperæ¥å£ |
| | |
| | | */ |
| | | public interface EimsSpareInoutMapper extends BaseMapperPlus<EimsSpareInout, EimsSpareInoutVo> { |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.eims.domain.EimsMaintSt; |
| | | import org.dromara.eims.domain.EimsSpareInoutdt; |
| | | import org.dromara.eims.domain.vo.EimsMaintStVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç»Mapperæ¥å£ |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | public interface EimsSpareInoutdtMapper extends BaseMapperPlus<EimsSpareInoutdt, EimsSpareInoutdtVo> { |
| | | |
| | | Page<EimsSpareInoutdtVo> selectSpareInoutdtList(@Param("page") Page<EimsSpareInoutdtVo> page, @Param(Constants.WRAPPER) Wrapper<EimsSpareInoutdt> queryWrapper); |
| | | } |
| | | |
| | |
| | | package org.dromara.eims.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.eims.domain.EimsSpare; |
| | | import org.dromara.eims.domain.EimsSpareInout; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareVo; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | |
| | |
| | | * @date 2025-03-20 |
| | | */ |
| | | public interface EimsSpareMapper extends BaseMapperPlus<EimsSpare, EimsSpareVo> { |
| | | |
| | | Page<EimsSpareInoutdtVo> selectSpareInoutList(@Param("page") Page<EimsSpareInoutdtVo> page, @Param(Constants.WRAPPER) Wrapper<EimsSpare> queryWrapper); |
| | | } |
| | |
| | | * @return æ¯å¦å 餿å |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.service; |
| | | |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.eims.domain.bo.EimsSpareInoutdtBo; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç»Serviceæ¥å£ |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | public interface IEimsSpareInoutdtService { |
| | | |
| | | /** |
| | | * æ¥è¯¢å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return å¤ä»¶åºå
¥åºæç» |
| | | */ |
| | | EimsSpareInoutdtVo queryById(Long id); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å¤ä»¶åºå
¥åºæç»å表 |
| | | * |
| | | * @param bo æ¥è¯¢æ¡ä»¶ |
| | | * @param pageQuery å页忰 |
| | | * @return å¤ä»¶åºå
¥åºæç»å页å表 |
| | | */ |
| | | TableDataInfo<EimsSpareInoutdtVo> queryPageList(EimsSpareInoutdtBo bo, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¬¦åæ¡ä»¶çå¤ä»¶åºå
¥åºæç»å表 |
| | | * |
| | | * @param bo æ¥è¯¢æ¡ä»¶ |
| | | * @return å¤ä»¶åºå
¥åºæç»å表 |
| | | */ |
| | | List<EimsSpareInoutdtVo> queryList(EimsSpareInoutdtBo bo); |
| | | |
| | | /** |
| | | * æ°å¢å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param bo å¤ä»¶åºå
¥åºæç» |
| | | * @return æ¯å¦æ°å¢æå |
| | | */ |
| | | Boolean insertByBo(EimsSpareInoutdtBo bo); |
| | | |
| | | /** |
| | | * ä¿®æ¹å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param bo å¤ä»¶åºå
¥åºæç» |
| | | * @return æ¯å¦ä¿®æ¹æå |
| | | */ |
| | | Boolean updateByBo(EimsSpareInoutdtBo bo); |
| | | |
| | | /** |
| | | * æ ¡éªå¹¶æ¹éå é¤å¤ä»¶åºå
¥åºæç»ä¿¡æ¯ |
| | | * |
| | | * @param ids å¾
å é¤ç主é®éå |
| | | * @param isValid æ¯å¦è¿è¡æææ§æ ¡éª |
| | | * @return æ¯å¦å 餿å |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | } |
| | |
| | | package org.dromara.eims.service; |
| | | |
| | | import org.dromara.eims.domain.bo.EimsSpareInoutBo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareVo; |
| | | import org.dromara.eims.domain.bo.EimsSpareBo; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | |
| | | * @return æ¯å¦å 餿å |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®å¤ä»¶æ¥è¯¢åºå
¥åºæç» |
| | | * @param bo |
| | | * @param pageQuery |
| | | * @return |
| | | */ |
| | | TableDataInfo<EimsSpareInoutdtVo> querySpareInoutList(EimsSpareBo bo, PageQuery pageQuery); |
| | | } |
| | |
| | | package org.dromara.eims.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.dromara.common.core.constant.DictConstants; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.eims.domain.EimsSpare; |
| | | import org.dromara.eims.domain.EimsSpareInoutdt; |
| | | import org.dromara.eims.domain.bo.EimsSpareBo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareVo; |
| | | import org.dromara.eims.mapper.EimsSpareInoutdtMapper; |
| | | import org.dromara.eims.mapper.EimsSpareMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.dromara.eims.domain.bo.EimsSpareInoutBo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutVo; |
| | | import org.dromara.eims.domain.EimsSpareInout; |
| | | import org.dromara.eims.mapper.EimsSpareInoutMapper; |
| | | import org.dromara.eims.service.IEimsSpareInoutService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collection; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºServiceä¸å¡å±å¤ç |
| | |
| | | public class EimsSpareInoutServiceImpl implements IEimsSpareInoutService { |
| | | |
| | | private final EimsSpareInoutMapper baseMapper; |
| | | private final EimsSpareInoutdtMapper inoutdtMapper; |
| | | private final EimsSpareMapper spareMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢å¤ä»¶åºå
¥åº |
| | |
| | | */ |
| | | @Override |
| | | public EimsSpareInoutVo queryById(Long id){ |
| | | return baseMapper.selectVoById(id); |
| | | EimsSpareInoutVo eimsSpareInoutVo = baseMapper.selectVoById(id); |
| | | QueryWrapper<EimsSpareInoutdt> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(EimsSpareInoutdt::getInoutId, id); |
| | | List<EimsSpareInoutdtVo> dtVos = inoutdtMapper.selectVoList(queryWrapper); |
| | | if(!dtVos.isEmpty()){ |
| | | Map<Long, Long> map = dtVos.stream() |
| | | .collect(Collectors.toMap( |
| | | EimsSpareInoutdtVo::getSpareId, |
| | | EimsSpareInoutdtVo::getQuantity |
| | | )); |
| | | List<Long> spareIdList = dtVos.stream() |
| | | .map(EimsSpareInoutdtVo::getSpareId) // è·å spareId åæ®µ |
| | | .toList(); |
| | | |
| | | List<EimsSpareVo> eimsSpareListVos = spareMapper.selectVoBatchIds(spareIdList); |
| | | |
| | | for (EimsSpareVo spareVo : eimsSpareListVos) { |
| | | // å设 quantity ç弿¯ä¸ä¸ªåºå®å¼ï¼ä¾å¦ 10ï¼ |
| | | spareVo.setQuantity(map.get(spareVo.getId())); |
| | | } |
| | | |
| | | eimsSpareInoutVo.setSpareList(eimsSpareListVos); |
| | | } |
| | | |
| | | |
| | | |
| | | return eimsSpareInoutVo; |
| | | } |
| | | |
| | | /** |
| | |
| | | Page<EimsSpareInoutVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¬¦åæ¡ä»¶çå¤ä»¶åºå
¥åºå表 |
| | |
| | | return lqw; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ°å¢å¤ä»¶åºå
¥åº |
| | | * |
| | | * @param bo å¤ä»¶åºå
¥åº |
| | | * @return æ¯å¦æ°å¢æå |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Boolean insertByBo(EimsSpareInoutBo bo) { |
| | | public synchronized Boolean insertByBo(EimsSpareInoutBo bo) { |
| | | EimsSpareInout add = MapstructUtils.convert(bo, EimsSpareInout.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setId(add.getId()); |
| | | } |
| | | //å
¥åºï¼åºå åºåº-åºå ï¼é»è®¤å
¥åºï¼ |
| | | int OperationType; |
| | | |
| | | //åºåº |
| | | if(bo.getType().equals(DictConstants.SPARE_INOUT_TYPE_DETAIL.CK)){ |
| | | OperationType = -1; |
| | | } else { |
| | | OperationType = 1; |
| | | } |
| | | |
| | | List<EimsSpareBo> spareList = Optional.ofNullable(bo.getSpareList()).orElse(new ArrayList<>()); |
| | | // æå
¥åºåºæç» |
| | | List<EimsSpareInoutdt> dtList = spareList.stream() |
| | | .map(eimsSpareBo -> { |
| | | EimsSpareInoutdt dt = new EimsSpareInoutdt(); |
| | | dt.setInoutId(add.getId()); |
| | | dt.setSpareId(eimsSpareBo.getId()); |
| | | dt.setBeforeStock(eimsSpareBo.getActualStock()); |
| | | // 注æå
¥åºåºåº |
| | | dt.setActualStock(eimsSpareBo.getActualStock() + (eimsSpareBo.getQuantity() * OperationType)); |
| | | dt.setQuantity(eimsSpareBo.getQuantity()); |
| | | |
| | | // 设置åä»·åéé¢ |
| | | Optional.ofNullable(eimsSpareBo.getReferPrice()).ifPresent(referPrice -> { |
| | | dt.setUnitPrice(referPrice); |
| | | dt.setAmount(referPrice.multiply(BigDecimal.valueOf(eimsSpareBo.getQuantity()))); |
| | | }); |
| | | |
| | | return dt; |
| | | }) |
| | | .toList(); |
| | | |
| | | // æ¹éæå
¥æ°æ® |
| | | if (!dtList.isEmpty()) { |
| | | inoutdtMapper.insertBatch(dtList); |
| | | } |
| | | |
| | | // æ´æ°å¤ä»¶çåºå |
| | | List<EimsSpare> updateSpareList = spareList.stream().map(spareBo -> { |
| | | EimsSpare spare = new EimsSpare(); |
| | | spare.setId(spareBo.getId()); |
| | | spare.setActualStock(spareBo.getActualStock() + (spareBo.getQuantity() * OperationType)); |
| | | // 设置åä»·åéé¢ |
| | | Optional.ofNullable(spareBo.getReferPrice()).ifPresent(referPrice -> { |
| | | spare.setStockAmount(referPrice.multiply(BigDecimal.valueOf(spare.getActualStock()))); |
| | | }); |
| | | return spare; |
| | | }).toList(); |
| | | |
| | | if (!updateSpareList.isEmpty()) { |
| | | spareMapper.updateBatchById(updateSpareList); |
| | | } |
| | | return flag; |
| | | } |
| | |
| | | } |
| | | return baseMapper.deleteByIds(ids) > 0; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.eims.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.eims.domain.vo.EimsMaintStVo; |
| | | import org.springframework.stereotype.Service; |
| | | import org.dromara.eims.domain.bo.EimsSpareInoutdtBo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.dromara.eims.domain.EimsSpareInoutdt; |
| | | import org.dromara.eims.mapper.EimsSpareInoutdtMapper; |
| | | import org.dromara.eims.service.IEimsSpareInoutdtService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * å¤ä»¶åºå
¥åºæç»Serviceä¸å¡å±å¤ç |
| | | * |
| | | * @author zhuguifei |
| | | * @date 2025-04-11 |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class EimsSpareInoutdtServiceImpl implements IEimsSpareInoutdtService { |
| | | |
| | | private final EimsSpareInoutdtMapper baseMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return å¤ä»¶åºå
¥åºæç» |
| | | */ |
| | | @Override |
| | | public EimsSpareInoutdtVo queryById(Long id){ |
| | | return baseMapper.selectVoById(id); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å¤ä»¶åºå
¥åºæç»å表 |
| | | * |
| | | * @param bo æ¥è¯¢æ¡ä»¶ |
| | | * @param pageQuery å页忰 |
| | | * @return å¤ä»¶åºå
¥åºæç»å页å表 |
| | | */ |
| | | @Override |
| | | public TableDataInfo<EimsSpareInoutdtVo> queryPageList(EimsSpareInoutdtBo bo, PageQuery pageQuery) { |
| | | Page<EimsSpareInoutdtVo> result = baseMapper.selectSpareInoutdtList(pageQuery.build(), buildWrapper(bo)); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¬¦åæ¡ä»¶çå¤ä»¶åºå
¥åºæç»å表 |
| | | * |
| | | * @param bo æ¥è¯¢æ¡ä»¶ |
| | | * @return å¤ä»¶åºå
¥åºæç»å表 |
| | | */ |
| | | @Override |
| | | public List<EimsSpareInoutdtVo> queryList(EimsSpareInoutdtBo bo) { |
| | | LambdaQueryWrapper<EimsSpareInoutdt> lqw = buildQueryWrapper(bo); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<EimsSpareInoutdt> buildQueryWrapper(EimsSpareInoutdtBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<EimsSpareInoutdt> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(bo.getInoutId() != null, EimsSpareInoutdt::getInoutId, bo.getInoutId()); |
| | | lqw.eq(bo.getSpareId() != null, EimsSpareInoutdt::getSpareId, bo.getSpareId()); |
| | | return lqw; |
| | | } |
| | | |
| | | private QueryWrapper<EimsSpareInoutdt> buildWrapper(EimsSpareInoutdtBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | QueryWrapper<EimsSpareInoutdt> qw = Wrappers.query(); |
| | | qw.eq("io.id",bo.getInoutId()); |
| | | return qw; |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param bo å¤ä»¶åºå
¥åºæç» |
| | | * @return æ¯å¦æ°å¢æå |
| | | */ |
| | | @Override |
| | | public Boolean insertByBo(EimsSpareInoutdtBo bo) { |
| | | EimsSpareInoutdt add = MapstructUtils.convert(bo, EimsSpareInoutdt.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setId(add.getId()); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹å¤ä»¶åºå
¥åºæç» |
| | | * |
| | | * @param bo å¤ä»¶åºå
¥åºæç» |
| | | * @return æ¯å¦ä¿®æ¹æå |
| | | */ |
| | | @Override |
| | | public Boolean updateByBo(EimsSpareInoutdtBo bo) { |
| | | EimsSpareInoutdt update = MapstructUtils.convert(bo, EimsSpareInoutdt.class); |
| | | validEntityBeforeSave(update); |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | /** |
| | | * ä¿ååçæ°æ®æ ¡éª |
| | | */ |
| | | private void validEntityBeforeSave(EimsSpareInoutdt entity){ |
| | | //TODO åä¸äºæ°æ®æ ¡éª,å¦å¯ä¸çº¦æ |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªå¹¶æ¹éå é¤å¤ä»¶åºå
¥åºæç»ä¿¡æ¯ |
| | | * |
| | | * @param ids å¾
å é¤ç主é®éå |
| | | * @param isValid æ¯å¦è¿è¡æææ§æ ¡éª |
| | | * @return æ¯å¦å 餿å |
| | | */ |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if(isValid){ |
| | | //TODO åä¸äºä¸å¡ä¸çæ ¡éª,夿æ¯å¦éè¦æ ¡éª |
| | | } |
| | | return baseMapper.deleteByIds(ids) > 0; |
| | | } |
| | | } |
| | |
| | | package org.dromara.eims.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.eims.domain.EimsSpareInout; |
| | | import org.dromara.eims.domain.bo.EimsSpareInoutBo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutVo; |
| | | import org.dromara.eims.domain.vo.EimsSpareInoutdtVo; |
| | | import org.springframework.stereotype.Service; |
| | | import org.dromara.eims.domain.bo.EimsSpareBo; |
| | | import org.dromara.eims.domain.vo.EimsSpareVo; |
| | |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public TableDataInfo<EimsSpareInoutdtVo> querySpareInoutList(EimsSpareBo bo, PageQuery pageQuery) { |
| | | Page<EimsSpareInoutdtVo> result = baseMapper.selectSpareInoutList(pageQuery.build(), buildWrapper(bo)); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¬¦åæ¡ä»¶çå¤ä»¶å°è´¦å表 |
| | | * |
| | |
| | | lqw.like(StringUtils.isNotBlank(bo.getSupplier()), EimsSpare::getSupplier, bo.getSupplier()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getUnit()), EimsSpare::getUnit, bo.getUnit()); |
| | | return lqw; |
| | | } |
| | | |
| | | private QueryWrapper<EimsSpare> buildWrapper(EimsSpareBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | QueryWrapper<EimsSpare> qw = Wrappers.query(); |
| | | qw.eq( "sp.id", bo.getId()); |
| | | return qw; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return baseMapper.deleteByIds(ids) > 0; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.dromara.eims.mapper.EimsSpareInoutdtMapper"> |
| | | <resultMap type="org.dromara.eims.domain.vo.EimsSpareInoutdtVo" id="SpareInoutdtVoResult"> |
| | | </resultMap> |
| | | <select id="selectSpareInoutdtList" resultMap="SpareInoutdtVoResult"> |
| | | SELECT dt.*, sp.name spareName, sp.code spareCode, sp.model_no modelNo, sp.unit unit, io.order_code orderCode |
| | | FROM eims_spare_inoutdt dt |
| | | LEFT JOIN eims_spare_inout io on dt.inout_id = io.id |
| | | LEFT JOIN eims_spare sp on dt.spare_id = sp.id |
| | | ${ew.getCustomSqlSegment} |
| | | </select> |
| | | </mapper> |
| | |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.dromara.eims.mapper.EimsSpareMapper"> |
| | | |
| | | <resultMap type="org.dromara.eims.domain.vo.EimsSpareInoutdtVo" id="SpareInoutdtVoResult"> |
| | | </resultMap> |
| | | <select id="selectSpareInoutList" resultMap="SpareInoutdtVoResult"> |
| | | SELECT io.*, dt.quantity, dt.actual_stock, dt.unit_price, dt.amount |
| | | FROM eims_spare_inout io |
| | | JOIN eims_spare_inoutdt dt on io.id = dt.inout_id |
| | | JOIN eims_spare sp on dt.spare_id = sp.id |
| | | ${ew.getCustomSqlSegment} |
| | | </select> |
| | | </mapper> |