feat: add minimizeApp & router back for android
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -48,6 +48,6 @@ jobs:
|
||||
# deploy to edgeone
|
||||
# see https://edgeone.ai/zh/document/180255338996572160?product=edgedeveloperplatform
|
||||
- name: Deploy to EdgeOne Pages
|
||||
run: npx edgeone pages deploy .output/public -n cook -t ${{ secrets.EDGEONE_API_TOKEN }}
|
||||
run: npx edgeone pages deploy .output/public -n cook-yunyoujun-cn -t ${{ secrets.EDGEONE_API_TOKEN }}
|
||||
env:
|
||||
EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}
|
||||
|
||||
@@ -1,41 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
|
||||
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
|
||||
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation" android:exported="true" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name=".MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths"></meta-data>
|
||||
<provider android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
|
||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
<!-- Permissions -->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
||||
|
||||
41
android/app/src/main/AndroidManifest.xml.orig
Normal file
41
android/app/src/main/AndroidManifest.xml.orig
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths"></meta-data>
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
<!-- Permissions -->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
||||
@@ -1,7 +1,33 @@
|
||||
<script lang="ts" setup>
|
||||
import { App } from '@capacitor/app'
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import { useBackButton } from '@ionic/vue'
|
||||
|
||||
useHead({
|
||||
title: 'Cook Tabs',
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
const ionRouter = useIonRouter()
|
||||
|
||||
function isTabRootPath(path: string) {
|
||||
// Tabs are set up with aliases: '/', '/home', '/random', '/my'
|
||||
// Treat '/tabs' as root too for safety
|
||||
return ['/', '/home', '/random', '/my', '/tabs'].includes(path)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (Capacitor.getPlatform() === 'android') {
|
||||
useBackButton(10, () => {
|
||||
if (isTabRootPath(router.currentRoute.value.path)) {
|
||||
App.minimizeApp()
|
||||
}
|
||||
else {
|
||||
ionRouter.back()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { appDescription } from './app/constants/index'
|
||||
|
||||
import { getLatestCommit } from './scripts/git'
|
||||
|
||||
try {
|
||||
const latestCommit = await getLatestCommit()
|
||||
/**
|
||||
* CF_PAGES_COMMIT_SHA is Cloudflare Pages env
|
||||
@@ -18,6 +19,12 @@ const latestCommit = await getLatestCommit()
|
||||
import.meta.env.VITE_COMMIT_REF = process.env.CF_PAGES_COMMIT_SHA || latestCommit?.hash || ''
|
||||
// add build date string to env
|
||||
import.meta.env.VITE_APP_BUILD_DATE = latestCommit?.date || new Date().toString()
|
||||
}
|
||||
catch (e) {
|
||||
console.error('Not in git repo, get latest commit failed:', e)
|
||||
import.meta.env.VITE_APP_BUILD_DATE = new Date().toString()
|
||||
import.meta.env.VITE_COMMIT_REF = ''
|
||||
}
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import path from 'node:path'
|
||||
import url from 'node:url'
|
||||
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
const __dirname = import.meta.dirname
|
||||
const recipeCsvFile = path.resolve(__dirname, '../app/data/recipe.csv')
|
||||
const recipeJsonFile = path.resolve(__dirname, '../app/data/recipe.json')
|
||||
const incompatibleFoodsCsvFile = path.resolve(__dirname, '../app/data/incompatible-foods.csv')
|
||||
|
||||
Reference in New Issue
Block a user