Repository: PLQin/FED-gadget-template Branch: master Commit: 7d62c71c01bc Files: 23 Total size: 37.7 KB Directory structure: gitextract_96sclw33/ ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github/ │ └── ISSUE_TEMPLATE/ │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── .vscode/ │ └── settings.json ├── LICENSE ├── README.md ├── babel.config.js ├── bash/ │ ├── commit.sh │ └── pull-r.sh ├── config/ │ ├── cdn.js │ ├── webpack.config.dev.js │ ├── webpack.config.js │ └── webpack.config.prod.js ├── package.json ├── public/ │ └── index.html ├── src/ │ ├── App.vue │ ├── components/ │ │ └── HelloWorld.vue │ └── main.js └── vue.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintignore ================================================ # Windows image file caches Thumbs.db ehthumbs.db # Node and JavaScript node_modules dist # yarn and npm files yarn-*.log npm-*.log *.log # local env files .env.local .env.*.local # Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Windows Installer files *.cab *.msi *.msm *.msp # Windows shortcuts *.lnk # ========================= # Operating System Files # ========================= # OSX # ========================= .DS_Store .AppleDouble .LSOverride # Thumbnails ._* # Files that might appear on external disk .Spotlight-V100 .Trashes # Directories potentially created on remote AFP share .AppleDB .AppleDesktop Network Trash Folder Temporary Items .apdisk # Editor directories and files .idea .vscode *.suo *.ntvs* *.njsproj *.sln *.sw? ================================================ FILE: .eslintrc.js ================================================ module.exports = { root: true, parserOptions: { parser: 'babel-eslint', sourceType: 'module' }, env: { browser: true, node: true, es6: true, }, extends: ['plugin:vue/recommended', 'eslint:recommended'], // add your custom rules here //it is base on https://github.com/vuejs/eslint-config-vue rules: { "vue/max-attributes-per-line": [2, { "singleline": 10, "multiline": { "max": 1, "allowFirstLine": false } }], "vue/singleline-html-element-content-newline": "off", "vue/multiline-html-element-content-newline":"off", "vue/name-property-casing": ["error", "PascalCase"], "vue/no-v-html": "off", 'accessor-pairs': 2, 'arrow-spacing': [2, { 'before': true, 'after': true }], 'block-spacing': [2, 'always'], 'brace-style': [2, '1tbs', { 'allowSingleLine': true }], 'camelcase': [0, { 'properties': 'always' }], 'comma-dangle': [2, 'never'], 'comma-spacing': [2, { 'before': false, 'after': true }], 'comma-style': [2, 'last'], 'constructor-super': 2, 'curly': [2, 'multi-line'], 'dot-location': [2, 'property'], 'eol-last': 2, 'eqeqeq': ["error", "always", {"null": "ignore"}], 'generator-star-spacing': [2, { 'before': true, 'after': true }], 'handle-callback-err': [2, '^(err|error)$'], 'indent': [2, 2, { 'SwitchCase': 1 }], 'jsx-quotes': [2, 'prefer-single'], 'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }], 'keyword-spacing': [2, { 'before': true, 'after': true }], 'new-cap': [2, { 'newIsCap': true, 'capIsNew': false }], 'new-parens': 2, 'no-array-constructor': 2, 'no-caller': 2, 'no-console': 'off', 'no-class-assign': 2, 'no-cond-assign': 2, 'no-const-assign': 2, 'no-control-regex': 0, 'no-delete-var': 2, 'no-dupe-args': 2, 'no-dupe-class-members': 2, 'no-dupe-keys': 2, 'no-duplicate-case': 2, 'no-empty-character-class': 2, 'no-empty-pattern': 2, 'no-eval': 2, 'no-ex-assign': 2, 'no-extend-native': 2, 'no-extra-bind': 2, 'no-extra-boolean-cast': 2, 'no-extra-parens': [2, 'functions'], 'no-fallthrough': 2, 'no-floating-decimal': 2, 'no-func-assign': 2, 'no-implied-eval': 2, 'no-inner-declarations': [2, 'functions'], 'no-invalid-regexp': 2, 'no-irregular-whitespace': 2, 'no-iterator': 2, 'no-label-var': 2, 'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }], 'no-lone-blocks': 2, 'no-mixed-spaces-and-tabs': 2, 'no-multi-spaces': 2, 'no-multi-str': 2, 'no-multiple-empty-lines': [2, { 'max': 1 }], 'no-native-reassign': 2, 'no-negated-in-lhs': 2, 'no-new-object': 2, 'no-new-require': 2, 'no-new-symbol': 2, 'no-new-wrappers': 2, 'no-obj-calls': 2, 'no-octal': 2, 'no-octal-escape': 2, 'no-path-concat': 2, 'no-proto': 2, 'no-redeclare': 2, 'no-regex-spaces': 2, 'no-return-assign': [2, 'except-parens'], 'no-self-assign': 2, 'no-self-compare': 2, 'no-sequences': 2, 'no-shadow-restricted-names': 2, 'no-spaced-func': 2, 'no-sparse-arrays': 2, 'no-this-before-super': 2, 'no-throw-literal': 2, 'no-trailing-spaces': 2, 'no-undef': 2, 'no-undef-init': 2, 'no-unexpected-multiline': 2, 'no-unmodified-loop-condition': 2, 'no-unneeded-ternary': [2, { 'defaultAssignment': false }], 'no-unreachable': 2, 'no-unsafe-finally': 2, 'no-unused-vars': [2, { 'vars': 'all', 'args': 'none' }], 'no-useless-call': 2, 'no-useless-computed-key': 2, 'no-useless-constructor': 2, 'no-useless-escape': 0, 'no-whitespace-before-property': 2, 'no-with': 2, 'one-var': [2, { 'initialized': 'never' }], 'operator-linebreak': [2, 'after', { 'overrides': { '?': 'before', ':': 'before' } }], 'padded-blocks': [2, 'never'], 'quotes': [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }], 'semi': [2, 'never'], 'semi-spacing': [2, { 'before': false, 'after': true }], 'space-before-blocks': [2, 'always'], 'space-before-function-paren': [2, 'never'], 'space-in-parens': [2, 'never'], 'space-infix-ops': 2, 'space-unary-ops': [2, { 'words': true, 'nonwords': false }], 'spaced-comment': [2, 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }], 'template-curly-spacing': [2, 'never'], 'use-isnan': 2, 'valid-typeof': 2, 'wrap-iife': [2, 'any'], 'yield-star-spacing': [2, 'both'], 'yoda': [2, 'never'], 'prefer-const': 2, 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 'object-curly-spacing': [2, 'always', { objectsInObjects: false }], 'array-bracket-spacing': [2, 'never'], } } ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto # Custom for Visual Studio *.cs diff=csharp # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: 🚨 Bug report | Bug 提交 about: Create a report to help us improve title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Version [e.g. 22] **Smartphone (please complete the following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - Browser [e.g. stock browser, safari] - Version [e.g. 22] **Additional context** Add any other context about the problem here. ================================================ FILE: .github/ISSUE_TEMPLATE/custom.md ================================================ --- name: Custom issue template about: Describe this issue template's purpose here. title: '' labels: '' assignees: '' --- ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: 🙋 Feature request | 新功能提案 about: Suggest an idea or enhancement. title: '' labels: 'feature-request' assignees: '' --- ### \# Is your feature request related to a problem? Please describe. ### \# Describe the solution you'd like ### \# Describe alternatives you've considered ### \# Additional context ================================================ FILE: .gitignore ================================================ # Windows image file caches Thumbs.db ehthumbs.db # Node and JavaScript node_modules dist # yarn and npm files yarn-*.log npm-*.log *.log # local env files .env.local .env.*.local # Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Windows Installer files *.cab *.msi *.msm *.msp # Windows shortcuts *.lnk # ========================= # Operating System Files # ========================= # OSX # ========================= .DS_Store .AppleDouble .LSOverride # Thumbnails ._* # Files that might appear on external disk .Spotlight-V100 .Trashes # Directories potentially created on remote AFP share .AppleDB .AppleDesktop Network Trash Folder Temporary Items .apdisk ================================================ FILE: .vscode/settings.json ================================================ { "code-runner.runInTerminal": true, "git.ignoreLimitWarning": true, "vetur.format.defaultFormatterOptions": { "prettier": { "semi": false, // 不要分号分号 "singleQuote": true, // 要单引号 }, }, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "vetur.validation.template": false, "editor.detectIndentation": false, "editor.tabSize": 2, "search.exclude": { "**/dist": true }, "files.watcherExclude": { "**/dist/**": true }, "eslint.alwaysShowStatus": true, "terminal.integrated.confirmOnExit": true, "terminal.integrated.cursorBlinking": true, } ================================================ FILE: LICENSE ================================================ Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. ================================================ FILE: README.md ================================================

