目录

File Structure

Project File Structure

ASCF Code Structure

The ASCF code is stored in the ascf/ascf_src directory. In this directory, code files are organized into a two-layer structure: app and page.

|— app.json
|— app.js
|— app.css
|— components
|  |— cart.json
|  |— cart.hxml
|  |— cart.js
|  |— cart.css
|— pages
|  |— user.json
|  |— user.hxml
|  |— user.js
|  |— user.css

File Organization

[h2]File Storage

The files of an atomic service are stored in the following partitions:

[h2]URI

URIs identify application resources and files, and can be used to access application resources and files by using components or APIs.

Resource Type

URI

Read-Only

Example

Description

Application resource

/path

Yes

/Common/header.png

Path to the rawfile folder of the installation package.

Cache

internal://cache/path/

No

internal://cache/fetch-123456.png

Sandbox directory of the atomic service, which cannot be accessed by users.

Files

internal://files/path

No

internal://files/image/demo.png

Sandbox directory of the atomic service, which cannot be accessed by users.

Temp

internal://tmp/path

Yes

internal://tmp/xxxxx/demo.png (file name)

Dynamically generated by the system.

You can use the regular expression [^\\s\"'|*?<>\\\\]+ to specify the characters allowed in a URI. A URI cannot contain double periods (..). URIs support directories, which are separated by slashes (/). An internal URI indicates a file of an application. When specifying an internal URI, you do not need to specify the application ID. The same internal URI points to different files for different applications.

[h2]Resource and File Access Rules

An application resource can be specified by an absolute path (starting with a slash (/), for example, /Common/a.png) or a relative path (not starting with a slash (/), for example, a.png or ./Common/a.png).

Application resource files are classified into code files and resource files. Code files are files that contain code, such as .js, .css, and .hxml files. Other files are resource files, which can be used as data, like image and video files.

  1. To import a code file into another one, use the relative path of the code file to be imported, for example, ./Common/component.hxml.
  2. To reference a resource file (for example, an image file or a video file) in a code file, generally you can use the relative path of the resource file, for example, ./abc.png.
  3. When importing a code file to another and referencing a resource file in the imported code file, you can use a relative path to reference the resource file if the code files are in the same directory. If the code files are not in the same directory, you must use an absolute path because the imported code file is copied to the target file during compilation, which changes the directory structure.