1import{n as e,o as t,r as n}from"./app-DHdWsCsc.js";import{t as r}from"./plugin-vue_export-helper-BDNMzG2s.js";var i=JSON.parse(`{"path":"/file/","title":"@mptool/file","lang":"zh-CN","frontmatter":{"title":"@mptool/file","icon":"folder","description":"æä»¶ API æç¤º 请注æï¼æ¡æ¶ä¼èªå¨å¸®ä½ æ·»å USER_DATA_PATH ä½ä¸ºåç¼ï¼å æ¤ä½ æ éå
³æ³¨å®ã å·¥å
·ç±» dirname(path: string): string è¿åè·¯å¾çæä»¶å¤¹é¨å exists(path: string): boolean è¿åå¸å°å¼ï¼ä»£è¡¨æä»¶ææä»¶å¤¹æ¯å¦åå¨ isDir(path: string): boolean ...","head":[["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"@mptool/file\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2026-10-03T04:31:00.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"Mr.Hope\\",\\"url\\":\\"https://mister-hope.com\\"}]}"],["meta",{"property":"og:url","content":"https://miniapp-tool.github.io/file/"}],["meta",{"property":"og:site_name","content":"MP Tool"}],["meta",{"property":"og:title","content":"@mptool/file"}],["meta",{"property":"og:description","content":"æä»¶ API æç¤º 请注æï¼æ¡æ¶ä¼èªå¨å¸®ä½ æ·»å USER_DATA_PATH ä½ä¸ºåç¼ï¼å æ¤ä½ æ éå
³æ³¨å®ã å·¥å
·ç±» dirname(path: string): string è¿åè·¯å¾çæä»¶å¤¹é¨å exists(path: string): boolean è¿åå¸å°å¼ï¼ä»£è¡¨æä»¶ææä»¶å¤¹æ¯å¦åå¨ isDir(path: string): boolean ..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2026-10-03T04:31:00.000Z"}],["meta",{"property":"article:modified_time","content":"2026-10-03T04:31:00.000Z"}]]},"git":{"createdTime":1791001860000,"updatedTime":1791001860000,"contributors":[{"name":"renovate[bot]","username":"renovate[bot]","email":"29139614+renovate[bot]@users.noreply.github.com","commits":2,"url":"https://github.com/renovate[bot]"}]},"readingTime":{"minutes":3.8,"words":1139},"filePathRelative":"file/README.md","autoDesc":true}`),a={name:`README.md`};function o(r,i,a,o,s,c){return t(),e(`div`,null,[...i[0]||=[n(`<h2 id="æä»¶-api" tabindex="-1"><a class="header-anchor" href="#æä»¶-api"><span>æä»¶ API</span></a></h2><div class="hint-container tip"><p class="hint-container-title">æç¤º</p><p>请注æï¼æ¡æ¶ä¼èªå¨å¸®ä½ æ·»å <code>USER_DATA_PATH</code> ä½ä¸ºåç¼ï¼å æ¤ä½ æ éå
³æ³¨å®ã</p></div><h3 id="å·¥å
·ç±»" tabindex="-1"><a class="header-anchor" href="#å·¥å
·ç±»"><span>å·¥å
·ç±»</span></a></h3><ul><li><p><code>dirname(path: string): string</code></p><p>è¿åè·¯å¾çæä»¶å¤¹é¨å</p></li><li><p><code>exists(path: string): boolean</code></p><p>è¿åå¸å°å¼ï¼ä»£è¡¨æä»¶ææä»¶å¤¹æ¯å¦åå¨</p></li><li><p><code>isDir(path: string): boolean</code></p><p>è¿åå¸å°å¼ï¼ä»£è¡¨è·¯å¾æ¯å¦æ¯æä»¶å¤¹</p></li><li><p><code>isFile(path: string): boolean</code></p><p>è¿åå¸å°å¼ï¼ä»£è¡¨è·¯å¾æ¯å¦æ¯æä»¶</p></li></ul><h2 id="读åç±»" tabindex="-1"><a class="header-anchor" href="#读åç±»"><span>读åç±»</span></a></h2><ul><li><p><code>ls(path: string): string[]</code></p><p>以æ°ç»å½¢å¼ååºç®å½ä¸ææå
容</p></li><li><p><code>readFile(path: string, encoding?: string): string | ArrayBuffer | undefined</code></p><p>读åæå®è·¯å¾çæä»¶å
容并è¿åã彿件ä¸å卿¶ï¼è¿å <code>undefined</code>ã</p><p><code>encoding</code> 为æä»¶çç¼ç æ ¼å¼ï¼å¯éï¼é»è®¤ <code>"utf-8"</code></p></li><li><p><code>readJSON(path: string, encoding = 'utf-8'): any | undefined</code></p><p>读åå¯åºååæä»¶æ°æ®å¹¶è¿åè§£æç»æã</p><p>å½ JSON æä»¶ä¸åå¨æè§£æå¤±è´¥æ¶ï¼è¿å <code>undefined</code></p><ul><li><code>path</code>: 读åçæä»¶è·¯å¾ï¼ä¸åºå«æ <code>.json</code> åç¼</li><li><code>encoding</code>: æä»¶çç¼ç æ ¼å¼ï¼å¯éï¼é»è®¤ <code>utf-8</code></li></ul></li></ul><h3 id="æä½ç±»" tabindex="-1"><a class="header-anchor" href="#æä½ç±»"><span>æä½ç±»</span></a></h3><ul><li><p><code>mkdir(path: string, recursive = true): void</code></p><p>å建ç®å½ã第äºä¸ªåæ° <code>recursive</code> å¯éï¼ä»£è¡¨æ¯å¦éå½ç¶ç®å½ï¼é»è®¤éå½å建ã</p></li><li><p><code>rm(path: string, type?: "dir" | "file"): void</code></p><p>å 餿å®è·¯å¾ã</p><p>第äºä¸ªåæ° <code>type</code> æ¯å¯éçï¼å¯å¡«å
¥ <code>"dir"</code> æ <code>"file"</code>ï¼å¡«å
¥å¯æåå 餿§è½</p></li><li><p><code>writeFile(path: string, data: any, encoding?: string): void</code></p><p>åå
¥æä»¶</p><ul><li><code>path</code>: å¾
åå
¥çæä»¶è·¯å¾ï¼è¥æä»¶æå
¶ç¶æä»¶å¤¹ä¸åå¨ä¼èªå¨å建</li><li><code>data</code>: å¾
åå
¥çæ°æ®ï¼å¯æ¥åä»»æå¯åºååçæ°æ®æ Buffer</li><li><code>encoding</code>: æä»¶ç¼ç é项ï¼å¯éï¼é»è®¤ <code>utf-8</code> (æ°æ®) æ <code>binary</code> (Buffer)</li></ul></li><li><p><code>
1writeJSON(path: string, data: any, encoding = 'utf-8'): void</code></p><p>åå
¥å¯åºååæ°æ®ä¸º JSON</p><ul><li><code>path</code>: åå
¥æä»¶çè·¯å¾ï¼è¥ç¶æä»¶å¤¹ä¸åå¨ä¼èªå¨å建</li><li><code>data</code>: åå
¥æä»¶çæ°æ®ï¼å¯æ¥åä»»æå¯åºååçæ°æ®</li><li><code>encoding</code>: æä»¶ç¼ç é项ï¼é»è®¤ <code>utf-8</code></li></ul></li><li><p><code>saveFile(tempFilePath: string, path: string): void</code></p><p>å°ç¼åæä»¶ä¿åå°æ¬å°æä»¶åå¨ã</p><ul><li><code>tempFilePath</code>: ç¼åæä»¶è·¯å¾</li><li><code>path</code>: ä¿åæä»¶è·¯å¾</li></ul></li><li><p><code>saveOnlineFile(onlinePath: string, localPath: string): Promise<string></code></p><p>å°å¨çº¿æä»¶ä¿åå°æ¬å°æå®ä½ç½®ï¼è¿åä¿ååçæ¬å°æä»¶è·¯å¾ã</p><ul><li><code>onlinePath</code>: å¨çº¿æä»¶è·¯å¾</li><li><code>localPath</code>: æ¬å°æä»¶è·¯å¾</li></ul><div class="hint-container tip"><p class="hint-container-title">æç¤º</p><p>ä¿åç®å½ä¼èªå¨å建ã</p></div></li><li><p><code>unzip(zipFilePath: string, targetPath: string): Promise<void></code></p><p>è§£åæä»¶</p><ul><li><code>zipFilePath</code>: å¾
è§£åçå缩æä»¶è·¯å¾</li><li><code>targetPath</code>: è§£åå°çç®å½</li></ul><div class="hint-container tip"><p class="hint-container-title">æç¤º</p><p>è§£åç®å½ä¼èªå¨å建ã</p></div></li></ul><h2 id="åå¨-api" tabindex="-1"><a class="header-anchor" href="#åå¨-api"><span>åå¨ API</span></a></h2><h3 id="åå" tabindex="-1"><a class="header-anchor" href="#åå"><span>åå</span></a></h3><p><code>put</code> å <code>take</code> å¯ä»¥åå
¥ä»»ä½æ°æ®ï¼ä½åå
¥çæ°æ®åªè½ååºä¸æ¬¡ï¼ä¸ä»
å¨å½æ¬¡å°ç¨åºå¯å¨ä¸ææã</p><div class="hint-container tip"><p class="hint-container-title">æç¤º</p><p>为äºä¿è¯æ§è½ï¼ä»¥åç±äºå°ç¨åºå¯¹ <code>Function</code> è¿è¡äºç¹æ®å¤çï¼æä»¬ä¸ä¼å¯¹åå
¥çæ°æ®è¿è¡æ·±æ·è´ã</p></div><ul><li><p><code>put<T = unknown>(key: string, data: T): void</code>: åæ°æ®ã</p></li><li><p><code>take<T = unknown>(key: string): T | undefined</code>: åæ°æ®</p><div class="hint-container tip"><p class="hint-container-title">æç¤º</p><p>彿°æ®å·²ç»è¢«åè¿ä¸æ¬¡åï¼åç»è¿å <code>undefined</code>ã</p></div></li></ul><h3 id="坿ä¹
åæ°æ®" tabindex="-1"><a class="header-anchor" href="#坿ä¹
åæ°æ®"><span>坿ä¹
åæ°æ®</span></a></h3><p><code>get</code> å <code>set</code> è®¾ç½®çæ°æ®å¯æä¹
åï¼ä¸å¯ä»¥è®¾ç½®è¿ææ¶é´ã</p><div class="hint-container warning"><p class="hint-container-title">注æ</p><p>请注æç±äºå¾®ä¿¡å°ç¨åºåºå±ä¸çé®é¢ï¼èªå¨æ¸
é¤åªåçå¨ä¸ä¸æ¬¡è¯»åå¹¶åç°å·²ç»å¤±ææ¶ï¼å¦æä½ 没æåç»è¯»å对åºçåå¨ï¼å®ä»¬ä¼ä¸ç´ä¿å (å³ä½¿å·²ç»è¿æ)ã</p><p>æä»¥å¦æä½ 使ç¨äºå¤§é临æ¶çé®å¼å»åå
¥æ°æ®ï¼ä½ å¯è½éè¦å®æéè¿ <code>check</code> æå¨æ£æ¥å¹¶æ¸
é¤è¿ææ°æ®ã</p></div><ul><li><p><code>set(key: string, value: any, expire?: number | 'once' | 'keep' = 0): void</code></p><p>åæ¥è®¾ç½®æ°æ®ã</p><ul><li><code>key</code>: 设置çé®å</li><li><code>value</code>: åå
¥çå¼</li><li><code>expire</code>: è¿ææ¶é´ï¼å¯éï¼é»è®¤ä¸º <code>0</code><ul><li><code>0</code>: é»è®¤ï¼æ°¸ä¹
ææ</li><li><code>'once'</code>: ä»
æ¬æ¬¡å¯å¨ææ</li><li><code>'keep'</code>: è¡¨ç¤ºä¿æä¸ä¸æ¬¡æææ¶é´</li><li>æ°å: 以毫ç§ä¸ºåä½çæææ¶é´</li></ul></li></ul><div class="hint-container tip"><p class="hint-container-title">æç¤º</p><p>请注æï¼å¦æä¼ å
¥ <code>'keep'</code> æ¶ï¼åå¨ä¸ä¸åå¨ååé®å¼ï¼å该å¼ä¹ä¸ä¼è¢«åå
¥ã</p></div></li><li><p><code>setAsync(key: string, value: any, expire?: number | 'once' | 'keep' = 'once'): Promise<void></code></p><p><code>set</code> ç弿¥çæ¬ï¼å¨è®¾ç½®å¤§éæ°æ®æ¶å¯èè使ç¨ï¼è¿åä¸ä¸ª Promiseã</p></li><li><p><code>get<T = unknown>(key: string): T | undefined</code></p><p>åæ¥è¯»åæ°æ®å¹¶è¿åã</p><p>彿°æ®å·²ç»è¿ææ¶ï¼è¿å <code>undefined</code>ã</p><ul><li><code>key</code>: 设置çé®å</li></ul></li><li><p><code>getAsync<T = unknown>(key: string): Promise<T | undefined></code></p><p><code>get</code> ç弿¥çæ¬ï¼å¨è¯»å大鿰æ®é¿å
é»å¡çº¿ç¨æ¶å¯èè使ç¨ï¼è¿åä¸ä¸ª Promiseã</p><ul><li><code>key</code>: 设置çé®å</li></ul></li><li><p><code>remove(key: string): void</code></p><p>忥å 餿°æ®ã</p><ul><li><code>key</code>: å é¤çé®å</li></ul></li><li><p><code>removeAsync(key: string): Promise<void></code></p><p>弿¥å 餿°æ®ï¼è¿åä¸ä¸ª Promiseã</p><ul><li><code>key</code>: å é¤çé®å</li></ul></li><li><p><code>check(): void</code></p><p>åæ¥æ£æ¥å¹¶æ¸
çè¿ææ°æ®ã</p></li><li><p><code>checkAsync(): Promise<void></code></p><p>弿¥æ£æ¥å¹¶æ¸
çè¿ææ°æ®ï¼è¿åä¸ä¸ª Promiseã</p></li></ul>`,17)]])}var s=r(a,[[`render`,o]]);
1export{i as _pageData,s as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.