Welcome to vue-pc-template 👋

Version Documentation Maintenance License: MIT

> Vue PC端的模板。拥有基本的页面,例子和恰到好处的配置,fork后就可以立即使用。如果它帮助到你,请给我一颗星星。 > 本仓库地址: https://github.com/PLQin/vue-pc-template。 > 你的star是我更新的动力。 ## 💋 鸣谢 感谢 [vuejs/vue](https://github.com/vuejs/vue),还有其他所有的开源作者。 ## 😜 功能与配置 - `mock` 运行命令`npm run mock`后,再运行命令`npm run serve:local`。或结合[vue-mock-cli](https://github.com/PLQin/vue-mock-cli)食用。 - 移动端适配 - 路由缓存 本模版不支持 ***(也不计划支持)*** 全局配置路由缓存,有需要的话可以尝试引入`vue-navigation`之类的modules或者在 `` 处进行自定义配置。 - 内置装饰器 有些场景使用装饰器比在代码里面硬编码显得更简单,比如防抖节流,确认提示等等,当前模版内置了一小部分装饰器,更多装饰器正在完善中。 - gzip打包压缩代码 通过配置压缩工具,可以在`build`的时候,自动将静态资源压缩为`gz`文件,当部署的服务器 启用`gzip`功能后,将会自动加载压缩的文件,提高加载速度。 - 二次封装`axios` 本模版对`axios`进行了二次封装,使用时只需要调整一下`token`获取方式,封装文件位置在 `src/utils/request.js`。 - 日期工具类 本模版食用 [dayjs](https://github.com/xx45/dayjs),它在GitHub上有28.2K的赞,是一个使用范围极广的时间日期库,更重要的是: - 支持UTC - 支持国际化 - 相比moment.js加上locals后3,400KB的体积,dayjs只有2KB - 代码规范与提交规范 本模版内部集成了`eslint`,全方位的去管控代码规范,为了方便使用,建议使用开发工具如 `vscode` 时需要安装`EsLint`插件。 虽然定义了`eslint`,但是假如在提交代码时不去校验,那么也无法有效的限制,所以定义了提交规范,在提交时会自动校验代码格式,并自动格式化。 - `cdn` 如果项目需要使用`cdn`的话,经常会将`cdn`的地址添加到`index.html`文件内,同时要对开发和生产环境进行区分,为了方便开发,模版内将`cdn`提取到了固定的文件内`cdn.js`,在这个文件内可以指定哪些文件使用`cdn`,同时有开关可以直接关闭`cdn`,具体文件在 `config/cdn.js`文件中。 - 目录结构 整个模版目录结构比较完整,基本可以满足常规开发,同时,为了提供功能复用,对于组件,分成了`base`与`components`两个目录,`base`里面放没有业务的基本组件,`components`里面放业务相关的组件,同时`base`目录里面提供了一个`loading`组件,在页面使用时可以直接使用`this.$loading()`调用。 - 文档 在开发中,一种功能可能会有多种选择,为了满足大家多种选择的需求,本模版特意添加的文档模块,对存在多种方案配置的内容通过文档和示例的方式记录下来,方便大家切换。 ## 😁 所有命令 ```shell # 安装 npm run install # 启动开发环境 npm run serve # 其他人员配置开发环境(这样的话,各开发人员之间配置互不冲突) npm run serve:local # 启动开发环境(接口地址将指向测试数据的接口) npm run serve:mock # 打包 npm run build # 打包(将log日志输出在当前目录) npm run build:log # 启动json-server提供测试数据 npm run mock # 启动json-server提供测试数据(在服务器中) npm run mock:serve # 代码校验 npm run lint ``` 总结: 平时开发时,只需要启动 `npm run serve` 即可。 如果服务端暂时无法提供数据支撑,也只需同时启动 `npm run serve:mock` 与 `npm run mock`。 当仅个别接口需要使用mock数据时,仅需将接口名例如 :`url: '/goods',` 改为 `url: 'mock/goods',` 即可,此时仅需要启动`npm run serve` 与 `npm run mock`。 ## 😥 常见问题 ## 🔑 环境配置 - node >= 12.18.0 - npm >= 6.14.0 ## 👤 贡献者 * Website: [@PLQin](https://segmentfault.com/u/_raymond) * Github: [@PLQin](https://github.com/PLQin) ## 🤝 参与贡献 问题或功能请求都是受欢迎的! 请查看[issue页面](https://github.com/PLQin/vue-pc-template/issues). ## 📝 License Copyright © 2020 [PLQin](https://github.com/PLQin).
This project is [MIT](https://github.com/PLQin/vue-pc-template/blob/master/LICENSE) licensed. --- _This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_ ================================================ FILE: babel.config.js ================================================ module.exports = { presets: [ '@vue/cli-plugin-babel/preset' ] } ================================================ FILE: bash/commit.sh ================================================ #!/bin/sh # Window only # Win使用命令 start [name].sh 即可运行此脚本,或双击脚本亦可 date +"%Y-%m-%d %H:%M:%S"" ------ git add ." git add ../ date +"%Y-%m-%d %H:%M:%S"" ------ git commit" echo -n "请填写commit(可空)" read remarks if [ ! -n "$remarks" ];then remarks=`date +%Y-%m-%d" "%H:%M:%S` fi git commit -m "$remarks" date +"%Y-%m-%d %H:%M:%S"" ------ git pull" git pull date +"%Y-%m-%d %H:%M:%S"" ------ 请自行执行 git push" # git push exec /bin/bash ================================================ FILE: bash/pull-r.sh ================================================ #!/bin/sh # Window only # Win使用命令 start [name].sh 即可运行此脚本,或双击脚本亦可 date +"%Y-%m-%d %H:%M:%S"" ------ git stash" git stash date +"%Y-%m-%d %H:%M:%S"" ------ git pull -r" git pull -r date +"%Y-%m-%d %H:%M:%S"" ------ git stash pop" git stash pop exec /bin/bash ================================================ FILE: config/cdn.js ================================================ // 记录所有cdn的路径,生产环境使用,可根据生产环境不同切换不同的cdn数据源 module.exports = { // 是否启用CDN enable: true, JS: { vue: { url: 'https://cdn.bootcss.com/vue/2.6.11/vue.min.js', exportName: 'Vue' }, vuex: { url: 'https://cdn.bootcdn.net/ajax/libs/vuex/3.2.0/vuex.js', exportName: 'Vuex' }, 'vue-router': { url: 'https://cdn.bootcss.com/vue-router/3.2.0/vue-router.min.js', exportName: 'VueRouter' }, axios: 'https://cdn.bootcss.com/axios/0.19.2/axios.min.js' }, CSS: {} } ================================================ FILE: config/webpack.config.dev.js ================================================ module.exports = (/** config */) => { // webpack.devtool = 'cheap-source-map' // config.devtool = 'cheap-inline-source-map' // config.css = { sourceMap: true } } ================================================ FILE: config/webpack.config.js ================================================ const path = require('path') const resolve = dir => path.resolve(__dirname, '../', dir) module.exports = config => { // 通用配置 // 设置路径别名 config.resolve.alias.set('@', resolve('./src')) // NPM引入的模块之间有共同的依赖 , 如何进行删减压缩,See:https://segmentfault.com/q/1010000023113947/a-1020000023206379 // config.resolve.alias.set('bn.js', path.resolve(process.cwd(), 'node_modules', 'bn.js')) // 根据环境不同,执行不同的配置 if (process.env.NODE_ENV === 'production') { require('./webpack.config.prod.js')(config) } else { require('./webpack.config.dev.js')(config) } } ================================================ FILE: config/webpack.config.prod.js ================================================ const cdn = require('./cdn') module.exports = config => { // 如果启用了cdn,则添加cdn内容 if (cdn.enable) { config.plugin('html').tap(args => { args.forEach(arg => { arg.cdns = { JS: Object.values(cdn.JS).map(item => { return typeof item === 'string' ? item : item.url }), CSS: Object.values(cdn.CSS) } }) return args }) config.externals( Object.entries(cdn.JS).reduce((result, [key, value]) => { result[key] = typeof value === 'string' ? key : value.exportName return result }, {}) ) } } ================================================ FILE: package.json ================================================ { "name": "vue-pc-template", "version": "0.1.0", "description": "Vue PC Template, all you need to do is `git clone`", "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/PLQin/vue-pc-template.git" }, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "modern": "vue-cli-service build --modern", "report": "vue-cli-service build --report-json", "lint": "vue-cli-service lint", "mock": "json-server --watch mock/db.js --m mock/post-to-get.js", "analyzer": "vue-cli-service build --report" }, "dependencies": { "axios": "^0.19.2", "core-js": "^3.6.5", "dayjs": "^1.8.32", "js-cookie": "^2.2.1", "swiper": "^3.4.2", "vue": "^2.6.11", "vue-i18n": "^8.3.2", "vue-router": "^3.0.6", "vuex": "^3.1.1" }, "devDependencies": { "@vue/cli-plugin-babel": "^4.0.5", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-service": "^4.5.3", "babel-eslint": "^10.0.1", "babel-plugin-lodash": "^3.3.4", "compression-webpack-plugin": "^5.0.1", "eslint": "^6.7.2", "eslint-plugin-babel": "^5.3.0", "eslint-plugin-vue": "^6.2.2", "json-server": "^0.16.1", "lint-staged": "^10.2.11", "mockjs": "^1.1.0", "node-sass": "^4.14.1", "sass-loader": "^8.0.0", "vue-template-compiler": "^2.6.10", "webpack-bundle-analyzer": "^3.8.0" }, "keywords": [ "Vue", "Nuxt", "template", "vue-pc-template", "vue-pc-base" ], "gitHooks": { "prepare-commit-msg": "lint-staged" }, "lint-staged": { "*.{js,vue}": [ "vue-cli-service lint" ] }, "engines": { "node": ">= 12.18.0", "npm": ">= 6.14.0" }, "browserslist": [ "> 1%", "last 2 versions" ] } ================================================ FILE: public/index.html ================================================ <%= htmlWebpackPlugin.options.title %>
================================================ FILE: src/App.vue ================================================ ================================================ FILE: src/components/HelloWorld.vue ================================================ ================================================ FILE: src/main.js ================================================ import Vue from 'vue' import App from './App.vue' Vue.config.productionTip = false new Vue({ render: h => h(App) }).$mount('#app'); ================================================ FILE: vue.config.js ================================================ const webpackConfig = require('./config/webpack.config.js') const isProd = process.env.NODE_ENV === 'production' // gzip const CompressionWebpackPlugin = require('compression-webpack-plugin') // Configure the proxy address, which can also be set .env // When used with mock services, devServerProxyTarget is required. Otherwise, TypeError: Cannot read property 'upgrade' of undefined // https://segmentfault.com/q/1010000020916388 const devServerProxyTarget = 'http://149.129.114.76:9000' module.exports = { configureWebpack: config => { if (isProd) { // 配置webpack 压缩 config.plugins.push( new CompressionWebpackPlugin({ test: /\.js$|\.css$/, // 匹配文件名 threshold: 102400, // 对超过100kb进行压缩 deleteOriginalAssets: false // 是否删除原文件 }) ) } }, chainWebpack: config => { // 项目标题 config.plugin('html').tap(args => { args[0].title = '首页' return args }) webpackConfig(config) }, productionSourceMap: false, // 生产环境不需要 source map publicPath: !isProd ? '/' : '', css: { extract: !!isProd, // 是否将css 提取到独立的文件,生产环境提取,开发环境不提取 sourceMap: !isProd // 开发模式开启css sourcemap // loaderOptions: { // less: { // lessOptions: { // modifyVars: { // hack: 'true;@import "~@/style/_variables.less"' // } // } // } // } }, devServer: { proxy: { '^/mock': { target: process.env.VUE_APP_MOCK_BASE_URL || devServerProxyTarget, changeOrigin: false, pathRewrite: { '^/mock': '/mock' } }, '^/': { target: devServerProxyTarget, changeOrigin: false, pathRewrite: { '^/': '' } } } } }