diff --git a/package.json b/package.json index 6759974..d4d6ed9 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "dev": "vite --host", "build": "pnpm run type-check:publish && vite build", "build:zip": "pnpm run build && powershell -NoProfile -Command \"New-Item -ItemType Directory -Force -Path release | Out-Null; Compress-Archive -Path dist\\* -DestinationPath release\\gao-customer-h5.zip -Force\"", + "twa:build": "cd twa && pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 build --manifest=./twa-manifest.json", + "twa:update": "cd twa && pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 update --skipVersionUpgrade --manifest=./twa-manifest.json", + "twa:validate": "pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 validate --url=https://gao.imyeyu.com/", "preview": "vite preview", "lint": "eslint . --ext .ts,.vue", "type-check": "vue-tsc -p tsconfig.app.json --noEmit", diff --git a/public/.well-known/assetlinks.json b/public/.well-known/assetlinks.json new file mode 100644 index 0000000..efa3990 --- /dev/null +++ b/public/.well-known/assetlinks.json @@ -0,0 +1,12 @@ +[ + { + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "com.imyeyu.gao.customer", + "sha256_cert_fingerprints": [ + "EF:65:BA:62:7D:E3:1C:D3:BD:C7:D9:1D:6A:69:35:81:56:87:DF:03:0D:E7:76:27:94:90:5E:CC:F4:45:02:69" + ] + } + } +] diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest index 16cdf94..b03200b 100644 --- a/public/manifest.webmanifest +++ b/public/manifest.webmanifest @@ -1,11 +1,13 @@ { - "name": "Gao Customer H5", - "short_name": "Gao H5", + "id": "/", + "name": "糕店客户管理", + "short_name": "糕店管理", "display": "standalone", "background_color": "#ffffff", "theme_color": "#ffffff", "start_url": "/", "scope": "/", + "orientation": "portrait", "icons": [ { "src": "/icons/icon-192.png", diff --git a/twa/.gitignore b/twa/.gitignore new file mode 100644 index 0000000..b0326bb --- /dev/null +++ b/twa/.gitignore @@ -0,0 +1,10 @@ +.gradle/ +local.properties +**/build/ +*.apk +*.aab +*.idsig +*.jks +*.keystore + +!gradle/wrapper/gradle-wrapper.jar diff --git a/twa/README.md b/twa/README.md new file mode 100644 index 0000000..74c54f7 --- /dev/null +++ b/twa/README.md @@ -0,0 +1,41 @@ +# TWA 构建说明 + +本目录是 `gao.imyeyu.com` 的 Trusted Web Activity 工程。APK 只包含 Android 启动壳,业务页面始终从 `https://gao.imyeyu.com/` 加载,不把前端 `dist` 打进 APK。 + +## 构建环境 + +- JDK 17 +- Android SDK +- Bubblewrap CLI 1.25.0 + +在本机首次使用 Bubblewrap 时执行: + +```powershell +pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 doctor +``` + +## 构建 APK + +首次构建正式版本时,先在本目录生成并妥善备份 release keystore: + +```powershell +keytool -genkeypair -v -keystore .\android.keystore -alias gao-customer -keyalg RSA -keysize 2048 -validity 10000 +``` + +```powershell +pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 build +``` + +构建前请准备长期保存的 release keystore,并确认 `twa-manifest.json` 中的 `signingKey` 指向它。当前目录的 `signingKey` 是可提交的相对路径模板;本次验证 APK 使用的是本机调试签名,不能作为正式发布签名。 + +构建完成后,用 release keystore 的 SHA-256 证书指纹更新 `../public/.well-known/assetlinks.json`,再发布前端 `dist`。TWA 只有在网站的 `/.well-known/assetlinks.json` 与 APK 包名、签名一致时,才会进入无地址栏的全屏模式。 + +当前 `assetlinks.json` 中登记的是本机调试证书指纹,只能配合本次验证 APK 使用。正式发布前必须替换为 release 证书指纹;如果使用 Google Play,还要把 Play App Signing 证书指纹一并登记。 + +## 前端发布顺序 + +1. 先上传新版本 `dist/assets`。 +2. 再上传新的 `index.html`、Manifest 和其他静态文件。 +3. 最后检查 `https://gao.imyeyu.com/`、`/manifest.webmanifest` 和 `/.well-known/assetlinks.json`。 + +`index.html` 不缓存,带哈希的 `/assets/` 长缓存。不要给前端资源增加 Service Worker 缓存,除非同时实现版本更新和回滚,否则会阻止 TWA 获取最新页面。 diff --git a/twa/app/build.gradle b/twa/app/build.gradle new file mode 100644 index 0000000..a78f726 --- /dev/null +++ b/twa/app/build.gradle @@ -0,0 +1,213 @@ +/* + * Copyright 2019 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import groovy.xml.MarkupBuilder + +plugins { + id 'com.android.application' +} + +def twaManifest = [ + applicationId: 'com.imyeyu.gao.customer', + hostName: 'gao.imyeyu.com', // The domain being opened in the TWA. + launchUrl: '/', // The start path for the TWA. Must be relative to the domain. + name: '糕店客户管理', // The application name. + launcherName: '糕店管理', // The name shown on the Android Launcher. + themeColor: '#FFFFFF', // The color used for the status bar. + themeColorDark: '#000000', // The color used for the dark status bar. + navigationColor: '#000000', // The color used for the navigation bar. + navigationColorDark: '#000000', // The color used for the dark navbar. + navigationDividerColor: '#000000', // The navbar divider color. + navigationDividerColorDark: '#000000', // The dark navbar divider color. + backgroundColor: '#FFFFFF', // The color used for the splash screen background. + enableNotifications: false, // Set to true to enable notification delegation. + // Every shortcut must include the following fields: + // - name: String that will show up in the shortcut. + // - short_name: Shorter string used if |name| is too long. + // - url: Absolute path of the URL to launch the app with (e.g '/create'). + // - icon: Name of the resource in the drawable folder to use as an icon. + shortcuts: [], + // The duration of fade out animation in milliseconds to be played when removing splash screen. + splashScreenFadeOutDuration: 300, + generatorApp: 'bubblewrap-cli', // Application that generated the Android Project + // The fallback strategy for when Trusted Web Activity is not available. Possible values are + // 'customtabs' and 'webview'. + fallbackType: 'customtabs', + enableSiteSettingsShortcut: 'true', + orientation: 'portrait', +] + +android { + compileSdkVersion 36 + namespace "com.imyeyu.gao.customer" + defaultConfig { + applicationId "com.imyeyu.gao.customer" + minSdkVersion 21 + targetSdkVersion 36 + versionCode 1 + versionName "1" + + // The name for the application + resValue "string", "appName", twaManifest.name + + // The name for the application on the Android Launcher + resValue "string", "launcherName", twaManifest.launcherName + + // The URL that will be used when launching the TWA from the Android Launcher + def launchUrl = "https://" + twaManifest.hostName + twaManifest.launchUrl + resValue "string", "launchUrl", launchUrl + + + + + // The URL the Web Manifest for the Progressive Web App that the TWA points to. This + // is used by Chrome OS and Meta Quest to open the Web version of the PWA instead of + // the TWA, as it will probably give a better user experience for non-mobile devices. + resValue "string", "webManifestUrl", 'https://gao.imyeyu.com/manifest.webmanifest' + + + + // This is used by Meta Quest. + resValue "string", "fullScopeUrl", 'https://gao.imyeyu.com/' + + + + + // The hostname is used when building the intent-filter, so the TWA is able to + // handle Intents to open host url of the application. + resValue "string", "hostName", twaManifest.hostName + + // This attribute sets the status bar color for the TWA. It can be either set here or in + // `res/values/colors.xml`. Setting in both places is an error and the app will not + // compile. If not set, the status bar color defaults to #FFFFFF - white. + resValue "color", "colorPrimary", twaManifest.themeColor + + // This attribute sets the dark status bar color for the TWA. It can be either set here or in + // `res/values/colors.xml`. Setting in both places is an error and the app will not + // compile. If not set, the status bar color defaults to #000000 - white. + resValue "color", "colorPrimaryDark", twaManifest.themeColorDark + + // This attribute sets the navigation bar color for the TWA. It can be either set here or + // in `res/values/colors.xml`. Setting in both places is an error and the app will not + // compile. If not set, the navigation bar color defaults to #FFFFFF - white. + resValue "color", "navigationColor", twaManifest.navigationColor + + // This attribute sets the dark navigation bar color for the TWA. It can be either set here + // or in `res/values/colors.xml`. Setting in both places is an error and the app will not + // compile. If not set, the navigation bar color defaults to #000000 - black. + resValue "color", "navigationColorDark", twaManifest.navigationColorDark + + // This attribute sets the navbar divider color for the TWA. It can be either + // set here or in `res/values/colors.xml`. Setting in both places is an error and the app + // will not compile. If not set, the divider color defaults to #00000000 - transparent. + resValue "color", "navigationDividerColor", twaManifest.navigationDividerColor + + // This attribute sets the dark navbar divider color for the TWA. It can be either + // set here or in `res/values/colors.xml`. Setting in both places is an error and the + //app will not compile. If not set, the divider color defaults to #000000 - black. + resValue "color", "navigationDividerColorDark", twaManifest.navigationDividerColorDark + + // Sets the color for the background used for the splash screen when launching the + // Trusted Web Activity. + resValue "color", "backgroundColor", twaManifest.backgroundColor + + // Defines a provider authority for the Splash Screen + resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider' + + // The enableNotification resource is used to enable or disable the + // TrustedWebActivityService, by changing the android:enabled and android:exported + // attributes + resValue "bool", "enableNotification", twaManifest.enableNotifications.toString() + + twaManifest.shortcuts.eachWithIndex { shortcut, index -> + resValue "string", "shortcut_name_$index", "$shortcut.name" + resValue "string", "shortcut_short_name_$index", "$shortcut.short_name" + } + + // The splashScreenFadeOutDuration resource is used to set the duration of fade out animation in milliseconds + // to be played when removing splash screen. The default is 0 (no animation). + resValue "integer", "splashScreenFadeOutDuration", twaManifest.splashScreenFadeOutDuration.toString() + + resValue "string", "generatorApp", twaManifest.generatorApp + + resValue "string", "fallbackType", twaManifest.fallbackType + + resValue "bool", "enableSiteSettingsShortcut", twaManifest.enableSiteSettingsShortcut + resValue "string", "orientation", twaManifest.orientation + + + } + buildTypes { + release { + minifyEnabled true + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + lintOptions { + checkReleaseBuilds false + } +} + +task generateShorcutsFile { + assert twaManifest.shortcuts.size() < 5, "You can have at most 4 shortcuts." + twaManifest.shortcuts.eachWithIndex { s, i -> + assert s.name != null, 'Missing `name` in shortcut #' + i + assert s.short_name != null, 'Missing `short_name` in shortcut #' + i + assert s.url != null, 'Missing `icon` in shortcut #' + i + assert s.icon != null, 'Missing `url` in shortcut #' + i + } + + def shortcutsFile = new File("$projectDir/src/main/res/xml", "shortcuts.xml") + + def xmlWriter = new StringWriter() + def xmlMarkup = new MarkupBuilder(new IndentPrinter(xmlWriter, " ", true)) + + xmlMarkup + .'shortcuts'('xmlns:android': 'http://schemas.android.com/apk/res/android') { + twaManifest.shortcuts.eachWithIndex { s, i -> + 'shortcut'( + 'android:shortcutId': 'shortcut' + i, + 'android:enabled': 'true', + 'android:icon': '@drawable/' + s.icon, + 'android:shortcutShortLabel': '@string/shortcut_short_name_' + i, + 'android:shortcutLongLabel': '@string/shortcut_name_' + i) { + 'intent'( + 'android:action': 'android.intent.action.MAIN', + 'android:targetPackage': twaManifest.applicationId, + 'android:targetClass': twaManifest.applicationId + '.LauncherActivity', + 'android:data': s.url) + 'categories'('android:name': 'android.intent.category.LAUNCHER') + } + } + } + shortcutsFile.text = xmlWriter.toString() + '\n' +} + +preBuild.dependsOn(generateShorcutsFile) + +repositories { + +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + + implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.6.2' + +} diff --git a/twa/app/src/main/AndroidManifest.xml b/twa/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7b28ccb --- /dev/null +++ b/twa/app/src/main/AndroidManifest.xml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/twa/app/src/main/java/com/imyeyu/gao/customer/Application.java b/twa/app/src/main/java/com/imyeyu/gao/customer/Application.java new file mode 100644 index 0000000..47dbe27 --- /dev/null +++ b/twa/app/src/main/java/com/imyeyu/gao/customer/Application.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.imyeyu.gao.customer; + + + +public class Application extends android.app.Application { + + + + @Override + public void onCreate() { + super.onCreate(); + + } +} diff --git a/twa/app/src/main/java/com/imyeyu/gao/customer/DelegationService.java b/twa/app/src/main/java/com/imyeyu/gao/customer/DelegationService.java new file mode 100644 index 0000000..20fbfc2 --- /dev/null +++ b/twa/app/src/main/java/com/imyeyu/gao/customer/DelegationService.java @@ -0,0 +1,14 @@ +package com.imyeyu.gao.customer; + + + +public class DelegationService extends + com.google.androidbrowserhelper.trusted.DelegationService { + @Override + public void onCreate() { + super.onCreate(); + + + } +} + diff --git a/twa/app/src/main/java/com/imyeyu/gao/customer/LauncherActivity.java b/twa/app/src/main/java/com/imyeyu/gao/customer/LauncherActivity.java new file mode 100644 index 0000000..4c0b375 --- /dev/null +++ b/twa/app/src/main/java/com/imyeyu/gao/customer/LauncherActivity.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.imyeyu.gao.customer; + +import android.content.pm.ActivityInfo; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; + + + +public class LauncherActivity + extends com.google.androidbrowserhelper.trusted.LauncherActivity { + + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // Setting an orientation crashes the app due to the transparent background on Android 8.0 + // Oreo and below. We only set the orientation on Oreo and above. This only affects the + // splash screen and Chrome will still respect the orientation. + // See https://github.com/GoogleChromeLabs/bubblewrap/issues/496 for details. + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } + } + + @Override + protected Uri getLaunchingUrl() { + // Get the original launch Url. + Uri uri = super.getLaunchingUrl(); + + + + return uri; + } +} diff --git a/twa/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml b/twa/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml new file mode 100644 index 0000000..d53c148 --- /dev/null +++ b/twa/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/twa/app/src/main/res/drawable-hdpi/splash.png b/twa/app/src/main/res/drawable-hdpi/splash.png new file mode 100644 index 0000000..2be828d Binary files /dev/null and b/twa/app/src/main/res/drawable-hdpi/splash.png differ diff --git a/twa/app/src/main/res/drawable-mdpi/splash.png b/twa/app/src/main/res/drawable-mdpi/splash.png new file mode 100644 index 0000000..322075a Binary files /dev/null and b/twa/app/src/main/res/drawable-mdpi/splash.png differ diff --git a/twa/app/src/main/res/drawable-xhdpi/splash.png b/twa/app/src/main/res/drawable-xhdpi/splash.png new file mode 100644 index 0000000..452d523 Binary files /dev/null and b/twa/app/src/main/res/drawable-xhdpi/splash.png differ diff --git a/twa/app/src/main/res/drawable-xxhdpi/splash.png b/twa/app/src/main/res/drawable-xxhdpi/splash.png new file mode 100644 index 0000000..29891c2 Binary files /dev/null and b/twa/app/src/main/res/drawable-xxhdpi/splash.png differ diff --git a/twa/app/src/main/res/drawable-xxxhdpi/splash.png b/twa/app/src/main/res/drawable-xxxhdpi/splash.png new file mode 100644 index 0000000..4972524 Binary files /dev/null and b/twa/app/src/main/res/drawable-xxxhdpi/splash.png differ diff --git a/twa/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/twa/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..0480797 --- /dev/null +++ b/twa/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/twa/app/src/main/res/mipmap-hdpi/ic_launcher.png b/twa/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..fce2e63 Binary files /dev/null and b/twa/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/twa/app/src/main/res/mipmap-hdpi/ic_maskable.png b/twa/app/src/main/res/mipmap-hdpi/ic_maskable.png new file mode 100644 index 0000000..15bd433 Binary files /dev/null and b/twa/app/src/main/res/mipmap-hdpi/ic_maskable.png differ diff --git a/twa/app/src/main/res/mipmap-mdpi/ic_launcher.png b/twa/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..a760fa1 Binary files /dev/null and b/twa/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/twa/app/src/main/res/mipmap-mdpi/ic_maskable.png b/twa/app/src/main/res/mipmap-mdpi/ic_maskable.png new file mode 100644 index 0000000..39e9a17 Binary files /dev/null and b/twa/app/src/main/res/mipmap-mdpi/ic_maskable.png differ diff --git a/twa/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/twa/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..df0d140 Binary files /dev/null and b/twa/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/twa/app/src/main/res/mipmap-xhdpi/ic_maskable.png b/twa/app/src/main/res/mipmap-xhdpi/ic_maskable.png new file mode 100644 index 0000000..1b94bdd Binary files /dev/null and b/twa/app/src/main/res/mipmap-xhdpi/ic_maskable.png differ diff --git a/twa/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/twa/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..ab29946 Binary files /dev/null and b/twa/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/twa/app/src/main/res/mipmap-xxhdpi/ic_maskable.png b/twa/app/src/main/res/mipmap-xxhdpi/ic_maskable.png new file mode 100644 index 0000000..d8aa8ff Binary files /dev/null and b/twa/app/src/main/res/mipmap-xxhdpi/ic_maskable.png differ diff --git a/twa/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/twa/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..57f497d Binary files /dev/null and b/twa/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/twa/app/src/main/res/mipmap-xxxhdpi/ic_maskable.png b/twa/app/src/main/res/mipmap-xxxhdpi/ic_maskable.png new file mode 100644 index 0000000..fdca916 Binary files /dev/null and b/twa/app/src/main/res/mipmap-xxxhdpi/ic_maskable.png differ diff --git a/twa/app/src/main/res/raw/web_app_manifest.json b/twa/app/src/main/res/raw/web_app_manifest.json new file mode 100644 index 0000000..16cdf94 --- /dev/null +++ b/twa/app/src/main/res/raw/web_app_manifest.json @@ -0,0 +1,27 @@ +{ + "name": "Gao Customer H5", + "short_name": "Gao H5", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#ffffff", + "start_url": "/", + "scope": "/", + "icons": [ + { + "src": "/icons/icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icons/icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "/icons/icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/twa/app/src/main/res/values/colors.xml b/twa/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..e66222d --- /dev/null +++ b/twa/app/src/main/res/values/colors.xml @@ -0,0 +1,18 @@ + + + #F5F5F5 + diff --git a/twa/app/src/main/res/values/strings.xml b/twa/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..24dc012 --- /dev/null +++ b/twa/app/src/main/res/values/strings.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + [{ + \"relation\": [\"delegate_permission/common.handle_all_urls\"], + \"target\": { + \"namespace\": \"web\", + \"site\": \"https://gao.imyeyu.com\" + } + }] + + + diff --git a/twa/app/src/main/res/xml/filepaths.xml b/twa/app/src/main/res/xml/filepaths.xml new file mode 100644 index 0000000..a543485 --- /dev/null +++ b/twa/app/src/main/res/xml/filepaths.xml @@ -0,0 +1,18 @@ + + + + diff --git a/twa/app/src/main/res/xml/shortcuts.xml b/twa/app/src/main/res/xml/shortcuts.xml new file mode 100644 index 0000000..7f3e9c1 --- /dev/null +++ b/twa/app/src/main/res/xml/shortcuts.xml @@ -0,0 +1,16 @@ + + diff --git a/twa/build.gradle b/twa/build.gradle new file mode 100644 index 0000000..a3d57ce --- /dev/null +++ b/twa/build.gradle @@ -0,0 +1,42 @@ +/* + * Copyright 2019 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.9.1' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/twa/gradle.properties b/twa/gradle.properties new file mode 100644 index 0000000..784a1d4 --- /dev/null +++ b/twa/gradle.properties @@ -0,0 +1,14 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +android.useAndroidX=true diff --git a/twa/gradle/wrapper/gradle-wrapper.jar b/twa/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..5c2d1cf Binary files /dev/null and b/twa/gradle/wrapper/gradle-wrapper.jar differ diff --git a/twa/gradle/wrapper/gradle-wrapper.properties b/twa/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..719e736 --- /dev/null +++ b/twa/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true diff --git a/twa/gradlew b/twa/gradlew new file mode 100644 index 0000000..b740cf1 --- /dev/null +++ b/twa/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/twa/gradlew.bat b/twa/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/twa/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/twa/manifest-checksum.txt b/twa/manifest-checksum.txt new file mode 100644 index 0000000..2db40d9 --- /dev/null +++ b/twa/manifest-checksum.txt @@ -0,0 +1 @@ +dff2536399b4ac0116642fb1c752408b59929697 \ No newline at end of file diff --git a/twa/settings.gradle b/twa/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/twa/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/twa/store_icon.png b/twa/store_icon.png new file mode 100644 index 0000000..0684be3 Binary files /dev/null and b/twa/store_icon.png differ diff --git a/twa/twa-manifest.json b/twa/twa-manifest.json new file mode 100644 index 0000000..3f41cbc --- /dev/null +++ b/twa/twa-manifest.json @@ -0,0 +1,47 @@ +{ + "packageId": "com.imyeyu.gao.customer", + "host": "gao.imyeyu.com", + "name": "糕店客户管理", + "launcherName": "糕店管理", + "display": "standalone", + "themeColor": "#FFFFFF", + "themeColorDark": "#000000", + "navigationColor": "#000000", + "navigationColorDark": "#000000", + "navigationDividerColor": "#000000", + "navigationDividerColorDark": "#000000", + "backgroundColor": "#FFFFFF", + "enableNotifications": false, + "startUrl": "/", + "iconUrl": "https://gao.imyeyu.com/icons/icon-512.png", + "maskableIconUrl": "https://gao.imyeyu.com/icons/icon-maskable-512.png", + "splashScreenFadeOutDuration": 300, + "signingKey": { + "path": "./android.keystore", + "alias": "gao-customer" + }, + "appVersionName": "1", + "appVersionCode": 1, + "shortcuts": [], + "generatorApp": "bubblewrap-cli", + "webManifestUrl": "https://gao.imyeyu.com/manifest.webmanifest", + "fallbackType": "customtabs", + "features": {}, + "alphaDependencies": { + "enabled": false + }, + "enableSiteSettingsShortcut": true, + "isChromeOSOnly": false, + "isMetaQuest": false, + "fullScopeUrl": "https://gao.imyeyu.com/", + "minSdkVersion": 21, + "orientation": "portrait", + "fingerprints": [], + "additionalTrustedOrigins": [], + "retainedBundles": [], + "protocolHandlers": [], + "fileHandlers": [], + "launchHandlerClientMode": "", + "displayOverride": [], + "appVersion": "1" +}