优化
This commit is contained in:
parent
e79100d770
commit
64d657f784
@ -8,6 +8,7 @@ import promptAction from '@ohos.promptAction';
|
||||
export default struct Exiting {
|
||||
@State showVideo: boolean = false
|
||||
@State base64: string = ""
|
||||
public title: string = "提示"
|
||||
private controller: CustomDialogController
|
||||
private xComponentController: XComponentController = new XComponentController()
|
||||
private cameraUtils: CameraUtils = new CameraUtils(getContext(this) as common.UIAbilityContext)
|
||||
@ -15,17 +16,13 @@ export default struct Exiting {
|
||||
private loading: boolean = false
|
||||
public onSubmit?: (base64: string) => void
|
||||
|
||||
async aboutToDisappear(): Promise<void> {
|
||||
this.cameraUtils.stopPreview()
|
||||
await this.cameraUtils.destroy()
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Text().width(18)
|
||||
Text("提示").fontSize(28).fontColor(0xffffff)
|
||||
Blank()
|
||||
Image($rawfile("img/close.png")).width(18)
|
||||
Text().width(18)
|
||||
// Image($rawfile("img/close.png")).width(18)
|
||||
}
|
||||
.width("100%")
|
||||
.linearGradient({
|
||||
@ -60,7 +57,9 @@ export default struct Exiting {
|
||||
buttonType: CusButtonType.Info
|
||||
})
|
||||
.margin({ right: 6 })
|
||||
.onClick(() => {
|
||||
.onClick(async () => {
|
||||
this.cameraUtils.stopPreview()
|
||||
await this.cameraUtils.destroy()
|
||||
this.controller.close()
|
||||
})
|
||||
CusButton({
|
||||
@ -82,7 +81,7 @@ export default struct Exiting {
|
||||
message: JSON.stringify(e)
|
||||
})
|
||||
}).finally(() => {
|
||||
this.loading = true
|
||||
this.loading = false
|
||||
})
|
||||
})
|
||||
} else {
|
||||
@ -100,7 +99,8 @@ export default struct Exiting {
|
||||
buttonType: CusButtonType.Primary
|
||||
})
|
||||
.margin({ left: 6 })
|
||||
.onClick(() => {
|
||||
.onClick(async () => {
|
||||
await this.cameraUtils.stopPreview()
|
||||
this.cameraUtils.destroy()
|
||||
this.onSubmit?.(this.base64)
|
||||
})
|
||||
|
||||
@ -15,10 +15,11 @@ export default struct TipDialog {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Text().width(18)
|
||||
Text("提示").fontSize(28).fontColor(0xffffff)
|
||||
Blank()
|
||||
Image($rawfile("img/close.png")).width(18)
|
||||
Text().width(18)
|
||||
// Image($rawfile("img/close.png")).width(18)
|
||||
}
|
||||
.width("100%")
|
||||
.linearGradient({
|
||||
|
||||
@ -4,13 +4,10 @@ import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import window from '@ohos.window';
|
||||
import { requestPermission } from '../utils/SystemUtils';
|
||||
import Logger, { LoggerLevel } from '../utils/Logger';
|
||||
import Logger, { LoggerLevel, LoggerMode } from '../utils/Logger';
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(_want: Want, _launchParam: AbilityConstant.LaunchParam): void {
|
||||
Logger.init({
|
||||
level: LoggerLevel.Debug
|
||||
})
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
}
|
||||
|
||||
@ -20,11 +17,16 @@ export default class EntryAbility extends UIAbility {
|
||||
|
||||
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||
|
||||
let window = await windowStage.getMainWindow()
|
||||
window.setWindowSystemBarEnable(["status"])
|
||||
window.setWindowLayoutFullScreen(true)
|
||||
requestPermission(this.context, ['ohos.permission.CAMERA', 'ohos.permission.FILE_ACCESS_MANAGER'])
|
||||
requestPermission(this.context, ['ohos.permission.CAMERA', "ohos.permission.READ_IMAGEVIDEO", 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA', 'ohos.permission.FILE_ACCESS_MANAGER'])
|
||||
.then(() => {
|
||||
Logger.init({
|
||||
level: LoggerLevel.Debug,
|
||||
mode: LoggerMode.Production
|
||||
})
|
||||
windowStage.loadContent('pages/Login', (err) => {
|
||||
if (err.code) {
|
||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
|
||||
@ -1,10 +1,57 @@
|
||||
import Footer from '../components/Footer'
|
||||
import window from '@ohos.window'
|
||||
import Header from '../components/Header'
|
||||
|
||||
interface ProjectItem {
|
||||
name: string
|
||||
value?: string
|
||||
picture?: string
|
||||
}
|
||||
|
||||
interface Project {
|
||||
name: string
|
||||
items: Array<ProjectItem>
|
||||
}
|
||||
|
||||
const Projects: Array<Project> = [
|
||||
{
|
||||
name: "左前45°查验项目",
|
||||
items: [{ name: "车身颜色" }, { name: "车辆外观" }, { name: "号牌板" }, { name: "车辆品牌" }]
|
||||
},
|
||||
{
|
||||
name: "右后45°查验项目",
|
||||
items: [{ name: "车身颜色" }, { name: "车辆外观" }, { name: "车辆品牌" }, { name: "反光背心" }, { name: "三脚架" }]
|
||||
},
|
||||
{
|
||||
name: "轮胎规格查验项目",
|
||||
items: [{ name: "轮胎规格" }, { name: "轮胎规格" }, { name: "轮胎规格" }, { name: "轮胎规格" }]
|
||||
},
|
||||
{
|
||||
name: "车辆喷涂查验项目",
|
||||
items: [{ name: "总质量" }, { name: "栏板高度" }, { name: "核定载人数" }]
|
||||
},
|
||||
{
|
||||
name: "车辆铭牌查验项目",
|
||||
items: [{ name: "品牌" }, { name: "栏板高度" }, { name: "生产日期" }, { name: "车辆识别代号" }, {
|
||||
name: "生产厂家"
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "车辆铭牌查验项目",
|
||||
items: [{ name: "车辆识别代号" }]
|
||||
},
|
||||
{
|
||||
name: "发动机号查验项目",
|
||||
items: [{ name: "发动机号" }]
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ProjectCheck {
|
||||
@State projects: Array<Project> = Projects
|
||||
@State current: number = 0
|
||||
|
||||
aboutToAppear(): void {
|
||||
|
||||
}
|
||||
@ -13,10 +60,17 @@ struct ProjectCheck {
|
||||
Column() {
|
||||
Header()
|
||||
Row() {
|
||||
Image($rawfile('img/check/scan.png')).layoutWeight(1).margin({ right: 32 }).height("100%")
|
||||
Image($rawfile('img/check/background.png')).layoutWeight(1).margin({ right: 32 }).height("100%")
|
||||
Column() {
|
||||
|
||||
}.width("33%")
|
||||
Text(this.projects[this.current].name).fontSize(36).fontColor(0x161B21).fontWeight(700).margin({ bottom: 64 })
|
||||
Text("识别结果").fontSize(24).fontColor(0x161B21).fontWeight(700).margin({ bottom: 30 })
|
||||
ForEach(this.projects[this.current].items, (item: ProjectItem) => {
|
||||
RowSplit() {
|
||||
Text(item.name).width("16%").fontWeight(700).fontSize(18).fontColor(0x161B21)
|
||||
Text(item.value).layoutWeight(1).fontSize(18).fontColor(0x102A9A).padding({ left: 20 })
|
||||
}.resizeable(false).borderColor(0xAEC4E8).margin({ bottom: 12 })
|
||||
})
|
||||
}.width("33%").height("100%").alignItems(HorizontalAlign.Start).justifyContent(FlexAlign.Start)
|
||||
}.layoutWeight(1).width("100%").padding({ left: 32, top: 40, right: 32, bottom: 40 }).backgroundColor(0xd7ebfd)
|
||||
|
||||
Footer()
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import Footer from '../components/Footer'
|
||||
import Header from '../components/Header'
|
||||
import TakePhotoDialog from '../components/TakePhotoDialog'
|
||||
import router from '@ohos.router'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -10,6 +11,9 @@ struct Waiting {
|
||||
onSubmit: (base64: string) => {
|
||||
AppStorage.setOrCreate("photo1", base64)
|
||||
this.controller.close()
|
||||
router.pushUrl({
|
||||
url: "pages/ProjectCheck"
|
||||
})
|
||||
}
|
||||
}),
|
||||
customStyle: true,
|
||||
@ -36,7 +40,7 @@ struct Waiting {
|
||||
|
||||
Text("完成上述内容后点击屏幕")
|
||||
.fontColor(0x3F4042)
|
||||
.fontSize(32)
|
||||
.fontSize(32).margin({ top: 12 })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@ interface LoggerOption {
|
||||
}
|
||||
|
||||
export enum LoggerLevel {
|
||||
Info,
|
||||
Warn,
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug
|
||||
}
|
||||
|
||||
@ -20,8 +20,9 @@ export enum LoggerMode {
|
||||
}
|
||||
|
||||
const MB = 1024 * 1024
|
||||
const PATH = "/data/log/duolun/log"
|
||||
const TAG = "Logger"
|
||||
const DuolunPath = '/mnt/hmdfs/100/account/device_view/local/files/duolun'
|
||||
const LogPath = "/mnt/hmdfs/100/account/device_view/local/files/duolun/logs"
|
||||
const Tag = "Logger"
|
||||
|
||||
function formatDate(date: Date, fmt = 'yyyy-MM-dd') {
|
||||
date = date instanceof Date ? date : new Date(date);
|
||||
@ -55,7 +56,6 @@ function pathJoin(...path: string[]) {
|
||||
return path.join("/")
|
||||
}
|
||||
|
||||
|
||||
export default class Logger {
|
||||
private static mode: LoggerMode = LoggerMode.Development
|
||||
private static level: LoggerLevel = LoggerLevel.Info
|
||||
@ -65,21 +65,33 @@ export default class Logger {
|
||||
private static fd: number = 0
|
||||
|
||||
private static createDir() {
|
||||
if (!fs.accessSync(PATH)) {
|
||||
fs.mkdirSync(PATH)
|
||||
}
|
||||
if (!fs.accessSync(pathJoin(PATH, Logger.date))) {
|
||||
fs.mkdirSync(pathJoin(PATH, Logger.date))
|
||||
try {
|
||||
if (!fs.accessSync(DuolunPath)) {
|
||||
fs.mkdirSync(DuolunPath)
|
||||
}
|
||||
if (!fs.accessSync(LogPath)) {
|
||||
fs.mkdirSync(LogPath)
|
||||
}
|
||||
let path = pathJoin(LogPath, Logger.date)
|
||||
if (!fs.accessSync(path)) {
|
||||
fs.mkdirSync(path)
|
||||
}
|
||||
} catch (e) {
|
||||
hilog.error(0x0000, Tag, JSON.stringify(e))
|
||||
}
|
||||
}
|
||||
|
||||
private static createNewFile() {
|
||||
Logger.date = formatDate(new Date(), "yyyy_MM_dd")
|
||||
Logger.time = formatDate(new Date(), "HH_mm_ss.SSS")
|
||||
let path = pathJoin(PATH, Logger.date, Logger.time, "log")
|
||||
if (!fs.accessSync(path)) {
|
||||
let file = fs.openSync(path, fs.OpenMode.CREATE | fs.OpenMode.APPEND | fs.OpenMode.WRITE_ONLY)
|
||||
Logger.fd = file.fd
|
||||
try {
|
||||
Logger.date = formatDate(new Date(), "yyyy_MM_dd")
|
||||
Logger.time = formatDate(new Date(), "HH_mm_ss.SSS")
|
||||
let path = pathJoin(LogPath, Logger.date, Logger.time) + ".log"
|
||||
if (!fs.accessSync(path)) {
|
||||
let file = fs.openSync(path, fs.OpenMode.CREATE | fs.OpenMode.APPEND | fs.OpenMode.WRITE_ONLY)
|
||||
Logger.fd = file.fd
|
||||
}
|
||||
} catch (e) {
|
||||
hilog.error(0x0000, Tag, JSON.stringify(e))
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,14 +99,14 @@ export default class Logger {
|
||||
if (type > Logger.level) {
|
||||
return
|
||||
}
|
||||
const map = ["info", "warn", "error", "debug"]
|
||||
const map = ["error", "warn", "info", "debug"]
|
||||
if (Logger.mode === LoggerMode.Development) {
|
||||
hilog.debug(0x0000, TAG, `${map[type]} start`)
|
||||
hilog.debug(0x0000, Tag, `${map[type]} start`)
|
||||
let resultMessage = message.join(" ")
|
||||
for (let i = 0; i < resultMessage.length; i + 100) {
|
||||
hilog.debug(0x0000, TAG, resultMessage.slice(i, i + 100))
|
||||
for (let i = 0; i < resultMessage.length; i += 200) {
|
||||
hilog.debug(0x0000, Tag, resultMessage.slice(i, i + 200))
|
||||
}
|
||||
hilog.debug(0x0000, TAG, `${map[type]} end`)
|
||||
hilog.debug(0x0000, Tag, `${map[type]} end`)
|
||||
} else {
|
||||
try {
|
||||
if (fs.statSync(Logger.fd).size >= Logger.size) {
|
||||
@ -102,17 +114,19 @@ export default class Logger {
|
||||
}
|
||||
fs.writeSync(Logger.fd, `[${formatDate(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")}]-[${map[type]}]: ${message.join(" ")}\n`)
|
||||
} catch (e) {
|
||||
hilog.error(0x0000, TAG, JSON.stringify(e))
|
||||
hilog.error(0x0000, Tag, JSON.stringify(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static init(option?: LoggerOption) {
|
||||
Logger.level = option.level || LoggerLevel.Info
|
||||
Logger.size = option.size || MB * 10
|
||||
Logger.mode = option.mode || LoggerMode.Development
|
||||
Logger.createDir()
|
||||
Logger.createNewFile()
|
||||
Logger.level = option?.level || LoggerLevel.Info
|
||||
Logger.size = option?.size || MB * 10
|
||||
Logger.mode = option?.mode || LoggerMode.Development
|
||||
if (Logger.mode === LoggerMode.Production) {
|
||||
Logger.createDir()
|
||||
Logger.createNewFile()
|
||||
}
|
||||
}
|
||||
|
||||
static info(...message: string[]) {
|
||||
|
||||
@ -43,9 +43,6 @@
|
||||
{
|
||||
"name": "ohos.permission.FILE_ACCESS_MANAGER"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.DISTRIBUTED_DATASYNC",
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.STORAGE_MANAGER"
|
||||
},
|
||||
@ -78,7 +75,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.sec.ACCESS_UDID"
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
BIN
entry/src/main/resources/rawfile/img/check/background.png
Normal file
BIN
entry/src/main/resources/rawfile/img/check/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
Loading…
x
Reference in New Issue
Block a user