Skip to content

Commit

Permalink
add file
Browse files Browse the repository at this point in the history
  • Loading branch information
yydounai1234 committed Dec 2, 2022
1 parent 23488db commit 1996a38
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
65 changes: 55 additions & 10 deletions packages/zeus-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,61 @@
# Vue 3 + TypeScript + Vite
# Zeus

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
**Zeus** 是一个 **vite** 插件,通过简单的插件引入,轻松获得缓存 app 本地文件与 fetch 请求的资源的能力,可以通过 [Zeus](https://yydounai1234.github.io/Zeus/) 查看示例。

## Recommended IDE Setup
## 使用方法

- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
* 下载插件
```javascript
npm install zeus-plugin --save-dev
```
***vite.config.ts** 中添加插件

## Type Support For `.vue` Imports in TS
```typescript
import zeusPlugin from 'zeus-plugin'
plugins: [...other plugins, zeusPlugin({
/** cache 版本号 */
cacheVersion: 1,
/** sw 版本号 */
swVersion: 1,
/** 初始缓存文件 */
appShellFiles: ["/source.webp"],
/** 拦截缓存文件的正则 */
patten: /image|png/
})]
```

Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
完整配置如下:

1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.

You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
```typescript
type ZeusOption = Partial<{
/**
* 作用域
*/
scope: string
/**
* 前缀
*/
prefix: string
/**
* SW 名
*/
swName: string
}> & {
/**
* SW 版本号
*/
swVersion: string
/**
* 缓存版本号
*/
cacheVersion: string
/**
* 初始缓存文件
*/
appShellFiles: string[]
/**
* 缓存请求正则
*/
patten: RegExp
}
```
10 changes: 9 additions & 1 deletion packages/zeus-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "zeus-plugin",
"private": true,
"private": false,
"version": "1.0.0",
"files": [
"dist/*.js",
"types/*.ts"
],
"repository": {
"type": "git",
"url": "git+https://github.com/yydounai1234/Zeus.git"
},
"scripts": {
"dev": "vite build -w",
"build": "vite build",
Expand Down

0 comments on commit 1996a38

Please sign in to comment.